-
-
Notifications
You must be signed in to change notification settings - Fork 199
/
install-cli.nix
69 lines (64 loc) · 1.77 KB
/
install-cli.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
{ flake
, flakeAttr
, diskMappings
, extraSystemConfig ? "{}"
, writeEfiBootEntries ? false
, rootMountPoint ? "/mnt"
,
}:
let
originalSystem = (builtins.getFlake "${flake}").nixosConfigurations."${flakeAttr}";
lib = originalSystem.pkgs.lib;
deviceName =
name:
if diskMappings ? ${name} then
diskMappings.${name}
else
throw "No device passed for disk '${name}'. Pass `--disk ${name} /dev/name` via commandline";
modifiedDisks = builtins.mapAttrs
(
name: value:
let
dev = deviceName name;
in
value
// {
device = dev;
content = value.content // {
device = dev;
};
}
)
originalSystem.config.disko.devices.disk;
# filter all nixos module internal attributes
cleanedDisks = lib.filterAttrsRecursive (n: _: !lib.hasPrefix "_" n) modifiedDisks;
diskoSystem = originalSystem.extendModules {
modules = [
{
disko.rootMountPoint = rootMountPoint;
disko.devices.disk = lib.mkVMOverride cleanedDisks;
}
];
};
installSystem = originalSystem.extendModules {
modules = [
(
{ lib, ... }:
{
boot.loader.efi.canTouchEfiVariables = lib.mkVMOverride writeEfiBootEntries;
boot.loader.grub.devices = lib.mkVMOverride diskoSystem.config.boot.loader.grub.devices;
imports = [
({ _file = "disko-install --system-config"; } // (builtins.fromJSON extraSystemConfig))
];
}
)
];
};
in
{
installToplevel = installSystem.config.system.build.toplevel;
closureInfo = installSystem.pkgs.closureInfo {
rootPaths = [ installSystem.config.system.build.toplevel ];
};
inherit (diskoSystem.config.system.build) formatScript mountScript diskoScript;
}