-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnonflake.nix
More file actions
85 lines (70 loc) · 2.19 KB
/
Copy pathnonflake.nix
File metadata and controls
85 lines (70 loc) · 2.19 KB
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
let
# flake.lock lockfile
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
# pins, we get it from the flake.lock
# we only source the direct deps, transitive deps are not sourced
neededPins = builtins.listToAttrs (
map
(name: {
inherit name;
value = null;
})
[
"nixpkgs"
"sops-nix"
"lanzaboote"
"svcvm"
"hosts"
"xkcd"
]
);
pins = builtins.mapAttrs (_: node: node.locked) (builtins.intersectAttrs neededPins lock.nodes);
# sources, everything is currently a fetchTarball
# also everything happens to be from github
sources = builtins.mapAttrs (
name: _:
fetchTarball {
url = "https://github.com/${pins.${name}.owner}/${pins.${name}.repo}/archive/${pins.${name}.rev}.tar.gz";
sha256 = pins.${name}.narHash;
}
) pins;
# the nix packages collection
pkgs = import sources.nixpkgs { };
# consumed by the modules
# it is possible to directly reference sources
# but inputs dress everything up nicely
# so that it looks like the flake inputs' outputs
inputs = {
# the sops-nix module
sops-nix.nixosModules.sops = "${sources.sops-nix}/modules/sops";
# the lanzaboote module
lanzaboote.nixosModules.lanzaboote =
(import sources.lanzaboote { inherit pkgs; }).nixosModules.lanzaboote;
# the svcvm module
svcvm.nixosModules.host = "${sources.svcvm}/module";
# the hosts outPath
hosts.outPath = sources.hosts;
# the xkcd-wall package
xkcd.packages.${pkgs.stdenv.hostPlatform.system}.default = import sources.xkcd { inherit pkgs; };
};
# helpers
helpers = import ./helpers.nix;
# additional lib functions
lib = (import ./lib) // {
inherit mkConfig;
};
# non-flake mkConfig
mkConfig = helpers.mkConfigBuilder {
nixos = import "${pkgs.path}/nixos/lib/eval-config.nix";
flakeInputs = inputs;
flakeSelf = self;
flakeLib = pkgs.lib // lib;
nonflake = true;
};
# nixosConfigurations & nixosModules
nixosConfigurations = helpers.nixosConfigurations { inherit mkConfig; };
inherit (helpers) nixosModules;
# everything to expose
self = { inherit lib nixosModules nixosConfigurations; };
in
self