nix: improve start script
test / test (push) Successful in 23s Details

Zsh store path in shebang. Replace writeShellScript with writeScript since runtimeShell is not overridable.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
Ophestra Umiker 2024-11-06 14:09:41 +09:00
parent f831948bca
commit ad80be721b
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
2 changed files with 17 additions and 3 deletions

View File

@ -173,7 +173,9 @@ This adds the `environment.fortify` option:
* `id`, the freedesktop application ID, primarily used by dbus, null to disable. * `id`, the freedesktop application ID, primarily used by dbus, null to disable.
* `command`, the command to run as the target user. Defaults to launcher name. * `script`, application launch script.
* `command`, the command to run as the target user. Defaults to launcher name. Has no effect when script is set.
* `dbus.session`, D-Bus session proxy custom configuration. * `dbus.session`, D-Bus session proxy custom configuration.

View File

@ -64,12 +64,21 @@ in
''; '';
}; };
script = mkOption {
type = nullOr str;
default = null;
description = ''
Application launch script.
'';
};
command = mkOption { command = mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;
description = '' description = ''
Command to run as the target user. Command to run as the target user.
Setting this to null will default command to wrapper name. Setting this to null will default command to wrapper name.
Has no effect when script is set.
''; '';
}; };
@ -298,6 +307,7 @@ in
system_bus = launcher.dbus.system; system_bus = launcher.dbus.system;
}; };
command = if launcher.command == null then name else launcher.command; command = if launcher.command == null then name else launcher.command;
script = if launcher.script == null then ("exec " + command + " $@") else launcher.script;
enablements = enablements =
(if wayland then 1 else 0) (if wayland then 1 else 0)
+ (if x11 then 2 else 0) + (if x11 then 2 else 0)
@ -307,8 +317,10 @@ in
inherit (launcher) id method; inherit (launcher) id method;
inherit user; inherit user;
command = [ command = [
"/run/current-system/sw/bin/zsh" (pkgs.writeScript "${name}-start" ''
(pkgs.writeShellScript "${name}-start" ("exec " + command + " $@")) #!${pkgs.zsh}${pkgs.zsh.shellPath}
${script}
'')
]; ];
confinement = { confinement = {
sandbox = { sandbox = {