Move the function to generate the store path into lib.

This commit is contained in:
R-VdP 2023-02-01 16:47:43 +00:00
parent 6a849d71d0
commit 95bd335d8c
No known key found for this signature in database

View file

@ -6,28 +6,32 @@
}; };
outputs = { self, nixpkgs, flake-utils }: { outputs = { self, nixpkgs, flake-utils }: {
serviceConfig = serviceConfig = self.lib.makeServiceConfig
let [
system = flake-utils.lib.system.x86_64-linux; "service-1"
lib = nixpkgs.lib; "service-2"
nixosConfig = nixpkgs.lib.nixosSystem { ];
inherit system;
specialArgs = { }; lib = {
modules = [ ./modules ]; 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;
};
}; };
} }