mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-23 22:23:15 +00:00
6bf72482eb
The freedesktop specification says that the autostart folder is located at $XDG_CONFIG_DIRS/autostart. Nixos defines XDG_CONFIG_DIRS as /etc/xdg. So we need to copy the desktop files into the right folder with make-startupitem.
36 lines
1.1 KiB
Nix
36 lines
1.1 KiB
Nix
# given a pakcage with a $name.desktop file, makes a copy
|
|
# as autostart item.
|
|
|
|
{stdenv, lib}:
|
|
{ name # name of the desktop file (without .desktop)
|
|
, package # package where the desktop file resides in
|
|
, srcPrefix ? "" # additional prefix that the desktop file may have in the 'package'
|
|
, after ? null
|
|
, condition ? null
|
|
, phase ? "2"
|
|
}:
|
|
|
|
# the builder requires that
|
|
# $package/share/applications/$name.desktop
|
|
# exists as file.
|
|
|
|
stdenv.mkDerivation {
|
|
name = "autostart-${name}";
|
|
priority = 5;
|
|
|
|
buildCommand = ''
|
|
mkdir -p $out/etc/xdg/autostart
|
|
target=${name}.desktop
|
|
cp ${package}/share/applications/${srcPrefix}${name}.desktop $target
|
|
chmod +rw $target
|
|
echo "X-KDE-autostart-phase=${phase}" >> $target
|
|
${lib.optionalString (after != null) ''echo "${after}" >> $target''}
|
|
${lib.optionalString (condition != null) ''echo "${condition}" >> $target''}
|
|
cp $target $out/etc/xdg/autostart
|
|
'';
|
|
|
|
# this will automatically put 'package' in the environment when you
|
|
# put its startup item in there.
|
|
propagatedBuildInputs = [ package ];
|
|
}
|