-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.nix
58 lines (57 loc) · 1.71 KB
/
build.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
defaults:
{
nixpkgs ? defaults.nixpkgs,
deploySystem ? defaults.deploySystem,
libOverlay ? null,
specialArgs ? { },
}:
let
extendLib = lib:
let
libOverlays = [
(import ./dag.nix)
(import ./ip.nix)
] ++ lib.optional (libOverlay != null) libOverlay;
combinedLibOverlay = lib.foldl' lib.composeExtensions (self: super: {}) libOverlays;
in lib.extend combinedLibOverlay;
nixusPkgs = import nixpkgs {
config = {};
overlays = [
(self: super: {
lib = extendLib super.lib;
})
];
system = deploySystem;
};
in
conf:
let
result = nixusPkgs.lib.evalModules {
modules = [
modules/options.nix
modules/deploy.nix
modules/secrets.nix
modules/ssh.nix
modules/public-ip.nix
modules/dns.nix
modules/vpn
conf
# Not naming it pkgs to avoid confusion and trouble for overriding scopes
{
_module.args.nixus = {
pkgs = nixusPkgs;
inherit extendLib;
};
_module.args.pkgs = throw "You're trying to access the pkgs argument from a Nixus module, use the nixus argument instead and use nixus.pkgs from that.";
}
];
inherit specialArgs;
};
in
result.config.deployScript
# Since https://github.com/NixOS/nixpkgs/pull/143207, the evalModules result contains a `type` attribute,
# which if we don't remove it here would override the `type = "derivation"` from the above derivation
# which is used by Nix to determine whether it should build the toplevel derivation or recurse
# If we don't remove it, Nix would therefore recurse into this resulting attribute set
// removeAttrs result [ "type" ]
// nixusPkgs.lib.mapAttrs (n: v: v.deployScript) result.config.nodes