extract service.nix
This commit is contained in:
parent
c15afde777
commit
e8c6f48bec
2 changed files with 28 additions and 18 deletions
20
module.nix
20
module.nix
|
@ -8,7 +8,7 @@ let
|
|||
inherit (lib.strings) concatStringsSep;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
|
||||
inherit (pkgs) writeShellScriptBin writeText;
|
||||
inherit (pkgs) writeText;
|
||||
in
|
||||
{
|
||||
options.${service} = {
|
||||
|
@ -30,23 +30,7 @@ in
|
|||
|
||||
# /nix/store/pxd7wc8icz577hpl6pmz02b74nhbrj6h-unit-home-manager-ravenshade.service/home-manager-ravenshade.service
|
||||
config = mkIf cfg.enable {
|
||||
systemd.user.services.${service} = {
|
||||
Unit.Description = "${service} service";
|
||||
Service = {
|
||||
Type = "exec";
|
||||
ExecStart =
|
||||
let
|
||||
execName = service;
|
||||
script = writeShellScriptBin execName ''
|
||||
echo "hello!"
|
||||
echo "${config.repo-clone.pkg}"
|
||||
'';
|
||||
in
|
||||
"${script}/bin/${execName}";
|
||||
RemainAfterExit = "yes";
|
||||
};
|
||||
Install.WantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
systemd.user.services.${service} = import ./service.nix { inherit service pkgs config; };
|
||||
|
||||
repo-clone.pkg = writeText "${service}.conf"
|
||||
(concatStringsSep "\n"
|
||||
|
|
26
service.nix
Normal file
26
service.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ config, service, pkgs }:
|
||||
|
||||
let
|
||||
inherit (pkgs)
|
||||
writeShellScriptBin;
|
||||
in
|
||||
{
|
||||
Unit = {
|
||||
Description = "${service} service";
|
||||
X-Restart-Triggers = [ "${config.repo-clone.pkg}" ];
|
||||
};
|
||||
Service = {
|
||||
Type = "exec";
|
||||
ExecStart =
|
||||
let
|
||||
execName = service;
|
||||
script = writeShellScriptBin execName ''
|
||||
echo "hello!"
|
||||
echo "${config.repo-clone.pkg}"
|
||||
'';
|
||||
in
|
||||
"${script}/bin/${execName}";
|
||||
RemainAfterExit = "yes";
|
||||
};
|
||||
Install.WantedBy = [ "multi-user.target" ];
|
||||
}
|
Loading…
Reference in a new issue