nix-config/nix/generate-installer-package.nix

41 lines
1.1 KiB
Nix
Raw Normal View History

2024-07-26 22:12:48 +02:00
{ self, ... }:
nodeName: nodeAttrs:
let
2024-06-09 20:59:23 +02:00
#FIXME inherit nodeAttrs. system;
system = "x86_64-linux";
2023-08-30 16:38:30 +02:00
pkgs = self.pkgs.${system};
2024-07-26 22:12:48 +02:00
disko-script = pkgs.writeShellScriptBin "disko-script" "${nodeAttrs.config.system.build.diskoScript
}";
2023-08-30 16:38:30 +02:00
disko-mount = pkgs.writeShellScriptBin "disko-mount" "${nodeAttrs.config.system.build.mountScript}";
2024-07-26 22:12:48 +02:00
disko-format = pkgs.writeShellScriptBin "disko-format" "${nodeAttrs.config.system.build.formatScript
}";
2023-08-30 16:38:30 +02:00
install-system = pkgs.writeShellScriptBin "install-system" ''
set -euo pipefail
echo "Formatting disks..."
${disko-script}/bin/disko-script
echo "Installing system..."
nixos-install --no-root-password --system ${nodeAttrs.config.system.build.toplevel}
echo "Done!"
'';
installer-package = pkgs.symlinkJoin {
name = "installer-package-${nodeName}";
paths = [
disko-script
disko-mount
disko-format
install-system
];
};
2024-07-26 22:12:48 +02:00
in
{
2023-08-30 16:38:30 +02:00
# Everything required for the installer as a single package,
# so it can be used from an existing live system by copying the derivation.
packages.${system}.installer-package.${nodeName} = installer-package;
}