Add more custom libs

This commit is contained in:
SebastianStork 2025-10-13 14:12:18 +02:00
parent f084e91ec0
commit 3acd35c7b2
5 changed files with 22 additions and 27 deletions

View file

@ -1,8 +1,4 @@
{ { inputs, self, ... }:
inputs,
self,
...
}:
let let
lib = inputs.nixpkgs.lib.extend (_: _: { custom = import "${self}/lib" inputs.nixpkgs.lib; }); lib = inputs.nixpkgs.lib.extend (_: _: { custom = import "${self}/lib" inputs.nixpkgs.lib; });
@ -29,18 +25,10 @@ let
in in
{ {
flake = { flake = {
nixosConfigurations = nixosConfigurations = "${self}/hosts" |> lib.custom.listDirectories |> lib.custom.genAttrs mkHost;
"${self}/hosts"
|> builtins.readDir
|> lib.filterAttrs (_: type: type == "directory")
|> lib.mapAttrs (name: _: mkHost name);
deploy.nodes = deploy.nodes = "${self}/hosts" |> lib.custom.listDirectories |> lib.custom.genAttrs mkDeployNode;
"${self}/hosts"
|> builtins.readDir
|> lib.filterAttrs (_: type: type == "directory")
|> lib.mapAttrs (name: _: mkDeployNode name);
checks = lib.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib; checks = inputs.deploy-rs.lib |> lib.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy);
}; };
} }

View file

@ -1,11 +1,10 @@
{ self, lib, ... }: { self, inputs, ... }:
let let
listNixFilesRecursive = lib = inputs.nixpkgs.lib.extend (_: _: { custom = import "${self}/lib" inputs.nixpkgs.lib; });
dir: dir |> lib.filesystem.listFilesRecursive |> lib.filter (lib.hasSuffix ".nix");
in in
{ {
flake = { flake = {
nixosModules.default.imports = listNixFilesRecursive "${self}/modules/system"; nixosModules.default.imports = lib.custom.listNixFilesRecursive "${self}/modules/system";
homeManagerModules.default.imports = listNixFilesRecursive "${self}/modules/home"; homeManagerModules.default.imports = lib.custom.listNixFilesRecursive "${self}/modules/home";
}; };
} }

View file

@ -4,4 +4,12 @@ lib: {
subdomainOf = domain: domain |> lib.splitString "." |> lib.head; subdomainOf = domain: domain |> lib.splitString "." |> lib.head;
rootDomainOf = domain: domain |> lib.splitString "." |> lib.tail |> lib.concatStringsSep "."; rootDomainOf = domain: domain |> lib.splitString "." |> lib.tail |> lib.concatStringsSep ".";
listNixFilesRecursive =
dir: dir |> lib.filesystem.listFilesRecursive |> lib.filter (lib.hasSuffix ".nix");
listDirectories =
path: path |> builtins.readDir |> lib.filterAttrs (_: type: type == "directory") |> lib.attrNames;
genAttrs = f: names: lib.genAttrs names f;
} }

View file

@ -107,7 +107,8 @@ in
let let
genFolders = genFolders =
folders: folders:
lib.genAttrs folders (name: { folders
|> lib.custom.genAttrs (name: {
path = "${dataDir}/${name}"; path = "${dataDir}/${name}";
ignorePerms = false; ignorePerms = false;
devices = config.services.syncthing.settings.devices |> lib.attrNames; devices = config.services.syncthing.settings.devices |> lib.attrNames;

View file

@ -29,11 +29,10 @@ in
sops.secrets = sops.secrets =
cfg.networks cfg.networks
|> lib.map (name: { |> lib.map (name: "iwd/${name}")
name = "iwd/${name}"; |> lib.custom.genAttrs (_: {
value.restartUnits = [ "iwd.service" ]; restartUnits = [ "iwd.service" ];
}) });
|> lib.listToAttrs;
systemd.services.iwd.preStart = '' systemd.services.iwd.preStart = ''
rm --force /var/lib/iwd/*.{psk,8021x} rm --force /var/lib/iwd/*.{psk,8021x}