[prev in list] [next in list] [prev in thread] [next in thread]
List: nix-dev
Subject: Re: [Nix-dev] (Haskell) Weird cross-project behaviour in presence of dist directory
From: Mateusz Kowalczyk <fuuzetsu () fuuzetsu ! co ! uk>
Date: 2014-06-28 16:43:21
Message-ID: 53AEF0A9.3020403 () fuuzetsu ! co ! uk
[Download RAW message or body]
On 06/28/2014 06:03 PM, Mateusz Kowalczyk wrote:
> Greetings,
>
> I have a simple use-case when developing Haskell. I have a library that
> I hack on and in another place an executable which uses the library. I
> have default.nix for both.
>
> Consider the following:
>
> /tmp/example/exec/{Main.hs,default.nix,Setup.hs,Executable.cabal}
> /tmp/example/lib/{Library.hs,default.nix,Setup.hs,Library.cabal}
>
> Library provides a simple message = "Library version 1"
>
> All the main that's in separate package does is print the message. The
> executable project depends on Library in cabal file and imports it in
> default.nix.
>
> Now I drop into a nix-shell --pure in exec. I am told this:
>
> these derivations will be built:
>
> /nix/store/haw37l5w9hqr7sglwfqash8r2jprwhla-haskell-Library-ghc7.6.3-0.1.0.0.drv
> …
>
> So far so good. Next I run
>
> eval "$configurePhase" && eval "$buildPhase"
>
> Still, good, it tells me Dependency Library -any: using Library-0.1.0.0
>
> Now I go to test the produced binary:
>
> [nix-shell:/tmp/example/exec]$ ./dist/build/Executable/Executable
> "Library version 1"
>
> OK, great!
>
> Now I want to make changes in my library. I quit this shell and change
> the message in my Library to "Library version 2". No changes necessary
> to either cabal or nix files. After I'm happy with the change, I go back
> into a shell in exec:
>
> these derivations will be built:
>
> /nix/store/04idz8675pr8pa97xk29msg4waa6820h-haskell-Library-ghc7.6.3-0.1.0.0.drv
>
> Great, it seems to have noticed I made a change and is wanting to rebuild.
>
> [nix-shell:/tmp/example/exec]$ ./dist/build/Executable/Executable
> "Library version 2"
>
> Sweet, as if by magic. Now for the weird thing. When developing a
> library, we'll ofter run eval "$configurePhase" && eval "$buildPhase" in
> it so we know it builds &c.
>
> Let me do that now. I will go into ../lib, change the message to version
> 3 and eval configure and build phase.
>
> Building Library-0.1.0.0...
> Preprocessing library Library-0.1.0.0...
> [1 of 1] Compiling Library ( Library.hs, dist/build/Library.o )
> In-place registering Library-0.1.0.0...
> Running Haddock for Library-0.1.0.0...
> Running hscolour for Library-0.1.0.0...
> Preprocessing library Library-0.1.0.0...
> Preprocessing library Library-0.1.0.0...
> Warning: The documentation for the following packages are not installed. No
> links will be generated to these packages: rts-1.0
> Haddock coverage:
> 0% ( 0 / 2) in 'Library'
> Documentation created: dist/doc/html/Library/index.html,
> dist/doc/html/Library/Library.txt
>
> [nix-shell:/tmp/example/lib]$ ls dist/
> build doc package.conf.inplace setup-config
>
>
> So far all good. This is exactly as we have done before with the
> difference that we run configure and build. Now I go back to my exec
> project, it picks up on changes in Library and I run configure phase and
> build phase.
>
> [nix-shell:/tmp/example/exec]$ ./dist/build/Executable/Executable
> "Library version 3"
>
> OK, now I want to do more hacking in Library. I go and do it *but* I
> forget or don't want to to run configure and build phases. I bump the
> message version to 4. I re-enter exec shell, configure, build, run dist:
>
> [nix-shell:/tmp/example/exec]$ ./dist/build/Executable/Executable
> "Library version 3"
>
> !!!!!
>
> OK, very weird. Now it seems that no matter what I change, what ‘exec’
> is somehow using is whatever the last version of Library was when I last
> configure and built it. Why? Why oh why? I don't want to clobber my
> dist/ in Library because rebuilding the whole thing might be a pain but
> I'm pretty sure that it sure as hell shouldn't matter whether I ran
> configure+build for other projects that use it so why does it? It seems
> insane to me.
>
> Here is my only guess at this: nix copies the lib directory to the store
> which at that stage contains ‘dist’. When it builds the package, the old
> ‘dist’ is still there and anything else is snow using results of that
> rather than results of the thing it just compiled. Am I correct? Who do
> I run to in order to have this corrected?
>
> I attach a tarball with the two nix projects I used in this example, it
> should be very easy to replicate. Unpack to /tmp due to hardcoded paths.
> It should be easy to replicate: run configure and build phases in lib,
> make change to source, go into exec, configure, build, run.
>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
I made a ticket.
https://github.com/NixOS/nixpkgs/issues/3112
--
Mateusz K.
_______________________________________________
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic