abstract away architectures
This commit is contained in:
parent
2dee155b68
commit
57eee399e3
8 changed files with 69 additions and 36 deletions
|
|
@ -1,35 +1,42 @@
|
|||
{
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||
inherit (builtins) baseNameOf elem;
|
||||
inherit (lib.attrsets) filterAttrs;
|
||||
inherit (lib.modules) mkDefault;
|
||||
inherit (lib.strings) removeSuffix;
|
||||
inherit (self.modules) mapModules;
|
||||
in rec {
|
||||
mkHost = path: attrs @ {system ? "x86_64-linux", ...}:
|
||||
mkHost = path: {
|
||||
system,
|
||||
pkgsFor,
|
||||
...
|
||||
}:
|
||||
nixosSystem {
|
||||
inherit system;
|
||||
|
||||
specialArgs = {inherit lib inputs system;};
|
||||
specialArgs = { inherit lib inputs system; };
|
||||
|
||||
modules = [
|
||||
{
|
||||
nixpkgs.pkgs = pkgs;
|
||||
nixpkgs.pkgs = pkgsFor.${system};
|
||||
nixpkgs.hostPlatform = lib.mkDefault system;
|
||||
networking.hostName =
|
||||
mkDefault (removeSuffix ".nix" (baseNameOf path));
|
||||
}
|
||||
(filterAttrs (n: v: !elem n ["system"]) attrs)
|
||||
../. # /default.nix
|
||||
(import path)
|
||||
];
|
||||
};
|
||||
|
||||
mapHosts = dir: attrs @ {system ? system, ...}:
|
||||
mapModules dir (hostPath: mkHost hostPath attrs);
|
||||
mapHosts = dir: attrs:
|
||||
mapModules dir (hostPath:
|
||||
let
|
||||
metaPath = "${hostPath}/meta.nix";
|
||||
meta = import metaPath;
|
||||
in
|
||||
mkHost hostPath (attrs // meta)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue