[Nix-dev] Generating desktop files

Nicolas Pierron nicolas.b.pierron at gmail.com
Tue May 12 11:57:59 CEST 2009


Hi,

On Tue, May 12, 2009 at 09:48, Eelco Dolstra <e.dolstra at tudelft.nl> wrote:
> Sander van der Burg - EWI wrote:
>
>> I just created a makeDesktopItem function in Nixpkgs, which you can use
>> to generate .desktop files for applications that do not include .desktop
>> files in their tarballs, such as Mozilla Firefox.
>
> Maybe it would be nice to have this as a shell function that can be called from
> postInstall hooks.  That way we wouldn't have to create a wrapper package for
> everything.

Adding a function inside setup.sh implies that you will have to
recompile every package each time you add a support to a new standard.
 I think there is a better solution to allow futur extension of the
setup.sh script without recompiling every package each time we want to
progressively integrate a standard.

We could add a "source" operation for all extra extension not
supported by setup.sh.

## inside setup.sh
for i in : $extraSetup; do
  test "$i" = ":" && continue
  . "$i"
done

## inside fnix expression

stdenv.mkDerivation {
  name = "foo-1.2.3";

  extraSetup = mkDesktopItem;

  ...

  postInstall = "
    mkDesktopItem $out/bin/foo ...
  ";
}

where mkDesktopItem is defined as:

mkDesktopItem = writeScript "
  mkDesktopItem(){ # shell function imported by setup.sh
    ...
  }
";

> Or even better, makeDesktopItem could be a setup hook that hooks itself into
> postInstall and uses derivation attributes to create a desktop item.  Something
> like this:
>
>  stdenv.mkDerivation {
>    name = "foo-1.2.3";
>
>    buildInputs = [makeDesktopItem ...];
>
>    desktopItemName = "foo";
>    desktopItemIcon = ...;
>    ...
>  }

The bad point of this, is that your derivation will become much more
complex each time you will have to extend it.  Moreover, a package
could have many .desktop files like we could expect from open-office.


-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
- If you are doing something twice then you should try to do it once.



More information about the nix-dev mailing list