Move the function to generate the store path into lib.
This commit is contained in:
parent
6a849d71d0
commit
95bd335d8c
1 changed files with 26 additions and 22 deletions
48
flake.nix
48
flake.nix
|
|
@ -6,28 +6,32 @@
|
|||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }: {
|
||||
serviceConfig =
|
||||
let
|
||||
system = flake-utils.lib.system.x86_64-linux;
|
||||
lib = nixpkgs.lib;
|
||||
nixosConfig = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { };
|
||||
modules = [ ./modules ];
|
||||
serviceConfig = self.lib.makeServiceConfig
|
||||
[
|
||||
"service-1"
|
||||
"service-2"
|
||||
];
|
||||
|
||||
lib = {
|
||||
makeServiceConfig = serviceNames:
|
||||
let
|
||||
system = flake-utils.lib.system.x86_64-linux;
|
||||
lib = nixpkgs.lib;
|
||||
nixosConfig = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { };
|
||||
modules = [ ./modules ];
|
||||
};
|
||||
services = lib.flip lib.genAttrs
|
||||
(serviceName:
|
||||
nixosConfig.config.systemd.units."${serviceName}.service".unit)
|
||||
serviceNames;
|
||||
in
|
||||
nixpkgs.legacyPackages.${system}.writeTextFile {
|
||||
name = "services";
|
||||
destination = "/services.json";
|
||||
text = lib.generators.toJSON { } services;
|
||||
};
|
||||
services = lib.flip lib.genAttrs
|
||||
(serviceName:
|
||||
nixosConfig.config.systemd.units."${serviceName}.service".unit)
|
||||
# TODO: generate this list from the config instead of hard coding
|
||||
[
|
||||
"service-1"
|
||||
"service-2"
|
||||
];
|
||||
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