feat: add initial modules

This commit is contained in:
2026-02-20 15:10:12 +01:00
parent 9d9d85f1ef
commit 4a2dac4118
15 changed files with 468 additions and 0 deletions

15
lib/autoDir.nix Normal file
View File

@@ -0,0 +1,15 @@
lib:
# takes dir as an argument and creates an attribute set by importing all .nix files in that directory
dir:
let
readDir = builtins.readDir dir;
files = lib.attrNames (
lib.filterAttrs (
name: type: type == "regular" && lib.hasSuffix ".nix" name && name != "default.nix"
) readDir
);
packages = builtins.map (name: lib.removeSuffix ".nix" name) files;
in
lib.genAttrs packages (name: import (dir + "/${name}.nix"))

11
lib/default.nix Normal file
View File

@@ -0,0 +1,11 @@
{ lib }:
let
mkHost = import ./mkHost.nix;
autoDir = import ./autoDir.nix lib;
mapDir = import ./mapDir.nix lib;
in
{
inherit mkHost autoDir mapDir;
}

11
lib/mapDir.nix Normal file
View File

@@ -0,0 +1,11 @@
lib:
let
autoDir = import ./autoDir.nix lib;
in
dir: args:
let
attrs = autoDir dir;
in
builtins.mapAttrs (_: f: f args) attrs

54
lib/mkHost.nix Normal file
View File

@@ -0,0 +1,54 @@
{
nixpkgs,
overlays,
inputs,
}:
name:
{
system,
users ? [ ],
}:
let
hostConfig = ../hosts/${name}/configuration.nix;
hostHWConfig = ../hosts/${name}/hardware-configuration.nix;
userHMConfigs = nixpkgs.lib.genAttrs users (
user: import ../users/${user}/home-manager.nix { inherit inputs; }
);
gib_in_bytes = 1073741824;
in
nixpkgs.lib.nixosSystem {
inherit system;
modules = [
{
nix.settings = {
download-buffer-size = 1 * gib_in_bytes;
experimental-features = [
"nix-command"
"flakes"
];
};
}
{ nixpkgs.overlays = overlays; }
{ nixpkgs.config.allowUnfree = true; }
hostConfig
hostHWConfig
inputs.home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users = userHMConfigs;
home-manager.extraSpecialArgs = { inherit inputs; };
}
];
specialArgs = { inherit inputs; };
}