Working on modularizing stuff

This commit is contained in:
Chris Kruining 2024-07-21 00:07:19 +02:00
parent 835faf218d
commit 8349809fec
15 changed files with 256 additions and 41 deletions

30
lib/nixos.nix Normal file
View file

@ -0,0 +1,30 @@
{ 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 @ {sytem ? "x86_64-linux", ...}:
nixosSystem {
inherit system;
specialArgs = { inherit lib input system; };
modules = [
{
nixpkgs.pkgs = pkgs;
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);
}