abstract away architectures

This commit is contained in:
Reid 2025-12-31 22:25:52 -08:00
parent 2dee155b68
commit 57eee399e3
Signed by: reidlab
GPG key ID: DAF5EAF6665839FD
8 changed files with 69 additions and 36 deletions

View file

@ -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)

View file

@ -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)
);
}

View file

@ -1,7 +1,7 @@
{lib, ...}: let
inherit (lib.options) mkOption;
in {
mkOpt = type: default: mkOption {inherit type default;};
mkOpt = type: default: mkOption { inherit type default; };
mkOpt' = type: default: description: mkOption {inherit type default description;};
mkOpt' = type: default: description: mkOption { inherit type default description; };
}