-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
92 lines (92 loc) · 2.44 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
{
description = "regula-nix enforcing security standards on nixos";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixdoc = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:adisbladis/mdbook-nixdoc";
};
};
outputs =
inputs:
with inputs;
let
forAllSystems =
function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
# "aarch64-linux"
] (system: function nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (pkgs: {
default = self.nixosConfigurations.default.config.system.build.toplevel;
docs = pkgs.callPackage ./packages/docs.nix {
mdbook-nixdoc = nixdoc.packages.x86_64-linux.default;
};
});
apps = forAllSystems (pkgs: {
serve = {
type = "app";
program = toString (
pkgs.writeScript "doc-serve" ''
${pkgs.mdbook}/bin/mdbook serve ./docs/
''
);
};
act = {
type = "app";
program = toString (
pkgs.writeScript "doc-serve" ''
${pkgs.act}/bin/act
''
);
};
statix = {
type = "app";
program = toString (
pkgs.writeScript "statix" ''
${pkgs.statix}/bin/statix $@
''
);
};
});
# Sample config to test behaviors
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.regula
./modules/test-system
];
};
nixosModules = {
default = self.nixosModules.regula;
regula = import ./modules/regula;
};
checks = forAllSystems (pkgs: {
default = self.nixosConfigurations.default.config.system.build.toplevel;
codeCheck = pkgs.callPackage (
{
runCommandNoCCLocal,
statix,
deadnix,
nixfmt-rfc-style,
}:
runCommandNoCCLocal "statix-check"
{
buildInputs = [
statix
deadnix
nixfmt-rfc-style
];
}
''
touch $out
statix check ${self} | tee -a $out
deadnix check --fail ${self} | tee -a $out
nixfmt -c ${self} | tee -a $out
''
) { };
});
};
}