[Nix-dev] (newbie) nix-env custom package installation

Иван Левашев octagram at bluebottle.com
Sun Dec 4 07:43:14 CET 2011


Hello!

I'm running in circles. I can't install a self-written derivation that I 
haven't written into all-packages.nix. Manual only has samples where a 
package is present in all-packages.nix. I don't want to touch this file yet.

So I have written rhash.nix:

{stdenv, fetchurl, openssl ? null}:

let
   version = "1.2.8";
in
stdenv.mkDerivation {
   name = "rhash-${version}";
   inherit openssl;

   makeFlags = if openssl != null then "ADDCFLAGS=\"-DUSE_OPENSSL 
-DOPENSSL_RUNTIME -rdynamic\" ADDLDFLAGS=\"-ldl\"" else "";
   src = fetchurl {
     url = 
"mirror://sourceforge/rhash/${version}/rhash-${version}-src.tar.gz";
     md5 = "6b9db38cc322caa5cd0151abdc92a2b5";
   };

   buildinputs = if openssl != null then [openssl] else [];

   meta = {
     homepage = "http://rhash.anz.ru/?l=en";
     description = "RHash (Recursive Hasher) is a console utility for 
computing and verifying hash sums of files";
   };
}


Now I'm trying to guess how to install it.

[OCTAGRAM at nixos:~]$ nix-env -E 'f: f // {rhash = import ./rhash.nix;}' 
-i rhash                                    --dry-run
(dry run; not doing anything)
error: cannot auto-call a function that has an argument without a 
default value (`stdenv')

[OCTAGRAM at nixos:~]$ nix-env -E 'f: f // {rhash = callPackage ./rhash.nix 
{ stdenv = f.stdenv; fetchurl = f.fetchurl; openssl = f.openssl; } ;}' 
-i rhash --dry-run
(dry run; not doing anything)
error: undefined variable `callPackage', in `(string)'

[OCTAGRAM at nixos:~]$ nix-env -E 'f: f // {rhash = f.callPackage 
./rhash.nix { stdenv = f.stdenv; fetchurl = f.fetchurl; openssl = 
f.openssl; } ;}' -i rhash --dry-run
(dry run; not doing anything)
error: attribute `callPackage' missing

[OCTAGRAM at nixos:~]$ nix-env -E 'f: f // {rhash = import ./rhash.nix { 
stdenv = f.stdenv; fetchurl = f.fetchurl; openssl = f.openssl; } ;}' -i 
rhash --dry-run
(dry run; not doing anything)
error: attribute `stdenv' missing
(use `--show-trace' to show detailed location information)

[OCTAGRAM at nixos:~]$ nix-env -E 'f: f // {rhash = import ./rhash.nix f 
;}' -i rhash --dry-run                       (dry run; not doing anything)
error: function at `/home/OCTAGRAM/rhash.nix:1:1' called without 
required argument `stdenv'

[OCTAGRAM at nixos:~]$ nix-env -E 'f: f // {rhash = import ./rhash.nix f {} 
;}' -i rhash --dry-run
(dry run; not doing anything)
error: function at `/home/OCTAGRAM/rhash.nix:1:1' called without 
required argument `stdenv'

[OCTAGRAM at nixos:~]$ nix-env -E 'f: f // {rhash = import ./rhash.nix (f 
{}) ;}' -i rhash --dry-run
(dry run; not doing anything)
error: attempt to call something which is neither a function nor a 
primop (built-in operation) but an attribute set

I believe it to be indeed possible, but I've ran out of ideas. IIUC I 
must construct something similar to what is defined in all-packages.nix, 
but all-packages is too long, I can't easily overlook it.

If that means something, I have NixOS installed inside VMWare Server 
(it's free, BTW).

Best regards,
Ivan Levashew

-- 
If you want to get to the top, you have to start at the bottom



More information about the nix-dev mailing list