Implement global custom libs as a flake output

This commit is contained in:
SebastianStork 2025-10-17 10:57:32 +02:00
parent f276848b18
commit 671a13239a
Signed by: SebastianStork
SSH key fingerprint: SHA256:iEM011ogNMG1q8+U500adGu/9rpPuZ2KnFtbdLeqTiI
10 changed files with 40 additions and 31 deletions

View file

@ -1,11 +1,16 @@
{ inputs, self, ... }:
{
inputs,
self,
lib,
...
}:
let
lib = inputs.nixpkgs.lib.extend (_: _: { custom = import "${self}/lib" inputs.nixpkgs.lib; });
inherit (self) lib';
mkHost =
hostName:
inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs self lib; };
specialArgs = { inherit inputs self lib'; };
modules = [
{ networking = { inherit hostName; }; }
"${self}/hosts/common.nix"
@ -25,9 +30,9 @@ let
in
{
flake = {
nixosConfigurations = "${self}/hosts" |> lib.custom.listDirectories |> lib.custom.genAttrs mkHost;
nixosConfigurations = "${self}/hosts" |> lib'.listDirectories |> lib'.genAttrs mkHost;
deploy.nodes = "${self}/hosts" |> lib.custom.listDirectories |> lib.custom.genAttrs mkDeployNode;
deploy.nodes = "${self}/hosts" |> lib'.listDirectories |> lib'.genAttrs mkDeployNode;
checks = inputs.deploy-rs.lib |> lib.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy);
};

4
flake-parts/lib.nix Normal file
View file

@ -0,0 +1,4 @@
{ self, inputs, ... }:
{
flake.lib' = import "${self}/lib" inputs.nixpkgs.lib;
}

View file

@ -1,10 +1,7 @@
{ self, inputs, ... }:
let
lib = inputs.nixpkgs.lib.extend (_: _: { custom = import "${self}/lib" inputs.nixpkgs.lib; });
in
{ self, ... }:
{
flake = {
nixosModules.default.imports = lib.custom.listNixFilesRecursive "${self}/modules/system";
homeManagerModules.default.imports = lib.custom.listNixFilesRecursive "${self}/modules/home";
nixosModules.default.imports = self.lib'.listNixFilesRecursive "${self}/modules/system";
homeManagerModules.default.imports = self.lib'.listNixFilesRecursive "${self}/modules/home";
};
}