Move lib into its own file.
This commit is contained in:
parent
dbe192d11e
commit
255818a001
2 changed files with 24 additions and 20 deletions
21
flake.nix
21
flake.nix
|
|
@ -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
23
lib.nix
Normal 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;
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue