From a90e736743a280ed5eaf8db899fed46ff207567b Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Sun, 19 Jul 2026 13:12:46 +1000 Subject: [PATCH] Simplify installer into shared common.nix + per-platform targets Replaces the single monolithic installer.nix (preserved as installer_old.nix for reference) with a shared common.nix carrying the install-script/user/SSH baseline, consumed by per-platform targets (installer.nix for netboot/ISO, new proxmox-lxc.nix for the Proxmox LXC-based flow). flake.nix drops the nixos-generators input in favor of building images directly from each nixosConfiguration's system.build.isoImage/tarball. Co-Authored-By: Claude Sonnet 5 --- common.nix | 127 +++++++++++++++++++++++++++++ flake.lock | 43 +--------- flake.nix | 141 +++++++++++++++++++++----------- installer.nix | 204 +++++++++------------------------------------- installer_old.nix | 171 ++++++++++++++++++++++++++++++++++++++ proxmox-lxc.nix | 32 ++++++++ 6 files changed, 464 insertions(+), 254 deletions(-) create mode 100644 common.nix create mode 100644 installer_old.nix create mode 100644 proxmox-lxc.nix diff --git a/common.nix b/common.nix new file mode 100644 index 0000000..32ff1b7 --- /dev/null +++ b/common.nix @@ -0,0 +1,127 @@ +{ pkgs, lib, ... }: + +{ + networking.useDHCP = lib.mkDefault true; + + time.timeZone = "Australia/Brisbane"; + + environment.systemPackages = with pkgs; [ + git + curl + jq + parted + e2fsprogs + btrfs-progs + util-linux + disko + ]; + + programs.git = { + enable = true; + + config = { + credential.helper = "store --file=/etc/git-credentials"; + }; + }; + + environment.etc."git-credentials".text = + "https://beatzaplenty:294be99829703536e02fdeed893137f1d8d96b76@gitea.lan.ddnsgeek.com"; + + + services.openssh.enable = true; + + services.openssh.settings = { + PermitRootLogin = "yes"; + PasswordAuthentication = true; + }; + + + users.users.root = { + hashedPassword = + "$6$Kwv9KAyvcurAViQF$H4.u3feqGE7lVoNgkFXhE3n2Pmo//9JYDTCz8ifrVHBxPjwa1xMby7tEZ8Bpt5MXs9Rkx6/YbZWxs5CpH0s/70"; + }; + + + users.users.nixos = { + isNormalUser = true; + + extraGroups = [ + "wheel" + ]; + + shell = pkgs.bashInteractive; + + hashedPassword = + "$6$Kwv9KAyvcurAViQF$H4.u3feqGE7lVoNgkFXhE3n2Pmo//9JYDTCz8ifrVHBxPjwa1xMby7tEZ8Bpt5MXs9Rkx6/YbZWxs5CpH0s/70"; + + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCq/Q5LvIXlZwO2kdeAN5nLGZ59nZB7JHYMEszHxmNtGMzv1lM31jiPNsr0z2EKVZhE7OOfa2IF9rhWYD7JUA9G0yzdZ4WTXFNGVVOJoOVH6vAF3XCxoVilOEwTc7h2Wiy+rzd0B28/3spffzQQWJhY6GRQVa8j+6xAGF60Fcvl1vLosYT9Bn2ZbK4TCWOwAn2jqXIieGpZdn/UNZbGOeKRiCvhktDfMAzuQzN/9jMu/oF4pkPn2X1UrsQdNlvp0Ci8md612MozIpncQJyAF1ADhunr3sMx0isUXiqD29R5DS4TftpekqLNLak+zcxFa8N7DcRNp3DcKfJvyTkwQrR4r+b7lFLYOLHLagSso9CzeW/paAS2q9I5SBm/2DtE1diLLg2jZikYcstsu/G5RgvbzbKqjiaMwTdXC3AMvDxQrs7U5pDRZFzoofG3cpODbTm+uy3m0kP70z0M1K45UbDG0p+itnTu9x40JbQEgefbx38AItNvAIx1A8HO4I1VX28= wayne@stream" + ]; + }; + + + system.stateVersion = "26.05"; + + # Write auto-install script to /root + environment.etc."auto-install.sh".text = '' + #!/run/current-system/sw/bin/bash + set -eux + + set -euo pipefail + +export FLAKE_BASE_URL="git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git" + +echo "Fetching available NixOS hosts from flake..." +mapfile -t options < <( + nix eval --json --no-use-registries --no-accept-flake-config --extra-experimental-features "flakes nix-command" \ + "''${FLAKE_BASE_URL}#nixosConfigurations" \ + --apply builtins.attrNames \ + | jq -r '.[]' +) + +if [[ ''${#options[@]} -eq 0 ]]; then + echo "ERROR: No NixOS hosts found in ''${FLAKE_BASE_URL}#nixosConfigurations" >&2 + exit 1 +fi + +echo "Choose the flake profile to install:" +select choice in "''${options[@]}"; do + if [[ -n "$choice" ]]; then + echo "You selected: $choice" + break + else + echo "Invalid selection. Try again." + fi +done + +echo "Starting install with flake: ''${FLAKE_BASE_URL}#''${choice}" + +# Optional: confirm before proceeding +read -rp "Proceed with installation? (y/N): " confirm +if [[ ! "$confirm" =~ ^[Yy]$ ]]; then + echo "Aborted." + exit 1 +fi + +if nix eval --refresh --json --extra-experimental-features "flakes nix-command" "''${FLAKE_BASE_URL}#nixosConfigurations.''${choice}.config.disko.devices.disk.main.device" >/dev/null 2>&1; then + disko --mode destroy,format,mount \ + --flake "''${FLAKE_BASE_URL}#''${choice}" --yes` +else + echo "Selected host has no Disko configuration." +fi + +mkdir -p /mnt/install-tmp +export TMPDIR=/mnt/install-tmp + +nixos-install \ + --flake "''${FLAKE_BASE_URL}#''${choice}" \ + --no-root-password + + + rm -rf /mnt/install-tmp + sleep 10 + reboot + ''; + + environment.etc."auto-install.sh".mode = "0755"; +} \ No newline at end of file diff --git a/flake.lock b/flake.lock index 61d9dab..8434154 100644 --- a/flake.lock +++ b/flake.lock @@ -127,21 +127,6 @@ "type": "github" } }, - "nixlib": { - "locked": { - "lastModified": 1736643958, - "narHash": "sha256-tmpqTSWVRJVhpvfSN9KXBvKEXplrwKnSZNAoNPf/S/s=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "1418bc28a52126761c02dd3d89b2d8ca0f521181", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, "nixos-conf-editor": { "inputs": { "flake-compat": "flake-compat", @@ -162,27 +147,6 @@ "type": "github" } }, - "nixos-generators": { - "inputs": { - "nixlib": "nixlib", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1769813415, - "narHash": "sha256-nnVmNNKBi1YiBNPhKclNYDORoHkuKipoz7EtVnXO50A=", - "owner": "nix-community", - "repo": "nixos-generators", - "rev": "8946737ff703382fda7623b9fab071d037e897d5", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixos-generators", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1771008912, @@ -201,11 +165,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1784011430, - "narHash": "sha256-lDebytrYdd47IBLwvNOD+6AGeoqZ78CIKlp70hzW280=", + "lastModified": 1784280462, + "narHash": "sha256-DtoqIqM7VkR6NxAkcLpMwmi02USwWb3JdmNGLyhthc0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8eeec934ae0dbeca3d7868c059568a65c08b2fc3", + "rev": "293d6abedf0478e681a4dfcfcb35b30fc796a32f", "type": "github" }, "original": { @@ -221,7 +185,6 @@ "flake-utils": "flake-utils", "home-manager": "home-manager", "nixos-conf-editor": "nixos-conf-editor", - "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs_2" } }, diff --git a/flake.nix b/flake.nix index 05297c9..0eaa375 100644 --- a/flake.nix +++ b/flake.nix @@ -1,68 +1,113 @@ -# flake.nix { description = "Auto-install NixOS ISO"; inputs = { -# nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + nixos-conf-editor.url = "github:snowfallorg/nixos-conf-editor"; + flake-utils.url = "github:numtide/flake-utils"; - nixos-generators = { - url = "github:nix-community/nixos-generators"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - # home-manager.url = "github:nix-community/home-manager"; - # home-manager.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { url = "github:nix-community/home-manager/release-26.05"; inputs.nixpkgs.follows = "nixpkgs"; }; + disko = { url = "github:nix-community/disko"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { self, nixpkgs, flake-utils, nixos-generators, home-manager, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - iso = nixos-generators.nixosGenerate { - inherit system; - format = "install-iso"; - modules = [ - ./installer.nix + outputs = { self, nixpkgs, flake-utils, home-manager, ... }: + + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + + netbootSystem = nixpkgs.lib.nixosSystem { + inherit system; + + modules = [ + ./installer.nix + + ({ modulesPath, ... }: { + imports = [ + (modulesPath + "/installer/netboot/netboot-minimal.nix") + ]; + }) + ]; + }; + + + in + { + + # + # Complete NixOS systems + # + # These can be used with: + # + # nixos-rebuild switch --flake .#name + # + + nixosConfigurations = { + + installer = + nixpkgs.lib.nixosSystem { + inherit system; + + modules = [ + ./installer.nix + ]; + }; + + + proxmox-lxc = + nixpkgs.lib.nixosSystem { + inherit system; + + modules = [ + ./proxmox-lxc.nix + ]; + }; + + }; + + + # + # Buildable artifacts + # + # These are built with: + # + # nix build .#name + # + + packages.${system} = { + + netboot-ipxe = + netbootSystem.config.system.build.netbootIpxeScript; + + + netboot-initrd = + netbootSystem.config.system.build.netbootRamdisk; + + + netboot-kernel = + netbootSystem.config.system.build.kernel; + images = + pkgs.linkFarm "images" [ + { + name = "installer-iso"; + path = self.nixosConfigurations.installer.config.system.build.isoImage; + } + { + name = "proxmox-lxc"; + path = self.nixosConfigurations.proxmox-lxc.config.system.build.tarball; + } ]; - }; + }; -netbootSystem = nixpkgs.lib.nixosSystem { - inherit system; - - modules = [ - ./installer.nix - - ({ modulesPath, ... }: { - imports = [ - (modulesPath + "/installer/netboot/netboot-minimal.nix") - ]; - }) - ]; -}; - in { - packages.default = iso; - -# packages.netboot = netbootSystem.config.system.build.netboot; - -#packages.netboot-debug = -# pkgs.writeText "attrs.json" -# (builtins.toJSON -# (builtins.attrNames netbootSystem.config.system.build)); - -packages.netboot-ipxe = netbootSystem.config.system.build.netbootIpxeScript; -packages.netboot-initrd = netbootSystem.config.system.build.netbootRamdisk; -packages.netboot-kernel = netbootSystem.config.system.build.kernel; - - - }); -} + }; +} \ No newline at end of file diff --git a/installer.nix b/installer.nix index 38a5d61..0283a22 100644 --- a/installer.nix +++ b/installer.nix @@ -1,187 +1,59 @@ -{ lib, pkgs, modulesPath, config, ... }: +{ pkgs, modulesPath, ... }: { -# imports = [ -# "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" -# ]; -imports = [ - "${modulesPath}/installer/netboot/netboot-minimal.nix" -]; - - networking.useDHCP = lib.mkDefault true; + imports = [ + "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" + ]; + + +# networking.useDHCP = true; + time.timeZone = "Australia/Brisbane"; + services.openssh.enable = true; - services.openssh.settings.PermitRootLogin = "yes"; + + services.openssh.settings = { + PermitRootLogin = "yes"; + }; + environment.systemPackages = with pkgs; [ - git curl jq parted e2fsprogs btrfs-progs util-linux disko + git + curl + jq + parted + e2fsprogs + btrfs-progs + util-linux + disko ]; -# environment.etc."flake-url".text = "git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git?ref=main#nixos"; -# Enable LISH -boot.kernelParams = [ "console=ttyS0,19200n8" ]; -boot.loader.grub.extraConfig = '' - serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1; - terminal_input serial; - terminal_output serial; -''; - -environment.etc."git-credentials".text = - "https://beatzaplenty:2b7e178eeee4af437fc721295d59e9e19366fd02@gitea.lan.ddnsgeek.com"; -#programs.git.enable = true; -#programs.git.extraConfig."credential.helper" = "store --file=/etc/git-credentials"; - programs.git = { - enable = true; - package = pkgs.git; - config = { - credential.helper = "store --file=/etc/git-credentials"; - }; - }; - - # Write auto-install script to /root - environment.etc."auto-install.sh".text = '' - #!/run/current-system/sw/bin/bash - set -eux - - set -euo pipefail - -export FLAKE_BASE_URL="git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git" - -echo "Fetching available NixOS hosts from flake..." -mapfile -t options < <( - nix eval --json --no-use-registries --no-accept-flake-config --extra-experimental-features "flakes nix-command" \ - "''${FLAKE_BASE_URL}#nixosConfigurations" \ - --apply builtins.attrNames \ - | jq -r '.[]' -) - -if [[ ''${#options[@]} -eq 0 ]]; then - echo "ERROR: No NixOS hosts found in ''${FLAKE_BASE_URL}#nixosConfigurations" >&2 - exit 1 -fi - -echo "Choose the flake profile to install:" -select choice in "''${options[@]}"; do - if [[ -n "$choice" ]]; then - echo "You selected: $choice" - break - else - echo "Invalid selection. Try again." - fi -done - -echo "Starting install with flake: ''${FLAKE_BASE_URL}#''${choice}" - -# Optional: confirm before proceeding -read -rp "Proceed with installation? (y/N): " confirm -if [[ ! "$confirm" =~ ^[Yy]$ ]]; then - echo "Aborted." - exit 1 -fi - - - # parted -s /dev/sda -- mklabel msdos - # parted -s /dev/sda -- mkpart primary 1MB -8GB - # parted -s /dev/sda -- set 1 boot on - # parted -s /dev/sda -- mkpart primary linux-swap -8GB 100% - # mkfs.ext4 -L nixos /dev/sda1 - # mkswap -L swap /dev/sda2 - # swapon /dev/sda2 - # sleep 10 - # mount /dev/disk/by-label/nixos /mnt - # mkdir -p /mnt/install-tmp - # export TMPDIR=/mnt/install-tmp - # nixos-install --flake "''${FLAKE_BASE_URL}#''${choice}" --no-root-password --no-write-lock-file - -if nix eval --refresh --json --extra-experimental-features "flakes nix-command" "''${FLAKE_BASE_URL}#nixosConfigurations.''${choice}.config.disko.devices.disk.main.device" >/dev/null 2>&1; then - lsblk - disko --mode destroy,format,mount \ - --flake "''${FLAKE_BASE_URL}#''${choice}" -else - echo "Selected host has no Disko configuration." - mount /dev/sda /mnt -fi - -mkdir -p /mnt/install-tmp -export TMPDIR=/mnt/install-tmp - -nixos-install \ - --flake "''${FLAKE_BASE_URL}#''${choice}" \ - --no-root-password +# environment.etc."auto-install.sh" = { +# source = ./auto-install.sh; +# mode = "0755"; +# }; - rm -rf /mnt/install-tmp - sleep 10 - reboot - ''; -# environment.etc."auto-install.sh".mode = "0755"; +# users.users.root = { +# initialPassword = "nixos"; +# }; - # Trigger the script from nixos user's shell - # environment.etc."nixos/.bashrc".text = '' - # # Run installer only once - # if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then - # sudo /etc/auto-install.sh - # touch ~/.auto_install_ran - # fi - # ''; - # environment.etc."nixos/.bashrc".mode = "0755"; - #Set root password -users.users.root = { - hashedPassword = "$6$Kwv9KAyvcurAViQF$H4.u3feqGE7lVoNgkFXhE3n2Pmo//9JYDTCz8ifrVHBxPjwa1xMby7tEZ8Bpt5MXs9Rkx6/YbZWxs5CpH0s/70"; -}; - # Define a user account. Don't forget to set a password with ‘passwd’. users.users.nixos = { isNormalUser = true; - extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. - packages = with pkgs; [ - tree + extraGroups = [ + "wheel" ]; - hashedPassword = "$6$Kwv9KAyvcurAViQF$H4.u3feqGE7lVoNgkFXhE3n2Pmo//9JYDTCz8ifrVHBxPjwa1xMby7tEZ8Bpt5MXs9Rkx6/YbZWxs5CpH0s/70"; - openssh.authorizedKeys.keys = [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCq/Q5LvIXlZwO2kdeAN5nLGZ59nZB7JHYMEszHxmNtGMzv1lM31jiPNsr0z2EKVZhE7OOfa2IF9rhWYD7JUA9G0yzdZ4WTXFNGVVOJoOVH6vAF3XCxoVilOEwTc7h2Wiy+rzd0B28/3spffzQQWJhY6GRQVa8j+6xAGF60Fcvl1vLosYT9Bn2ZbK4TCWOwAn2jqXIieGpZdn/UNZbGOeKRiCvhktDfMAzuQzN/9jMu/oF4pkPn2X1UrsQdNlvp0Ci8md612MozIpncQJyAF1ADhunr3sMx0isUXiqD29R5DS4TftpekqLNLak+zcxFa8N7DcRNp3DcKfJvyTkwQrR4r+b7lFLYOLHLagSso9CzeW/paAS2q9I5SBm/2DtE1diLLg2jZikYcstsu/G5RgvbzbKqjiaMwTdXC3AMvDxQrs7U5pDRZFzoofG3cpODbTm+uy3m0kP70z0M1K45UbDG0p+itnTu9x40JbQEgefbx38AItNvAIx1A8HO4I1VX28= wayne@stream" - ]; - home = "/home/nixos"; - createHome = true; - shell = pkgs.bashInteractive; - - }; -# environment.etc."auto-install.sh".source = ./auto-install.sh; - environment.etc."auto-install.sh".mode = "0755"; - - # environment.etc."home/nixos/.bashrc".text = '' - # if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then - # sudo /etc/auto-install.sh - # touch ~/.auto_install_ran - # fi - # ''; - # environment.etc."home/nixos/.bashrc".mode = "0644"; - - # Write .bashrc into the user's home directory - # environment.etc."bashrc-nixos".source = pkgs.writeText "bashrc-nixos" '' - # if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then - # sudo /etc/auto-install.sh - # touch ~/.auto_install_ran - # fi - # ''; - - system.activationScripts.installBashProfile = { - text = '' - mkdir -p /home/nixos - cp -f ${config.environment.etc."bash_profile-nixos".source} /home/nixos/.bash_profile - chown nixos:nixos /home/nixos/.bash_profile - chmod 644 /home/nixos/.bash_profile - ''; }; - environment.etc."bash_profile-nixos".source = pkgs.writeText "bash_profile-nixos" '' - if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then - sudo /etc/auto-install.sh - touch ~/.auto_install_ran - fi - ''; + # Only for ISO/Linode serial environments if required + # NOT for LXC + # + # boot.kernelParams = [ + # "console=ttyS0,19200n8" + # ]; - } +} \ No newline at end of file diff --git a/installer_old.nix b/installer_old.nix new file mode 100644 index 0000000..f39b703 --- /dev/null +++ b/installer_old.nix @@ -0,0 +1,171 @@ +{ lib, pkgs, modulesPath, config, ... }: + +{ +# imports = [ +# "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" +# ]; +imports = [ + "${modulesPath}/installer/netboot/netboot-minimal.nix" +]; + + networking.useDHCP = lib.mkDefault true; + time.timeZone = "Australia/Brisbane"; + + services.openssh.enable = true; + services.openssh.settings.PermitRootLogin = "yes"; + + environment.systemPackages = with pkgs; [ + git curl jq parted e2fsprogs btrfs-progs util-linux disko + ]; + +# environment.etc."flake-url".text = "git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git?ref=main#nixos"; + +# Enable LISH +boot.kernelParams = [ "console=ttyS0,19200n8" ]; +boot.loader.grub.extraConfig = '' + serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1; + terminal_input serial; + terminal_output serial; +''; + +environment.etc."git-credentials".text = + "https://beatzaplenty:2b7e178eeee4af437fc721295d59e9e19366fd02@gitea.lan.ddnsgeek.com"; +#programs.git.enable = true; +#programs.git.extraConfig."credential.helper" = "store --file=/etc/git-credentials"; + programs.git = { + enable = true; + package = pkgs.git; + config = { + credential.helper = "store --file=/etc/git-credentials"; + }; + }; + + # Write auto-install script to /root + environment.etc."auto-install.sh".text = '' + #!/run/current-system/sw/bin/bash + set -eux + + set -euo pipefail + +export FLAKE_BASE_URL="git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git" + +echo "Fetching available NixOS hosts from flake..." +mapfile -t options < <( + nix eval --json --no-use-registries --no-accept-flake-config --extra-experimental-features "flakes nix-command" \ + "''${FLAKE_BASE_URL}#nixosConfigurations" \ + --apply builtins.attrNames \ + | jq -r '.[]' +) + +if [[ ''${#options[@]} -eq 0 ]]; then + echo "ERROR: No NixOS hosts found in ''${FLAKE_BASE_URL}#nixosConfigurations" >&2 + exit 1 +fi + +echo "Choose the flake profile to install:" +select choice in "''${options[@]}"; do + if [[ -n "$choice" ]]; then + echo "You selected: $choice" + break + else + echo "Invalid selection. Try again." + fi +done + +echo "Starting install with flake: ''${FLAKE_BASE_URL}#''${choice}" + +# Optional: confirm before proceeding +read -rp "Proceed with installation? (y/N): " confirm +if [[ ! "$confirm" =~ ^[Yy]$ ]]; then + echo "Aborted." + exit 1 +fi + +if nix eval --refresh --json --extra-experimental-features "flakes nix-command" "''${FLAKE_BASE_URL}#nixosConfigurations.''${choice}.config.disko.devices.disk.main.device" >/dev/null 2>&1; then + disko --mode destroy,format,mount \ + --flake "''${FLAKE_BASE_URL}#''${choice}" --yes` +else + echo "Selected host has no Disko configuration." +fi + +mkdir -p /mnt/install-tmp +export TMPDIR=/mnt/install-tmp + +nixos-install \ + --flake "''${FLAKE_BASE_URL}#''${choice}" \ + --no-root-password + + + rm -rf /mnt/install-tmp + sleep 10 + reboot + ''; +# environment.etc."auto-install.sh".mode = "0755"; + + # Trigger the script from nixos user's shell + # environment.etc."nixos/.bashrc".text = '' + # # Run installer only once + # if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then + # sudo /etc/auto-install.sh + # touch ~/.auto_install_ran + # fi + # ''; + # environment.etc."nixos/.bashrc".mode = "0755"; + #Set root password +users.users.root = { + hashedPassword = "$6$Kwv9KAyvcurAViQF$H4.u3feqGE7lVoNgkFXhE3n2Pmo//9JYDTCz8ifrVHBxPjwa1xMby7tEZ8Bpt5MXs9Rkx6/YbZWxs5CpH0s/70"; +}; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.nixos = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + packages = with pkgs; [ + tree + ]; + hashedPassword = "$6$Kwv9KAyvcurAViQF$H4.u3feqGE7lVoNgkFXhE3n2Pmo//9JYDTCz8ifrVHBxPjwa1xMby7tEZ8Bpt5MXs9Rkx6/YbZWxs5CpH0s/70"; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCq/Q5LvIXlZwO2kdeAN5nLGZ59nZB7JHYMEszHxmNtGMzv1lM31jiPNsr0z2EKVZhE7OOfa2IF9rhWYD7JUA9G0yzdZ4WTXFNGVVOJoOVH6vAF3XCxoVilOEwTc7h2Wiy+rzd0B28/3spffzQQWJhY6GRQVa8j+6xAGF60Fcvl1vLosYT9Bn2ZbK4TCWOwAn2jqXIieGpZdn/UNZbGOeKRiCvhktDfMAzuQzN/9jMu/oF4pkPn2X1UrsQdNlvp0Ci8md612MozIpncQJyAF1ADhunr3sMx0isUXiqD29R5DS4TftpekqLNLak+zcxFa8N7DcRNp3DcKfJvyTkwQrR4r+b7lFLYOLHLagSso9CzeW/paAS2q9I5SBm/2DtE1diLLg2jZikYcstsu/G5RgvbzbKqjiaMwTdXC3AMvDxQrs7U5pDRZFzoofG3cpODbTm+uy3m0kP70z0M1K45UbDG0p+itnTu9x40JbQEgefbx38AItNvAIx1A8HO4I1VX28= wayne@stream" + ]; + home = "/home/nixos"; + createHome = true; + shell = pkgs.bashInteractive; + + }; +# environment.etc."auto-install.sh".source = ./auto-install.sh; + environment.etc."auto-install.sh".mode = "0755"; + + # environment.etc."home/nixos/.bashrc".text = '' + # if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then + # sudo /etc/auto-install.sh + # touch ~/.auto_install_ran + # fi + # ''; + # environment.etc."home/nixos/.bashrc".mode = "0644"; + + # Write .bashrc into the user's home directory + # environment.etc."bashrc-nixos".source = pkgs.writeText "bashrc-nixos" '' + # if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then + # sudo /etc/auto-install.sh + # touch ~/.auto_install_ran + # fi + # ''; + + system.activationScripts.installBashProfile = { + text = '' + mkdir -p /home/nixos + cp -f ${config.environment.etc."bash_profile-nixos".source} /home/nixos/.bash_profile + chown nixos:nixos /home/nixos/.bash_profile + chmod 644 /home/nixos/.bash_profile + ''; + }; + + + environment.etc."bash_profile-nixos".source = pkgs.writeText "bash_profile-nixos" '' + if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then + sudo /etc/auto-install.sh + touch ~/.auto_install_ran + fi + ''; + + } diff --git a/proxmox-lxc.nix b/proxmox-lxc.nix new file mode 100644 index 0000000..0e665dd --- /dev/null +++ b/proxmox-lxc.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: + +{ + imports = [ + ./common.nix + ]; + + + # LXC has no bootloader + boot.loader.grub.enable = false; + boot.loader.systemd-boot.enable = false; + + + # Ensure Proxmox console works +# services.getty.enable = true; + + +# environment.etc."auto-install.sh" = { +# source = ./auto-install.sh; +# mode = "0755"; +# }; + + + # Run installer when logging in + environment.etc."bash_profile-nixos".text = '' + if [ -n "$PS1" ] && [ ! -e ~/.auto_install_ran ]; then + sudo /etc/auto-install.sh + touch ~/.auto_install_ran + fi + ''; +# networking.useDHCP = true; +} \ No newline at end of file