nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 47 lines 1.6 kB view raw
1# given a package with a $name.desktop file, makes a copy 2# as autostart item. 3 4{ stdenv, lib }: 5{ 6 name, # name of the desktop file (without .desktop) 7 package, # package where the desktop file resides in 8 srcPrefix ? "", # additional prefix that the desktop file may have in the 'package' 9 after ? null, 10 condition ? null, 11 phase ? "2", 12 prependExtraArgs ? [ ], 13 appendExtraArgs ? [ ], 14}: 15 16# the builder requires that 17# $package/share/applications/$name.desktop 18# exists as file. 19 20stdenv.mkDerivation { 21 name = "autostart-${name}"; 22 priority = 5; 23 24 buildCommand = 25 let 26 escapeArgs = args: lib.escapeRegex (lib.escapeShellArgs args); 27 prependArgs = lib.optionalString (prependExtraArgs != [ ]) "${escapeArgs prependExtraArgs} "; 28 appendArgs = lib.optionalString (appendExtraArgs != [ ]) " ${escapeArgs appendExtraArgs}"; 29 in 30 '' 31 mkdir -p $out/etc/xdg/autostart 32 target=${name}.desktop 33 cp ${package}/share/applications/${srcPrefix}${name}.desktop $target 34 ${lib.optionalString (prependExtraArgs != [ ] || appendExtraArgs != [ ]) '' 35 sed -i -r "s/(Exec=)([^ \n]*) *(.*)/\1\2 ${prependArgs}\3${appendArgs}/" $target 36 ''} 37 chmod +rw $target 38 echo "X-KDE-autostart-phase=${phase}" >> $target 39 ${lib.optionalString (after != null) ''echo "${after}" >> $target''} 40 ${lib.optionalString (condition != null) ''echo "${condition}" >> $target''} 41 cp $target $out/etc/xdg/autostart 42 ''; 43 44 # this will automatically put 'package' in the environment when you 45 # put its startup item in there. 46 propagatedBuildInputs = [ package ]; 47}