2mol / pboy

a small .pdf management tool with a command-line UI
BSD 3-Clause "New" or "Revised" License
737 stars 24 forks source link

Current master fails to build with nix #12

Closed mgttlinger closed 6 years ago

mgttlinger commented 6 years ago

The current master 36e76b4 fails to compile with nix

system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.0.4, channels(merlin): "", channels(root): "nixos-18.03, nixos-unstable-18.03pre123130.1bc288591ea", nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
[1 of 3] Compiling Config           ( src/Config.hs, dist/build/Config.o )

src/Config.hs:78:20: error:
    Not in scope: type constructor or class ‘Toml.Table’
    Module ‘Text.Toml’ does not export ‘Table’.
   |
78 | getConfigHelper :: Toml.Table -> Maybe Config
   |                    ^^^^^^^^^^

src/Config.hs:81:10: error:
    Not in scope: data constructor ‘Toml.VString’
    Module ‘Text.Toml’ does not export ‘VString’.
   |
81 |         (Toml.VString inb, Toml.VString lib, Toml.VBoolean mov) ->
   |          ^^^^^^^^^^^^

src/Config.hs:81:28: error:
    Not in scope: data constructor ‘Toml.VString’
    Module ‘Text.Toml’ does not export ‘VString’.
   |
81 |         (Toml.VString inb, Toml.VString lib, Toml.VBoolean mov) ->
   |                            ^^^^^^^^^^^^

src/Config.hs:81:46: error:
    Not in scope: data constructor ‘Toml.VBoolean’
    Module ‘Text.Toml’ does not export ‘VBoolean’.
   |
81 |         (Toml.VString inb, Toml.VString lib, Toml.VBoolean mov) ->
   |                                              ^^^^^^^^^^^^^

I suspect that a wrong version of htoml-megaparsec gets used but it is not clear to me which is the intended version.

mgttlinger commented 6 years ago

Ok, so it requires htoml-megaparsec-2.0.0.1 but the nix build chooses to use htoml-megaparsec-1.1.0.1

mgttlinger commented 6 years ago

The unstable channel has the correct version of the dependency but it is not obvious to me how to switch the build to unstable.

2mol commented 6 years ago

Thanks for raising! Yup, htoml-megaparsec-2.0.0.1 is the required version. It is specified in the extra-deps of the stack.yaml file, but I remember something about nix not using that. Curiously enough it worked without a hitch on CI and on my linux machine. I'll have to talk to my more nix-knowledged friends to understand how it chooses its versions.

By the way, feel free to chime in if you have opinions about pinning the nix version or any other ideas that would make this more robust.

mgttlinger commented 6 years ago

I don't think there is a way to do that in your current build setup. To elaborate on how it chooses the version: Nix generally has one version in the channel that is the version and given that the names of the specific version derivations might differ cabal2nix uses the standard version and ignores the version constraints.

2mol commented 6 years ago

I apologize for my lack of nix knowledge. I didn't use cabal2nix. Here's how you could help me:

  1. Is the above the output of nix-build?
  2. How can I find out in which sense our nix setups differ? For example I am also on nix version 2.0.4

Funnily enough my nix-build seems to use htoml-megaparsec-2.0.0.0.

mgttlinger commented 6 years ago

You do use cabal2Nix: https://github.com/2mol/pboy/blob/master/pboy.nix#L8

  1. Yes, it is the output of nix-build (at least the interesting part of it).
  2. The nix version is not what determines the library versions but the channel you use. I'm using the nixos-18.03 stable channel and I would guess you use the unstable one. You can check that with nix-channel --list (You might need to run that with sudo depending if you have those channels user specific or global).
2mol commented 6 years ago

Oh, oops, sorry for the misinformation, that's what I get for taking credit for my friend's work :)

Yes, turns out I am using the unstable channel! I'm surprised that was the default.

What you can do in the meantime is check out the commit just before I updated to that new version, so 01737076826ca8f6fb997666e78f5baf4fca7145

mgttlinger commented 6 years ago

I think many people use the unstable channel to have the bleeding edge of versions.

I think I will just build with stack --nix until the stable channel advances.

2mol commented 6 years ago

It will work now, if you want to test it, you can either pull the latest dev branch and try a nix-build, or do

nix-env -if https://github.com/2mol/pboy/tarball/dev

Let me know if it works for you. Cheers.

mgttlinger commented 6 years ago

Ok, so master obviously still fails to build with nix but I tested your changes in dev and they build and install successfully. So your fix is basically to pull a different nix package tree for your build?

2mol commented 6 years ago

Great to hear! Yes, so basically it fixes the nixpkgs to be a specific commit in NixOS/nixpkgs.

I'll close this as soon as I merge dev into master then. Thanks for testing!

mgttlinger commented 6 years ago

You're welcome. Thanks for fixing!

2mol commented 6 years ago

fixed by e56c0076ff2adad8ed34cdf5a9e029b5e65fbb2b