feat(transientServices): add transient services module, credit to github:NotAShelf
This commit is contained in:
parent
7d3d715408
commit
2d83b0f10d
3 changed files with 38 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
./git
|
||||
./tools
|
||||
./ssh
|
||||
./transientServices
|
||||
];
|
||||
|
||||
options.homeModules.console.utility = {
|
||||
|
|
@ -20,5 +21,8 @@
|
|||
tools = {
|
||||
enable = lib.mkEnableOption "Enable various console tools";
|
||||
};
|
||||
transientServices = {
|
||||
enable = lib.mkEnableOption "Enable various console transientServices";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
33
home/modules/console/utility/transientServices/default.nix
Normal file
33
home/modules/console/utility/transientServices/default.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# taken from github:NotAShelf/fufexan
|
||||
{ pkgs, config, lib, ... }:
|
||||
let
|
||||
cfg = config.homeModules.console.utility.transientServices;
|
||||
apply-hm-env = pkgs.writeShellScript "apply-hm-env" ''
|
||||
${lib.optionalString (config.home.sessionPath != []) ''
|
||||
export PATH=${builtins.concatStringsSep ":" config.home.sessionPath}:$PATH
|
||||
''}
|
||||
${builtins.concatStringsSep "\n" (lib.mapAttrsToList (k: v: ''
|
||||
export ${k}=${toString v}
|
||||
'')
|
||||
config.home.sessionVariables)}
|
||||
${config.home.sessionVariablesExtra}
|
||||
exec "$@"
|
||||
'';
|
||||
|
||||
# runs processes as systemd transient services
|
||||
run-as-service = pkgs.writeShellScriptBin "run-as-service" ''
|
||||
exec ${pkgs.systemd}/bin/systemd-run \
|
||||
--slice=app-manual.slice \
|
||||
--property=ExitType=cgroup \
|
||||
--user \
|
||||
--wait \
|
||||
bash -lc "exec ${apply-hm-env} $@"
|
||||
'';
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.enable {
|
||||
home = {
|
||||
packages = [run-as-service];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -74,6 +74,7 @@ in
|
|||
nixIndex.enable = true;
|
||||
git.enable = true;
|
||||
tools.enable = true;
|
||||
transientServices.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue