{ pkgs, lib, config, modulesPath, manangerConfig, ... }: with lib; let auto-install = pkgs.writers.writeBash "auto-install" '' set -o errexit set -o nounset set -o pipefail set -x if [[ "$(cat /proc/cmdline)" =~ nixos\.install=([^ ]+) ]]; then INSTALL="''${BASH_REMATCH[1]}" else echo "No install derivation found" >&2 exit 1 fi ${pkgs.retry}/bin/retry \ --times 10 \ --delay 15 \ -- ${pkgs.nix}/bin/nix-store \ --realize \ --add-root /tmp/install \ "$INSTALL" exec /tmp/install ''; in { imports = [ "${modulesPath}/installer/netboot/netboot-minimal.nix" ]; config = { services.getty.autologinUser = lib.mkForce "root"; networking.hostName = "installer"; networking.hosts = mkForce manangerConfig.networking.hosts; users.users."root" = mkForce manangerConfig.users.users."root"; systemd.services."auto-install" = { description = "Automated NixOS installer"; wants = [ "network-online.target" ]; after = [ "network-online.target" ]; conflicts = [ "getty@tty1.service" ]; wantedBy = [ "multi-user.target" ]; path = [ pkgs.bash pkgs.nix ]; unitConfig = { AssertKernelCommandLine = "nixos.install"; FailureAction = "reboot-force"; }; serviceConfig = { Type = "oneshot"; ExecStart = auto-install; StandardInput = "tty-force"; TTYPath = "/dev/tty1"; TTYVTDisallocate = false; }; }; nix.settings = { substituters = [ "http://cache.${manangerConfig.networking.domain}" ]; trusted-public-keys = [ (fileContents manangerConfig.gather.parts."cache/key".path) ]; }; system.stateVersion = config.system.nixos.release; }; }