33 lines
951 B
Nix
33 lines
951 B
Nix
# 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];
|
|
};
|
|
};
|
|
}
|