1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00

Merge pull request #284161 from felschr/make-startupitem-extra-args

make-startupitem: add `prependExtraArgs` and `appendExtraArgs`
This commit is contained in:
Pol Dellaiera 2024-08-10 18:39:01 +02:00 committed by GitHub
commit c4e73af4dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,8 @@
, after ? null
, condition ? null
, phase ? "2"
, prependExtraArgs ? []
, appendExtraArgs ? []
}:
# the builder requires that
@ -18,10 +20,17 @@ stdenv.mkDerivation {
name = "autostart-${name}";
priority = 5;
buildCommand = ''
buildCommand = let
escapeArgs = args: lib.escapeRegex (lib.escapeShellArgs args);
prependArgs = lib.optionalString (prependExtraArgs != []) "${escapeArgs prependExtraArgs} ";
appendArgs = lib.optionalString (appendExtraArgs != []) " ${escapeArgs appendExtraArgs}";
in ''
mkdir -p $out/etc/xdg/autostart
target=${name}.desktop
cp ${package}/share/applications/${srcPrefix}${name}.desktop $target
${lib.optionalString (prependExtraArgs != [] || appendExtraArgs != []) ''
sed -i -r "s/(Exec=)([^ ]*) (.*)/\1\2 ${prependArgs}\3${appendArgs}/" $target
''}
chmod +rw $target
echo "X-KDE-autostart-phase=${phase}" >> $target
${lib.optionalString (after != null) ''echo "${after}" >> $target''}