All checks were successful
CI / Format Check (push) Successful in 2s
CI / Flake Check (push) Successful in 1m34s
CI / Evaluate Key Configurations (nix-builder) (push) Successful in 8s
CI / Evaluate Key Configurations (nix-desktop1) (push) Successful in 6s
CI / Evaluate Key Configurations (nix-laptop1) (push) Successful in 6s
CI / Evaluate Artifacts (installer-iso-nix-laptop1) (push) Successful in 13s
CI / Evaluate Artifacts (lxc-nix-builder) (push) Successful in 7s
66 lines
1.5 KiB
Nix
66 lines
1.5 KiB
Nix
# This module defines a systemd service that automatically installs NixOS to the disk.
|
|
# It is intended to be used in an installation ISO.
|
|
# It expects `targetSystem` (the closure to install) and `diskoScript` (the partitioning script) to be passed as arguments.
|
|
{
|
|
pkgs,
|
|
hostName,
|
|
hostPlatform,
|
|
targetSystemBuild,
|
|
diskoScript,
|
|
...
|
|
}:
|
|
{
|
|
environment.systemPackages = [
|
|
pkgs.git
|
|
pkgs.bashInteractive
|
|
pkgs.curl
|
|
targetSystemBuild.toplevel
|
|
];
|
|
|
|
nixpkgs.hostPlatform = hostPlatform;
|
|
|
|
nix.settings.experimental-features = "nix-command flakes";
|
|
|
|
system.extraDependencies = with targetSystemBuild; [
|
|
toplevel
|
|
etc
|
|
bootStage2
|
|
];
|
|
|
|
isoImage.storeContents = [ targetSystemBuild.toplevel ];
|
|
|
|
systemd.services.auto-install = {
|
|
description = "Automatic NixOS install for ${hostName}";
|
|
after = [
|
|
"network-online.target"
|
|
"systemd-udev-settle.service"
|
|
];
|
|
wants = [ "network-online.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
StandardOutput = "journal+console";
|
|
StandardError = "journal+console";
|
|
Environment = "PATH=/run/current-system/sw/bin";
|
|
};
|
|
|
|
script = ''
|
|
echo "=== AUTO INSTALL START for ${hostName} ==="
|
|
|
|
echo ">>> Running disko script..."
|
|
${diskoScript}
|
|
|
|
echo ">>> Setting up NixOS..."
|
|
nixos-install \
|
|
--system ${targetSystemBuild.toplevel} \
|
|
--no-root-passwd \
|
|
--no-channel-copy \
|
|
--substituters ""
|
|
|
|
echo ">>> Done. Rebooting."
|
|
systemctl reboot
|
|
'';
|
|
};
|
|
}
|