abstract away architectures
This commit is contained in:
parent
8ebf7b68df
commit
9414398f68
8 changed files with 80 additions and 33 deletions
|
|
@ -4,7 +4,7 @@
|
|||
in rec {
|
||||
# attrsToList
|
||||
attrsToList = attrs:
|
||||
mapAttrsToList (name: value: {inherit name value;}) attrs;
|
||||
mapAttrsToList (name: value: { inherit name value; }) attrs;
|
||||
|
||||
# mapFilterAttrs ::
|
||||
# (name -> value -> bool)
|
||||
|
|
|
|||
|
|
@ -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 ? "aarch64-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)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
7
lib/options.nix
Normal file
7
lib/options.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption;
|
||||
in {
|
||||
mkOpt = type: default: mkOption { inherit type default; };
|
||||
|
||||
mkOpt' = type: default: description: mkOption { inherit type default description; };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue