From 1965d29c4363542435e94016e31314437fd02e1a Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 12 Nov 2026 14:17:23 -0500 Subject: [PATCH] Apply the same fixes to kubernetes. --- nix/configuration/flake.nix | 9 +- nix/configuration/formats/toplevel.nix | 1 - nix/kubernetes/flake.nix | 135 +++++++++++-------------- nix/kubernetes/formats/toplevel.nix | 1 - 4 files changed, 65 insertions(+), 81 deletions(-) delete mode 100644 nix/configuration/formats/toplevel.nix delete mode 100644 nix/kubernetes/formats/toplevel.nix diff --git a/nix/configuration/flake.nix b/nix/configuration/flake.nix index 7185393..19e1a35 100644 --- a/nix/configuration/flake.nix +++ b/nix/configuration/flake.nix @@ -45,7 +45,14 @@ ... }: let - forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; + forAllSystems = + func: + builtins.listToAttrs ( + map (system: { + name = system; + value = func system; + }) nixpkgs.lib.systems.flakeExposed + ); nodes = { odo = { system = "x86_64-linux"; diff --git a/nix/configuration/formats/toplevel.nix b/nix/configuration/formats/toplevel.nix deleted file mode 100644 index ffcd441..0000000 --- a/nix/configuration/formats/toplevel.nix +++ /dev/null @@ -1 +0,0 @@ -{ } diff --git a/nix/kubernetes/flake.nix b/nix/kubernetes/flake.nix index a38d663..2567ea5 100644 --- a/nix/kubernetes/flake.nix +++ b/nix/kubernetes/flake.nix @@ -71,64 +71,49 @@ system = "x86_64-linux"; }; }; - nixosConfigs = builtins.mapAttrs ( - hostname: nodeConfig: format: - nixpkgs.lib.nixosSystem { - specialArgs = { - inherit self; - - this_nixos_config = self.nixosConfigurations."${hostname}"; - - all_nixos_configs = self.nixosConfigurations; - }; + baseConfig = nixpkgs.lib.nixosSystem { + specialArgs = { + inherit self; + }; + modules = [ + impermanence.nixosModules.impermanence + lanzaboote.nixosModules.lanzaboote + disko.nixosModules.disko + ./configuration.nix + { + config = { + nixpkgs.overlays = [ + (final: prev: { + # stable = nixpkgs-stable.legacyPackages."${prev.stdenv.hostPlatform.system}"; + unoptimized = import nixpkgs { + system = prev.stdenv.hostPlatform.system; + hostPlatform.gcc.arch = "default"; + hostPlatform.gcc.tune = "default"; + }; + }) + ]; + }; + } + ]; + }; + toplevelConfigs = builtins.mapAttrs ( + hostname: nodeConfig: + baseConfig.extendModules { modules = [ - impermanence.nixosModules.impermanence - lanzaboote.nixosModules.lanzaboote - disko.nixosModules.disko - ./configuration.nix (./. + "/hosts/${hostname}") - (./. + "/formats/${format}.nix") { config = { nixpkgs.hostPlatform.system = nodeConfig.system; - nixpkgs.overlays = [ - (final: prev: { - # stable = nixpkgs-stable.legacyPackages."${prev.stdenv.hostPlatform.system}"; - unoptimized = import nixpkgs { - system = prev.stdenv.hostPlatform.system; - hostPlatform.gcc.arch = "default"; - hostPlatform.gcc.tune = "default"; - }; - }) - ]; }; } - ( - { - config, - lib, - pkgs, - ... - }: - let - nix-self-repl = pkgs.writeShellScriptBin "nix-self-repl" '' - source /etc/set-environment - nix repl --expr 'builtins.getFlake "${self}"' - ''; - # If we wanted the current version of a flake then we'd just launch - # nix repl - # and then run: - # :lf /path/to/flake - in - { - config = { - environment.systemPackages = lib.mkIf config.nix.enable [ nix-self-repl ]; - }; - } - ) ]; } ) nodes; + specialFormats = + nixosConfig: format: + nixosConfig.extendModules { + modules = [ (./. + "/formats/${format}.nix") ]; + }; installerConfig = hostname: nodeConfig: nixpkgs.lib.nixosSystem { @@ -137,46 +122,40 @@ }; modules = [ ./formats/installer.nix - ( - { - config, - lib, - pkgs, - ... - }: - let - nix-self-repl = pkgs.writeShellScriptBin "nix-self-repl" '' - source /etc/set-environment - nix repl --expr 'builtins.getFlake "${self}"' - ''; - # If we wanted the current version of a flake then we'd just launch - # nix repl - # and then run: - # :lf /path/to/flake - in - { - config = { - environment.systemPackages = lib.mkIf config.nix.enable [ nix-self-repl ]; - }; - } - ) ({ nixpkgs.hostPlatform.system = nodeConfig.system; }) ]; }; in { - nixosConfigurations = (builtins.mapAttrs (name: value: value "toplevel") nixosConfigs); + nixosConfigurations = toplevelConfigs; } // { packages = ( forAllSystems ( system: - (builtins.mapAttrs (hostname: nodeConfig: { - iso = (nixosConfigs."${hostname}" "iso").config.system.build.isoImage; - vm_iso = (nixosConfigs."${hostname}" "vm_iso").config.system.build.isoImage; - sd = (nixosConfigs."${hostname}" "sd").config.system.build.sdImage; - installer = (installerConfig hostname nodes."${hostname}").config.system.build.isoImage; - }) (nixpkgs.lib.attrsets.filterAttrs (hostname: nodeConfig: nodeConfig.system == system) nodes)) + let + machines = ( + builtins.mapAttrs (hostname: nodeConfig: { + iso = (specialFormats self.nixosConfigurations."${hostname}" "iso").config.system.build.isoImage; + vm_iso = + (specialFormats self.nixosConfigurations."${hostname}" "vm_iso").config.system.build.isoImage; + sd = (specialFormats self.nixosConfigurations."${hostname}" "sd").config.system.build.sdImage; + installer = (installerConfig hostname nodes."${hostname}").config.system.build.isoImage; + }) (nixpkgs.lib.attrsets.filterAttrs (hostname: nodeConfig: nodeConfig.system == system) nodes) + ); + in + ( + machines + // { + wip = nixpkgs.legacyPackages."${system}".symlinkJoin { + name = "wip"; + paths = [ + self.nixosConfigurations."controller0".config.system.build.toplevel + self.nixosConfigurations."worker0".config.system.build.toplevel + ]; + }; + } + ) ) ); }; diff --git a/nix/kubernetes/formats/toplevel.nix b/nix/kubernetes/formats/toplevel.nix deleted file mode 100644 index ffcd441..0000000 --- a/nix/kubernetes/formats/toplevel.nix +++ /dev/null @@ -1 +0,0 @@ -{ }