-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdefault.nix
51 lines (49 loc) · 1.58 KB
/
default.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
let
evalModules = import ./eval-modules.nix;
in {
evaluateInputs = {
lockFile,
modules,
initialInputs,
}: let
inherit ((builtins.fromJSON (builtins.readFile lockFile))) nodes;
evaluatedInputs =
if (builtins.pathExists lockFile && nodes ? nixpkgs)
then let
nixpkgsLock = nodes.nixpkgs.locked;
lib = import ((builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsLock.rev}.tar.gz";
sha256 = nixpkgsLock.narHash;
})
+ "/lib");
in
(evalModules {
inherit modules;
inputs = {
nixpkgs = {
inherit lib;
inherit (nixpkgsLock) rev;
lastModified = toString nixpkgsLock.lastModified;
shortRev = builtins.substring 0 7 nixpkgsLock.rev;
};
};
system = builtins.currentSystem;
})
.config
.inputs
else builtins.trace "[1;31mInputs need to be evaluated again.[0m" {};
in
assert builtins.elem "nixpkgs" (builtins.attrNames initialInputs) || throw "nixpkgs input not found in initialInputs" {};
assert builtins.elem "home-manager" (builtins.attrNames initialInputs) || throw "home-manager input not found in initialInputs" {};
evaluatedInputs // initialInputs;
nixosSystem = {
inputs,
system,
modules,
}: let
inherit ((evalModules {inherit modules inputs system;}).config) osModules;
evaluated = evalModules {
inherit modules inputs osModules system;
};
in {config = evaluated.config.os;};
}