0

I am trying to build a nix package for the datomic database.

here is the derivation so far:

{ stdenv, fetchurl, unzip }:                                                                                                                                                                  

stdenv.mkDerivation rec {                                                                                                                                                                     
  name    = "datomic-${version}";                                                                                                                                                             
  version = "0.9.5561";                                                                                                                                                                       

  src = fetchurl {                                                                                                                                                                            
    url    = "https://my.datomic.com/downloads/free/${version}";                                                                                                                              
    sha256 = "145c3yx9ylmvvxmwgk2s14cdirxasdlglq3vs9qsnhyaz5jp1xjh";                                                                                                                          
  };                                                                                                                                                                                          
}                                                                                                                                                                                             

The URL:

https://my.datomic.com/downloads/free/0.9.5561

IS a zip file, without the zip extension, so fetchurl is throwing the following error:

unpacking source archive /nix/store/rrv926023hmbvcxc7r421mk1l0x1537c-0.9.5561
do not know how to unpack source archive /nix/store/rrv926023hmbvcxc7r421mk1l0x1537c-0.9.5561
builder for ‘/nix/store/bhmrgkjqbha5p5cf79xvqwkqwr3rfjfk-datomic-0.9.5561.drv’ failed with exit code 1

Any suggestions for how to get this source, and maybe tack on a *.zip extension so it can unpack itself?

ftravers
  • 3,809
  • 3
  • 37
  • 38

2 Answers2

1

The generic builder that is used by default has configurable phases (source).

You can take a look at the unpack phase, in it you can just specify a command that unpacks the downloaded sources (unpackCmd is probably exactly what you want).

Alternatively it looks like you could just specify the name argument of fetchurl and give the downloaded file a '*.zip' name (see name argument).

fghibellini
  • 636
  • 4
  • 15
  • also the src variable seems to have a special meaning to the generic builder as described in the above linked docs. The unpack phases expect it to contain the path to the unpackable content (no matter if open source). – fghibellini Jan 09 '18 at 15:08
0

It seems like the generic builder script that comes with nixpkgs doesn't know how to handle your download. You can try using a custom builder shell script. Just write something like builder = ./builder.sh; right after version and then write a shell script in builder.sh. The script should be something like this:

source $stdenv/setup

unzip $src

# more stuff

You'll have to figure out the details yourself by fixing one error message at a time.

P.S. Datomic is not open source, so I would not have a variable named src.

David Grayson
  • 84,103
  • 24
  • 152
  • 189