[Nix-dev] Installing a Haskell program

Amy de Buitléir amy at nualeargais.ie
Sun May 17 01:10:34 CEST 2015


I have a very simple Haskell project, with just two files, Jot.cabal and
Jot.hs. I can build and run it OK, but can't figure out how to install it.

    [amy at wombat9000:~/jot]$ cabal2nix --shell . > default.nix

    [amy at wombat9000:~/jot]$ nix-shell -I ~ --command 'cabal configure'
    Warning: The package list for 'hackage.haskell.org' does not exist. Run
'cabal
    update' to download it.
    Resolving dependencies...
    Configuring Jot-1.0...

NOTE: I didn't run 'cabal update'. I'm guessing that I don't need to because
haskell NG is managing haskell packages for me.

    [amy at wombat9000:~/jot]$ cabal build
    Building Jot-1.0...
    Preprocessing executable 'jot' for Jot-1.0...
    [1 of 1] Compiling Main             ( Jot.hs,
dist/build/jot/jot-tmp/Main.o )
    Linking dist/build/jot/jot ...

    [amy at wombat9000:~/jot]$ cabal run

...it works fine. So now I want to install it so I can run the "jot" command
anywhere on my system. I created a shell.nix file:

    [amy at wombat9000:~/jot]$ cat shell.nix
    { pkgs ? (import <nixpkgs> {}) }:

    (import ./default.nix) {
        stdenv            = pkgs.stdenv;
        haskellngPackages = pkgs.haskellngPackages;
      }

    [amy at wombat9000:~/jot]$ nix-env -f default.nix -i
    installing ‘interactive-Jot-1.0-environment’
    these derivations will be built:
     
/nix/store/1nwq9hcna1j1pcinp41xlxysqzd3m7bh-interactive-Jot-1.0-environment.drv
    building path(s)
‘/nix/store/svkd0dh83fs2rr1p18zbq1ldcnx0xz1w-interactive-Jot-1.0-environment’
    unpacking sources
    variable $src or $srcs should point to the source
    builder for
‘/nix/store/1nwq9hcna1j1pcinp41xlxysqzd3m7bh-interactive-Jot-1.0-environment.drv’
failed with exit code 1
    error: build of
‘/nix/store/1nwq9hcna1j1pcinp41xlxysqzd3m7bh-interactive-Jot-1.0-environment.drv’
failed





More information about the nix-dev mailing list