[Nix-dev] [Fwd: lsof nix-expression]

Eelco Dolstra eelco at cs.uu.nl
Mon Jun 11 14:00:13 CEST 2007


Michael Raskin wrote:

> I am now migrating to NixOS. I have already written some Nix expressions
>   for software not included/included with minimal options.. So I want to
> hear what to correct in attached lsof expression in order to get it
> merged. It has the simplest nix-part, non-standard builder part and is
> the most critical of my hand-installed packages.

It looks fine :-)  Some minor comments:

> source $stdenv/setup || exit 1

The "exit 1" is unnecessary (since bash is started with the -e option).

> set -e

Idem.

> tar xvjf $src
> cd lsof_*
> tar xvf lsof_*.tar
> cd lsof_*
> ./Configure -n linux
> make
> mkdir -p $out/bin $out/man/man8
> cp lsof.8 $out/man/man8/
> cp lsof $out/bin

It's a bit nicer to use the generic builder (since it does things like running
patchelf to get rid of unnecessary dependencies, stripping libraries, etc,
though none of that is particularly useful here).  Something like this (not tested):

unpackPhase="tar xvjf $src; cd lsof_*; tar xvf lsof_*.tar"

configurePhase="./Configure -n linux"

installPhase="mkdir ... etc"

genericBuild

In fact, it's even possible to stick this directly in the Nix expression, and
then you don't need a build script at all (since the default builder just calls
genericBuild).  Something like

  stdenv.mkDerivation {
    name = ...;
    unpackPhase = "tar xvjf $src; cd lsof_*; tar xvf lsof_*.tar";
    ... and so on ...
  }

> pkgs.stdenv.mkDerivation {
>   name = "lsof";
> 
>   src = pkgs.fetchurl {
>     url = ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_4.78.tar.bz2;
>     md5 = "00360ce2b62de3015fa7e0f8f92179a8";

We're slowly migrating to SHA-256 hashes (since MD5 is not very secure anymore),
which is what nix-prefetch-url now prints by default.  So

  sha256 = "0azvl43niqkq94drx52p6dvp70r38f25fqw181ywmvqn80dbb3c9";

>   };
>  
>   builder=./builder.sh;
> 
>   buildInputs = [];

If buildInputs is empty you can omit it.

> }

-- 
Eelco Dolstra | http://www.cs.uu.nl/~eelco



More information about the nix-dev mailing list