-
Notifications
You must be signed in to change notification settings - Fork 63
/
flake.nix
113 lines (97 loc) · 3.09 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils = {
url = "github:numtide/flake-utils";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
pre-commit-hooks,
nixpkgs,
flake-utils,
treefmt-nix,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
# Current Version of Morph
# TODO: this sucks...
version = "dev";
pkgs = (import nixpkgs) { inherit system; };
# Eval the treefmt modules from ./treefmt.nix
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in
rec {
# for `nix fmt`
formatter = treefmtEval.config.build.wrapper;
# for `nix flake check`
checks = {
vm_integration_tests = pkgs.callPackage ./nixos/tests/integration_tests.nix { inherit packages; };
formatting = treefmtEval.config.build.check self;
build = self.packages.${system}.morph;
pre-commit-check =
let
# some treefmt formatters are not supported in pre-commit-hooks we
# filter them out for now.
toFilter = [
"yamlfmt"
"nixfmt"
];
filterFn = n: _v: (!builtins.elem n toFilter);
treefmtFormatters = pkgs.lib.mapAttrs (_n: v: { inherit (v) enable; }) (
pkgs.lib.filterAttrs filterFn (import ./treefmt.nix).programs
);
in
pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = treefmtFormatters // {
nixfmt-rfc-style.enable = true;
};
};
};
# Acessible through 'nix develop' or 'nix-shell' (legacy)
devShells.default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
inputsFrom = [ self.packages.${system}.morph ];
};
packages = rec {
default = morph;
morph = pkgs.buildGoModule rec {
name = "morph-unstable-${version}";
inherit version;
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
ldflags = [
"-X main.version=${version}"
"-X main.assetRoot=${placeholder "lib"}"
];
vendorHash = "sha256-zQlMtbXgrH83zrcIoOuFhb2tYCeQ1pz4UQUvRIsLMCE==";
postInstall = ''
mkdir -p $lib
cp -v ./data/*.nix $lib
'';
outputs = [
"out"
"lib"
];
meta = {
homepage = "https://github.com/DBCDK/morph";
description = "Morph is a NixOS host manager written in Golang.";
mainProgram = "morph";
};
};
};
}
);
}