[<<][nixos][>>][..]
Tue Mar 12 06:59:37 EDT 2019

solving some issues

I want to get this into incremental changes mode.

Some questions:

- how does cabal2nix actually work?
- how can I override some packages?
- how to include it into exo/deps
- how to build offline


There seem to be two ways to extend or modify nixpkgs.

- Put things in your local .nix file
- clone nixpkgs and modify

I'm starting from the one I found in hatd:

fde2012519999145c541547bce310f327080e997 Merge #44931: firefox: disable VLC plugin
Date:   Fri Aug 24 09:29:06 2018 +0200

So, how to direct the nix shell to this env?



I've set up exo with:

deps/nixpkgs clone of hatd nixpkgs
nix          release.nix bound to ../deps/nixpkgs


How do I know which version a haskell package is at?

This didn't return anything:
tom@panda:~/exo/nix/nixpkgs$ grep -re '*llvm-hs-pretty*'

Let's start with exploring
https://github.com/NixOS/cabal2nix

It gives this example:

tom@panda:~/exo/nix$ cabal2nix cabal://mtl
{ mkDerivation, base, stdenv, transformers }:
mkDerivation {
  pname = "mtl";
  version = "2.2.2";
  sha256 = "8803f48a8ed33296c3a3272f448198737a287ec31baa901af09e2118c829bef6";
  libraryHaskellDepends = [ base transformers ];
  homepage = "http://github.com/haskell/mtl";
  description = "Monad classes, using functional dependencies";
  license = stdenv.lib.licenses.bsd3;
}


So I should be able to get the llvm-hs-pretty package this way:

tom@panda:~/exo/nix$ cabal2nix cabal://llvm-hs-pretty
{ mkDerivation, array, base, bytestring, directory, filepath
, llvm-hs, llvm-hs-pure, mtl, prettyprinter, stdenv, tasty
, tasty-golden, tasty-hspec, tasty-hunit, text, transformers
}:
mkDerivation {
  pname = "llvm-hs-pretty";
  version = "0.5.0.0";
  sha256 = "0dca50bf44df9128fe6f4ad0ed09281c1fc4e615ceac390b2197d2f7f8e9259c";
  libraryHaskellDepends = [
    array base bytestring llvm-hs-pure prettyprinter text
  ];
  testHaskellDepends = [
    base directory filepath llvm-hs llvm-hs-pure mtl tasty tasty-golden
    tasty-hspec tasty-hunit text transformers
  ];
  homepage = "https://github.com/llvm-hs/llvm-hs-pretty";
  description = "A pretty printer for LLVM IR";
  license = stdenv.lib.licenses.mit;
}


Can I just build that derivation directly?
I'm not sure this is the right question to ask.

Why is the above different from just including llvm-hs-pretty in a
cabal file?  How does it resolve, basically?

EDIT: Now that nixpkgs points at the repo mentioned above, the
versions do seem to be higher:

* llvm-hs-pretty
    Synopsis: A pretty printer for LLVM IR.
    Default available version: 0.5.0.0
    Installed versions: [ Not installed ]
    Homepage: https://github.com/llvm-hs/llvm-hs-pretty
    License:  MIT


I rememver the other one being at 0.2
I don't understand why.

I've added llvm-hs-pretty to exo-hs.cabal again.


This is the error:
test: tests/input/: getDirectoryContents:openDirStream: does not exist (No such file or directory)

I think it is the same as before.  It's still at:
Building library for llvm-hs-pretty-0.2.0.0..

Is there a way to override running the tests during package build?


So question remains: where does this version come from?



EDIT: I'm going to have to trace this down.  Setting a >= constraint
on the version in the .cabal file doesn't have any effect.

Where does it get its versions?

cabal2nix page links to:

https://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure

  "The Haskell package set is not registered in the top-level
   namespace because it is *huge*. If all Haskell packages were
   visible to these commands, then name-based search/install
   operations would be much slower than they are now. We avoided that
   by keeping all Haskell-related packages in a separate attribute set
   called haskellPackages, which the following command will list: "


tom@panda:~/exo/hs$ nix-env -f ./nixpkgs -qaP -A haskellPackages | grep llvm-hs
haskellPackages.llvm-hs                                         llvm-hs-5.1.3
haskellPackages.llvm-hs_6_0_0                                   llvm-hs-6.0.0
haskellPackages.llvm-hs-pretty                                  llvm-hs-pretty-0.2.0.0
haskellPackages.llvm-hs-pure                                    llvm-hs-pure-5.1.2
haskellPackages.llvm-hs-pure_6_0_0                              llvm-hs-pure-6.0.0

So it appears that it will always take the version from there.

Reproducing just the error:

