HASH 730fb7ca3bc4
DATE 2025-03-10
SUBJECT installer: move modules
FILES 3 CHANGED
HASH 730fb7ca3bc4
DATE 2025-03-10
SUBJECT installer: move modules
FILES 3 CHANGED
┌─ modules/nixos/image/installer.nix ────────────────────────────────────────┐
│ diff --git a/modules/nixos/image/installer.nix b/modules/nixos/image/installer.nix │
│ new file mode 100644 │
│ index 0000000..0ec6cfa │
│ --- /dev/null │
│ +++ b/modules/nixos/image/installer.nix │
│ @@ -0,0 +1,43 @@ │
│ +{ │
│ + inputs, │
│ + config, │
│ + lib, │
│ + pkgs, │
│ + self, │
│ + ... │
│ +}: let │
│ + inherit (inputs) nixpkgs; │
│ + inherit (config.ooknet.host) role admin; │
│ + inherit (lib) mkIf mkForce mkDefault cleanSource; │
│ +in { │
│ + imports = [ │
│ + # provides a set of packages/modules helpful for installing/repairing a syste │
│ m │
│ + "${nixpkgs}/nixos/modules/profiles/base.nix" │
│ + ]; │
│ + config = mkIf (role == "installer") { │
│ + users.users.root.initialHashedPassword = ""; │
│ + services.getty.autologinUser = admin.name; │
│ + boot = { │
│ + kernelPackages = mkDefault pkgs.linuxPackages_latest; │
│ + # zfs broken │
│ + supportedFilesystems = mkForce [ │
│ + "btrfs" │
│ + "vfat" │
│ + "f2fs" │
│ + "xfs" │
│ + "ntfs" │
│ + "cifs" │
│ + ]; │
│ + }; │
│ + isoImage = { │
│ + appendToMenuLabel = " ooknet installer"; │
│ + contents = [ │
│ + # copy contents of current flake to build initial installation │
│ + { │
│ + source = cleanSource self; │
│ + target = "/ooknet"; │
│ + } │
│ + ]; │
│ + }; │
│ + }; │
│ +} │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ...les/nixos/image/installer.nix ───┐
│ diff --git a/modules/nixos/image/installer.n │
│ ix b/modules/nixos/image/installer.nix │
│ new file mode 100644 │
│ index 0000000..0ec6cfa │
│ --- /dev/null │
│ +++ b/modules/nixos/image/installer.nix │
│ @@ -0,0 +1,43 @@ │
│ +{ │
│ + inputs, │
│ + config, │
│ + lib, │
│ + pkgs, │
│ + self, │
│ + ... │
│ +}: let │
│ + inherit (inputs) nixpkgs; │
│ + inherit (config.ooknet.host) role admin; │
│ + inherit (lib) mkIf mkForce mkDefault clea │
│ nSource; │
│ +in { │
│ + imports = [ │
│ + # provides a set of packages/modules he │
│ lpful for installing/repairing a system │
│ + "${nixpkgs}/nixos/modules/profiles/base │
│ .nix" │
│ + ]; │
│ + config = mkIf (role == "installer") { │
│ + users.users.root.initialHashedPassword │
│ = ""; │
│ + services.getty.autologinUser = admin.na │
│ me; │
│ + boot = { │
│ + kernelPackages = mkDefault pkgs.linux │
│ Packages_latest; │
│ + # zfs broken │
│ + supportedFilesystems = mkForce [ │
│ + "btrfs" │
│ + "vfat" │
│ + "f2fs" │
│ + "xfs" │
│ + "ntfs" │
│ + "cifs" │
│ + ]; │
│ + }; │
│ + isoImage = { │
│ + appendToMenuLabel = " ooknet installe │
│ r"; │
│ + contents = [ │
│ + # copy contents of current flake to │
│ build initial installation │
│ + { │
│ + source = cleanSource self; │
│ + target = "/ooknet"; │
│ + } │
│ + ]; │
│ + }; │
│ + }; │
│ +} │
└──────────────────────────────────────────────┘
┌─ modules/nixos/image/isoImage.nix ─────────────────────────────────────────┐
│ diff --git a/modules/nixos/image/isoImage.nix b/modules/nixos/image/isoImage.nix │
│ new file mode 100644 │
│ index 0000000..dd54269 │
│ --- /dev/null │
│ +++ b/modules/nixos/image/isoImage.nix │
│ @@ -0,0 +1,34 @@ │
│ +{ │
│ + inputs, │
│ + lib, │
│ + pkgs, │
│ + config, │
│ + ... │
│ +}: let │
│ + inherit (inputs) nixpkgs; │
│ + inherit (lib) mkIf; │
│ + inherit (config.ooknet.host) type; │
│ +in { │
│ + imports = [ │
│ + "${nixpkgs}/nixos/modules/installer/cd-dvd/iso-image.nix" │
│ + │
│ + # ensure we have we have an initial copy of the nixos channel │
│ + "${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix" │
│ + ]; │
│ + │
│ + config = mkIf (type == "iso") { │
│ + isoImage = { │
│ + makeEfiBootable = true; │
│ + makeUsbBootable = true; │
│ + edition = config.networking.hostName; │
│ + }; │
│ + │
│ + hardware = { │
│ + enableAllHardware = true; │
│ + enableRedistributableFirmware = true; │
│ + }; │
│ + │
│ + boot.loader.grub.memtest86.enable = true; │
│ + system.switch.enable = false; │
│ + }; │
│ +} │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ modules/nixos/image/isoImage.nix ───┐
│ diff --git a/modules/nixos/image/isoImage.ni │
│ x b/modules/nixos/image/isoImage.nix │
│ new file mode 100644 │
│ index 0000000..dd54269 │
│ --- /dev/null │
│ +++ b/modules/nixos/image/isoImage.nix │
│ @@ -0,0 +1,34 @@ │
│ +{ │
│ + inputs, │
│ + lib, │
│ + pkgs, │
│ + config, │
│ + ... │
│ +}: let │
│ + inherit (inputs) nixpkgs; │
│ + inherit (lib) mkIf; │
│ + inherit (config.ooknet.host) type; │
│ +in { │
│ + imports = [ │
│ + "${nixpkgs}/nixos/modules/installer/cd- │
│ dvd/iso-image.nix" │
│ + │
│ + # ensure we have we have an initial cop │
│ y of the nixos channel │
│ + "${nixpkgs}/nixos/modules/installer/cd- │
│ dvd/channel.nix" │
│ + ]; │
│ + │
│ + config = mkIf (type == "iso") { │
│ + isoImage = { │
│ + makeEfiBootable = true; │
│ + makeUsbBootable = true; │
│ + edition = config.networking.hostName; │
│ + }; │
│ + │
│ + hardware = { │
│ + enableAllHardware = true; │
│ + enableRedistributableFirmware = true; │
│ + }; │
│ + │
│ + boot.loader.grub.memtest86.enable = tru │
│ e; │
│ + system.switch.enable = false; │
│ + }; │
│ +} │
└──────────────────────────────────────────────┘
┌─ outputs/lib/builders.nix ─────────────────────────────────────────────────┐
│ diff --git a/outputs/lib/builders.nix b/outputs/lib/builders.nix │
│ index 4d90717..9d5c012 100644 │
│ --- a/outputs/lib/builders.nix │
│ +++ b/outputs/lib/builders.nix │
│ @@ -5,7 +5,7 @@ │
│ ... │
│ }: let │
│ inherit (inputs) nixpkgs; │
│ - inherit (lib) singleton recursiveUpdate mkDefault; │
│ + inherit (lib) assertMsg singleton recursiveUpdate mkDefault; │
│ inherit (builtins) concatLists; │
│ inherit (self) hozen ook; │
│ inherit (inputs.secrets.nixosModules) secrets; │
│ @@ -17,6 +17,8 @@ │
│ consoleModules = nixosModules + "/console"; │
│ workstationModules = nixosModules + "/workstation"; │
│ serverModules = nixosModules + "/server"; │
│ + imageModules = nixosModules + "/image"; │
│ + │
│ minimalCore = [ │
│ (baseModules + "/options.nix") │
│ (baseModules + "/admin.nix") │
│ @@ -24,10 +26,13 @@ │
│ ]; │
│ core = [baseModules hardwareModules consoleModules appearanceModules hm secrets │
│ ]; │
│ hostModules = "${self}/hosts"; │
│ - installModules = [ │
│ - "${nixpkgs}/nixos/modules/installer/cd-dvd/iso-image.nix" │
│ - "${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix" │
│ - "${nixpkgs}/nixos/modules/profiles/all-hardware.nix" │
│ + isoModules = [ │
│ + secrets │
│ + (imageModules + "/isoImage.nix") │
│ + (baseModules + "/networking.nix") │
│ + (baseModules + "/nix.nix") │
│ + (baseModules + "/tailscale.nix") │
│ + (baseModules + "/security/sudo.nix") │
│ ]; │
│ │
│ mkNixos = nixpkgs.lib.nixosSystem; │
│ @@ -98,7 +103,7 @@ │
│ additionalModules ? [], │
│ specialArgs ? {}, │
│ }: │
│ - assert lib.assertMsg (!(type == "vm" && profile == null)) │
│ + assert assertMsg (!(type == "vm" && profile == null)) │
│ "Profile must be specified for VM servers"; │
│ mkBaseSystem { │
│ inherit withSystem hostname system type specialArgs; │
│ @@ -121,29 +126,28 @@ │
│ }; │
│ │
│ mkImage = { │
│ + withSystem, │
│ profile ? null, │
│ - system, │
│ hostname, │
│ - installer ? false, │
│ + system, │
│ + type, │
│ + role, │
│ additionalModules ? [], │
│ - ... │
│ + specialArgs ? {}, │
│ }: │
│ - mkNixos { │
│ - specialArgs = {inherit inputs lib self;}; │
│ - modules = concatLists [ │
│ - (singleton { │
│ - networking.hostName = hostname; │
│ - nixpkgs = { │
│ - hostPlatform = mkDefault system; │
│ - flake.source = nixpkgs.outPath; │
│ - }; │
│ - }) │
│ + mkBaseSystem { │
│ + inherit withSystem role hostname system type specialArgs; │
│ + additionalModules = concatLists [ │
│ minimalCore │
│ additionalModules │
│ - [secrets] │
│ ( │
│ - if installer │
│ - then installModules │
│ + if type == "iso" │
│ + then isoModules │
│ + else [] │
│ + ) │
│ + ( │
│ + if role == "installer" │
│ + then [(imageModules + "/installer.nix")] │
│ else [] │
│ ) │
│ ( │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ outputs/lib/builders.nix ───────────┐
│ diff --git a/outputs/lib/builders.nix b/outp │
│ uts/lib/builders.nix │
│ index 4d90717..9d5c012 100644 │
│ --- a/outputs/lib/builders.nix │
│ +++ b/outputs/lib/builders.nix │
│ @@ -5,7 +5,7 @@ │
│ ... │
│ }: let │
│ inherit (inputs) nixpkgs; │
│ - inherit (lib) singleton recursiveUpdate m │
│ kDefault; │
│ + inherit (lib) assertMsg singleton recursi │
│ veUpdate mkDefault; │
│ inherit (builtins) concatLists; │
│ inherit (self) hozen ook; │
│ inherit (inputs.secrets.nixosModules) sec │
│ rets; │
│ @@ -17,6 +17,8 @@ │
│ consoleModules = nixosModules + "/console │
│ "; │
│ workstationModules = nixosModules + "/wor │
│ kstation"; │
│ serverModules = nixosModules + "/server"; │
│ + imageModules = nixosModules + "/image"; │
│ + │
│ minimalCore = [ │
│ (baseModules + "/options.nix") │
│ (baseModules + "/admin.nix") │
│ @@ -24,10 +26,13 @@ │
│ ]; │
│ core = [baseModules hardwareModules conso │
│ leModules appearanceModules hm secrets]; │
│ hostModules = "${self}/hosts"; │
│ - installModules = [ │
│ - "${nixpkgs}/nixos/modules/installer/cd- │
│ dvd/iso-image.nix" │
│ - "${nixpkgs}/nixos/modules/installer/cd- │
│ dvd/channel.nix" │
│ - "${nixpkgs}/nixos/modules/profiles/all- │
│ hardware.nix" │
│ + isoModules = [ │
│ + secrets │
│ + (imageModules + "/isoImage.nix") │
│ + (baseModules + "/networking.nix") │
│ + (baseModules + "/nix.nix") │
│ + (baseModules + "/tailscale.nix") │
│ + (baseModules + "/security/sudo.nix") │
│ ]; │
│ │
│ mkNixos = nixpkgs.lib.nixosSystem; │
│ @@ -98,7 +103,7 @@ │
│ additionalModules ? [], │
│ specialArgs ? {}, │
│ }: │
│ - assert lib.assertMsg (!(type == "vm" && │
│ profile == null)) │
│ + assert assertMsg (!(type == "vm" && pro │
│ file == null)) │
│ "Profile must be specified for VM serve │
│ rs"; │
│ mkBaseSystem { │
│ inherit withSystem hostname system │
│ type specialArgs; │
│ @@ -121,29 +126,28 @@ │
│ }; │
│ │
│ mkImage = { │
│ + withSystem, │
│ profile ? null, │
│ - system, │
│ hostname, │
│ - installer ? false, │
│ + system, │
│ + type, │
│ + role, │
│ additionalModules ? [], │
│ - ... │
│ + specialArgs ? {}, │
│ }: │
│ - mkNixos { │
│ - specialArgs = {inherit inputs lib sel │
│ f;}; │
│ - modules = concatLists [ │
│ - (singleton { │
│ - networking.hostName = hostname; │
│ - nixpkgs = { │
│ - hostPlatform = mkDefault system │
│ ; │
│ - flake.source = nixpkgs.outPath; │
│ - }; │
│ - }) │
│ + mkBaseSystem { │
│ + inherit withSystem role hostname syst │
│ em type specialArgs; │
│ + additionalModules = concatLists [ │
│ minimalCore │
│ additionalModules │
│ - [secrets] │
│ ( │
│ - if installer │
│ - then installModules │
│ + if type == "iso" │
│ + then isoModules │
│ + else [] │
│ + ) │
│ + ( │
│ + if role == "installer" │
│ + then [(imageModules + "/installer │
│ .nix")] │
│ else [] │
│ ) │
│ ( │
└──────────────────────────────────────────────┘
[ BACK TO LOG ]
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET