Move lib into its own file.

This commit is contained in:
R-VdP 2023-02-01 17:05:44 +00:00
parent dbe192d11e
commit 255818a001
No known key found for this signature in database
2 changed files with 24 additions and 20 deletions

View file

@ -11,25 +11,6 @@
module = { imports = [ ./modules ]; }; module = { imports = [ ./modules ]; };
}; };
lib = { lib = import ./lib.nix { inherit nixpkgs; };
makeServiceConfig = { system, module }:
let
lib = nixpkgs.lib;
nixosConfig = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { };
modules = [ module ];
};
services = lib.flip lib.genAttrs
(serviceName:
nixosConfig.config.systemd.units."${serviceName}.service".unit)
nixosConfig.config.service-manager.services;
in
nixpkgs.legacyPackages.${system}.writeTextFile {
name = "services";
destination = "/services.json";
text = lib.generators.toJSON { } services;
};
};
}; };
} }

23
lib.nix Normal file
View file

@ -0,0 +1,23 @@
{ nixpkgs }:
let
inherit (nixpkgs) lib;
in
{
makeServiceConfig = { system, module }:
let
nixosConfig = lib.nixosSystem {
inherit system;
specialArgs = { };
modules = [ module ];
};
services = lib.flip lib.genAttrs
(serviceName:
nixosConfig.config.systemd.units."${serviceName}.service".unit)
nixosConfig.config.service-manager.services;
in
nixpkgs.legacyPackages.${system}.writeTextFile {
name = "services";
destination = "/services.json";
text = lib.generators.toJSON { } services;
};
}