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 }: {
|
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;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue