make system configurable

This commit is contained in:
Daylin Morgan 2025-02-20 10:00:45 -06:00
parent f74deacae0
commit 186fda577e
Signed by: daylin
GPG key ID: 950D13E9719334AD
3 changed files with 26 additions and 11 deletions

View file

@ -64,7 +64,7 @@ let
rec { rec {
default = oizys; default = oizys;
oizys = pkgs.callPackage ../pkgs/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; }) // (import ../pkgs { inherit pkgs lib inputs; })
); );

View file

@ -140,6 +140,12 @@ let
pathFromHostName = host: ../. + "/hosts/${host}"; pathFromHostName = host: ../. + "/hosts/${host}";
hostFiles = host: host |> pathFromHostName |> listFilesRecursive |> filter isNixFile; 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 # if the specified path doesn't exist returns an empty array
tryReadLinesNoComment = f: if pathExists f then (readLinesNoComment f) else [ ]; tryReadLinesNoComment = f: if pathExists f then (readLinesNoComment f) else [ ];
@ -208,6 +214,7 @@ in
listify listify
loadOverlays loadOverlays
hostFiles hostFiles
hostSystem
oizysSettings oizysSettings
tryPkgsFromFile tryPkgsFromFile
; ;

View file

@ -15,6 +15,7 @@ let
listify listify
readSettings readSettings
hostFiles hostFiles
hostSystem
; ;
flake = flakeFromSystem "x86_64-linux"; flake = flakeFromSystem "x86_64-linux";
nixosModules = names: names |> listify |> map (n: inputs.${n}.nixosModules.default); nixosModules = names: names |> listify |> map (n: inputs.${n}.nixosModules.default);
@ -30,22 +31,29 @@ let
; ;
}; };
mkIso = nixosSystem { mkIso =
modules = system:
[ nixosSystem {
{ nixpkgs.hostPlatform = "x86_64-linux"; } system = system;
] modules =
++ (nixosModules "lix-module") [
++ (selfModules "essentials|iso"); { nixpkgs.hostPlatform = system; }
specialArgs = commonSpecialArgs; ]
}; ++ (nixosModules "lix-module")
++ (selfModules "essentials|iso");
specialArgs = commonSpecialArgs;
};
mkSystem = mkSystem =
hostName: hostName:
let
system = hostSystem hostName;
in
nixosSystem { nixosSystem {
inherit system;
modules = modules =
[ [
{ nixpkgs.hostPlatform = "x86_64-linux"; } { nixpkgs.hostPlatform = system; }
] ]
++ (selfModules ''oizys'') ++ (selfModules ''oizys'')
++ (nixosModules ''lix-module|sops-nix'') ++ (nixosModules ''lix-module|sops-nix'')