forked from SaumonNet/proxmox-nixos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiso.nix
64 lines (56 loc) · 1.79 KB
/
iso.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
installBuild:
{
config,
pkgs,
modulesPath,
...
}:
{
imports = [ "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" ];
boot.kernelModules = [ "kvm-intel" ];
environment.systemPackages = with pkgs; [ git ];
isoImage.compressImage = false;
isoImage.squashfsCompression = null;
isoImage.isoBaseName = "nixos-offline-installer";
isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.iso";
isoImage.makeEfiBootable = true;
isoImage.makeUsbBootable = true;
isoImage.volumeID = "NIXOS_ISO";
isoImage.storeContents = [ installBuild.toplevel ];
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
systemd.services.installer = {
description = "Unattended NixOS installer";
wantedBy = [ "multi-user.target" ];
after = [
"getty.target"
"nscd.service"
];
conflicts = [ "[email protected]" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
StandardInput = "tty-force";
StandardOutput = "inherit";
StandardError = "inherit";
TTYReset = "yes";
TTYVHangup = "yes";
};
path = [ "/run/current-system/sw" ];
environment = config.nix.envVars // {
inherit (config.environment.sessionVariables) NIX_PATH;
HOME = "/root";
};
script = ''
set -euxo pipefail
${installBuild.diskoScript}
# nixos-install will run "nix build --store /mnt ..." which won't be able
# to see what we have in the installer nix store, so copy everything
# needed over.
nix copy --no-check-sigs --to local?root=/mnt ${installBuild.toplevel}
${installBuild.nixos-install}/bin/nixos-install --no-channel-copy --no-root-passwd --system ${installBuild.toplevel}
reboot
'';
};
}