Move nix code under nix/

This commit is contained in:
R-VdP 2023-02-01 17:39:07 +00:00
parent fe6fb907f7
commit 929da3e3c3
No known key found for this signature in database
3 changed files with 2 additions and 2 deletions

34
nix/lib.nix Normal file
View file

@ -0,0 +1,34 @@
{ nixpkgs }:
let
inherit (nixpkgs) lib;
in
{
makeServiceConfig = { system, module }:
let
pkgs = nixpkgs.legacyPackages.${system};
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;
servicesPath =
pkgs.writeTextFile {
name = "services";
destination = "/services.json";
text = lib.generators.toJSON { } services;
};
activationScript = pkgs.writeShellScript "activate" ''
echo "${servicesPath}"
'';
in
pkgs.linkFarmFromDrvs "service-manager" [
servicesPath
activationScript
];
}