tom@panda:~/exo/hs$ nix-env -f ./nixpkgs -iA haskellPackages.llvm-hs-pretty
...
running tests
Running 1 test suites...
Test suite test: RUNNING...
test: tests/input/: getDirectoryContents:openDirStream: does not exist (No such file or directory)
Test suite test: FAIL
Test suite logged to: dist/test/llvm-hs-pretty-0.2.0.0-test.log
0 of 1 test suites (0 of 1 test cases) passed.
builder for '/nix/store/mcprcpib8l31qkyjkw4qk84395332yzq-llvm-hs-pretty-0.2.0.0.drv' failed with exit code 1
error: build of '/nix/store/mcprcpib8l31qkyjkw4qk84395332yzq-llvm-hs-pretty-0.2.0.0.drv' failed

So I should be able to go into nixpkgs and find that package.

Yep, here it is:

~/exo/deps/nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix


  "llvm-hs-pretty" = callPackage
    ({ mkDerivation, array, base, bytestring, directory, filepath
     , llvm-hs, llvm-hs-pure, mtl, pretty-show, tasty, tasty-golden
     , tasty-hspec, tasty-hunit, text, transformers, wl-pprint-text
     }:
     mkDerivation {
       pname = "llvm-hs-pretty";
       version = "0.2.0.0";
       sha256 = "133kyksbp88q0wavp3wdjg69h9fpwi7nq626nvikdy46cf7lgklh";
       libraryHaskellDepends = [
         array base bytestring llvm-hs-pure text wl-pprint-text
       ];
       testHaskellDepends = [
         base directory filepath llvm-hs llvm-hs-pure mtl pretty-show tasty
         tasty-golden tasty-hspec tasty-hunit text transformers
       ];
       homepage = "https://github.com/llvm-hs/llvm-hs-pretty";
       description = "Pretty printer for LLVM IR";
       license = stdenv.lib.licenses.mit;
       hydraPlatforms = stdenv.lib.platforms.none;
     }) {};


So a couple of paths here:
- find a way to fix the build error
- try a different nixpkgs tree to see if it has a different version
- override the package locally

It is updated in the current listing.
version = "0.6.1.0";

So can I just merge nixpkgs?
Let's try it.  It might brake some things though...

Let's at least pick a release version
Branch 19-03 also has the same version.


Set up git properly
- in ~/git/nixpkgs, restore origin to https://github.com/NixOS/nixpkgs.git
- fetch the branch into main ~/git
tom@panda:~/git/nixpkgs.git$ git fetch origin release-19.03:release-19.03
- then fetch and merge it into exo
tom@panda:~/exo/deps/nixpkgs$ git fetch origin release-19.03
tom@panda:~/exo/deps/nixpkgs$ git merge origin/release-19.03

That merge failed big time.  So just do:
tom@panda:~/exo/deps/nixpkgs$ git reset --hard origin/release-19.03

It fails building:

Setup: The program 'llvm-config' version ==7.0.* is required but the version
found at
/nix/store/xznp9rd6r6lim185s35a5ni11ra3p0ja-llvm-6.0.1/bin/llvm-config is
version 6.0.1

builder for '/nix/store/rmyrhg19gifvcwcsg0dhgxqbg93d4xnx-llvm-hs-7.0.1.drv' failed with exit code 1
cannot build derivation '/nix/store/cisvd2zk7dk52pf65bmrgjqdqx3m3963-ghc-8.6.3-with-packages.drv': 1 dependencies couldn't be built
error: build of '/nix/store/cisvd2zk7dk52pf65bmrgjqdqx3m3963-ghc-8.6.3-with-packages.drv' failed



I'm going to have to learn how to deal with this.

It seems that there is no guarantee the versions match properly for
all packages.  

Now, do i fix this in nixpkgs, or in the source package?

It makes more sense to keep the environment consistent to my needs, so
fix it in nixpkgs.

I can either bump llvm to 7, or wind the haskell bindings back to 6.
Messing with llvm seems more dangerous.  Let's try the haskell side first.
Changing in hackage-packages.nix : llvm-hs to "6.3.0"

And again a fucking build error.
This time it seems due to GHC version 8.6

Trying some more changes and more constraints pop up.
This is not the right avenue.  Going to revert back, saved it in:

tom@panda:~/exo/deps/nixpkgs$ git-log |head
17640cb67fa338ada104c5f48200ef3cd4a60bb8 attempt_llvm_hs_fixes

The other route is to upgrade llvm.  There are build scripts for
version 7.  How to make sure it finds the right version?

override "llvm-config" with version 7.


First switch main env to 19.03
tom@panda:~/exo/hs$ nix-channel --add https://nixos.org/channels/nixos-19.03 nixpkgs





[Reply][About]
[<<][nixos][>>][..]