extract service name

main
Zynh Ludwig 2024-07-31 23:53:14 -07:00
parent b0a3abbd79
commit 45e8c3e1d5
1 changed files with 13 additions and 6 deletions

View File

@ -1,11 +1,12 @@
{ lib, config, ... }: { lib, config, pkgs, ... }:
let let
service = "repo-clone";
cfg = config.repo-clone; cfg = config.repo-clone;
in in
{ {
options.repo-clone = { options.${service} = {
enable = lib.mkEnableOption "repo-clone service"; enable = lib.mkEnableOption "${service} service";
repos = lib.mkOption { repos = lib.mkOption {
type = import ./repo.nix { inherit lib; }; type = import ./repo.nix { inherit lib; };
@ -14,20 +15,24 @@ in
''; '';
default = { }; default = { };
}; };
pkg = lib.mkOption {
type = lib.types.package;
};
}; };
# /nix/store/pxd7wc8icz577hpl6pmz02b74nhbrj6h-unit-home-manager-ravenshade.service/home-manager-ravenshade.service # /nix/store/pxd7wc8icz577hpl6pmz02b74nhbrj6h-unit-home-manager-ravenshade.service/home-manager-ravenshade.service
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
system.user.services.repo-clone = { system.user.services.${service} = {
Unit = { Unit = {
Description = "repo-clone service"; Description = "${service} service";
}; };
Service = { Service = {
Type = "exec"; Type = "exec";
ExecStart = ExecStart =
let let
execName = "repo-clone"; execName = service;
script = lib.writeShellScriptBin execName '' script = lib.writeShellScriptBin execName ''
echo "hello!" echo "hello!"
''; '';
@ -39,5 +44,7 @@ in
WantedBy = [ "multi-user.target" ]; WantedBy = [ "multi-user.target" ];
}; };
}; };
cfg.pkg = pkgs.writeText "${service}.conf" '''';
}; };
} }