Eelco Dolstra wrote:
Michael Raskin wrote:

source $stdenv/setup || exit 1

Every non-specific line in builder is honestly stolen from some script
checked out from NixOS SVN. Without thinking. OK, I will know it in future..


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):

I use it for preBuild or preConfigure or *Flags, but not for whole phases. I didn't think of using all customization resources hidden in this system.

unpackPhase="tar xvjf $src; cd 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),
Random collisions are dependent more on length, but sha-256 still wins. I thought checksum is more useful to discourage *-current.tar.bz2 links than to find malicious party who cracked an official mirror of either NixOS (he'll mess with hashes too) or some useful package. Really, I just took random package as a template, and also I usually take both source and MD5 from ftp server. Yes, I should migrate to nix-prefetch-url.

  buildInputs = [];

If buildInputs is empty you can omit it.
I write enough nix-expressions these days to have an empty template and fill it - and also I guess that every package in Nix should eventually be appropriate for being used as a template..

--

Thanks for all your comments. Now I fixed everything you noted and tested it. It works now.

I propose my nix-expression for inclusion as pkgs/development/tools/misc/lsof/default.nix (or pkgs/tools/misc/lsof, if anyone prefers it this way) . Is it now fit for this purpose?
pkgs:
pkgs.stdenv.mkDerivation {
  name = "lsof";

  src = pkgs.fetchurl {
    url = ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_4.78.tar.bz2;
    sha256 = "0azvl43niqkq94drx52p6dvp70r38f25fqw181ywmvqn80dbb3c9";
  };

  unpackPhase = "tar xvjf $src; cd lsof_*; tar xvf lsof_*.tar; 
sourceRoot=lsof_*; ";
  configurePhase = "./Configure -n linux";
  installPhase = " mkdir -p $out/bin $out/man/man8; cp lsof.8 $out/man/man8/; 
cp lsof $out/bin";

  buildInputs = [];
}
_______________________________________________
nix-dev mailing list
[email protected]
https://mail.cs.uu.nl/mailman/listinfo/nix-dev

Reply via email to