From 186fda577e3f2687ad2afae01cff2f6760df8307 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 20 Feb 2025 10:00:45 -0600 Subject: [PATCH] make system configurable --- lib/default.nix | 2 +- lib/extended.nix | 7 +++++++ lib/generators.nix | 28 ++++++++++++++++++---------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 38c9eb5..b13c40f 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -64,7 +64,7 @@ let rec { default = oizys; oizys = pkgs.callPackage ../pkgs/oizys { }; - iso = mkIso.config.system.build.isoImage; + iso-x86_64-linux = (mkIso "x86_64-linux").config.system.build.isoImage; } // (import ../pkgs { inherit pkgs lib inputs; }) ); diff --git a/lib/extended.nix b/lib/extended.nix index 647c709..01f2d99 100644 --- a/lib/extended.nix +++ b/lib/extended.nix @@ -140,6 +140,12 @@ let pathFromHostName = host: ../. + "/hosts/${host}"; hostFiles = host: host |> pathFromHostName |> listFilesRecursive |> filter isNixFile; + hostSystem = + host: + let + f = (host |> pathFromHostName) + "/settings/system"; + in + if pathExists f then readLinesNoComment f else "x86_64-linux"; # if the specified path doesn't exist returns an empty array tryReadLinesNoComment = f: if pathExists f then (readLinesNoComment f) else [ ]; @@ -208,6 +214,7 @@ in listify loadOverlays hostFiles + hostSystem oizysSettings tryPkgsFromFile ; diff --git a/lib/generators.nix b/lib/generators.nix index af5ff1a..9f18e65 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -15,6 +15,7 @@ let listify readSettings hostFiles + hostSystem ; flake = flakeFromSystem "x86_64-linux"; nixosModules = names: names |> listify |> map (n: inputs.${n}.nixosModules.default); @@ -30,22 +31,29 @@ let ; }; - mkIso = nixosSystem { - modules = - [ - { nixpkgs.hostPlatform = "x86_64-linux"; } - ] - ++ (nixosModules "lix-module") - ++ (selfModules "essentials|iso"); - specialArgs = commonSpecialArgs; - }; + mkIso = + system: + nixosSystem { + system = system; + modules = + [ + { nixpkgs.hostPlatform = system; } + ] + ++ (nixosModules "lix-module") + ++ (selfModules "essentials|iso"); + specialArgs = commonSpecialArgs; + }; mkSystem = hostName: + let + system = hostSystem hostName; + in nixosSystem { + inherit system; modules = [ - { nixpkgs.hostPlatform = "x86_64-linux"; } + { nixpkgs.hostPlatform = system; } ] ++ (selfModules ''oizys'') ++ (nixosModules ''lix-module|sops-nix'')