mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
added environment script.
This commit is contained in:
parent
30dc417188
commit
c60c8d8e0b
|
@ -70,6 +70,15 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
mkWrapper = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Make a shell script wrapper called 'copyparty-env' with all options set here,
|
||||
for ease of things like password hashing
|
||||
'';
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "copyparty";
|
||||
|
@ -324,5 +333,27 @@ in {
|
|||
home = lib.mkIf externalStateDir;
|
||||
isSystemUser = true;
|
||||
};
|
||||
environment.systemPackages = lib.mkIf cfg.mkWrapper [
|
||||
(
|
||||
let
|
||||
command = ''
|
||||
${getExe cfg.package} -c ${runtimeConfigPath} \
|
||||
${optionalString (cfg.seperateHist) "--hist ${externalCacheDir}"} \
|
||||
'';
|
||||
in
|
||||
pkgs.writeShellScriptBin "copyparty-env" ''
|
||||
set -a # automatically export variables
|
||||
# set same environment variables as the systemd service
|
||||
${lib.pipe config.systemd.services.copyparty.environment [
|
||||
(lib.filterAttrs (n: v: v != null && n != "PATH"))
|
||||
(lib.mapAttrs (_: v: "${v}"))
|
||||
(lib.toShellVars)
|
||||
]}
|
||||
PATH=${config.systemd.services.copyparty.environment.PATH}:$PATH
|
||||
|
||||
exec ${command} "$@"
|
||||
''
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue