jaspervdj / patat

Terminal-based presentations using Pandoc
GNU General Public License v2.0
2.42k stars 60 forks source link

Any nix support? #65

Closed rpearce closed 4 years ago

rpearce commented 5 years ago

Hi, Jasper!

I've been using nix for a few months and was wondering if there is a way to use this through nixpkgs? I've received a message that it's marked as "broken"! I do see it listed here in this hackage2nix part of nixpkgs, https://github.com/NixOS/nixpkgs/blob/11f10b686e179603725be36c70ae7cc9695527e0/pkgs/development/haskell-modules/configuration-hackage2nix.yaml#L7532, but I don't know how relevant that is?

If it's not available there, do you think I should give it a go and try to get it working through nix?

Thanks for your work here! Robert

jaspervdj commented 5 years ago

Hi Robert! I would like to have this, but I'm not too experienced with nix. If you would like to add this, I would be very grateful. Please let me know if there's anything that would make it easier -- tweaks to the cabal file, etc.

rpearce commented 5 years ago

Sure thing! I've already converted my hakyll website to use nix (blog post will happen eventually... https://github.com/rpearce/robertwpearce.com/issues/34), so I'll give it a ago.

rpearce commented 5 years ago

@jaspervdj After giving this a good look, I think the reason that patat is listed as broken in this hackage2nix output (it's a big file), https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix, is because of a pandoc dependency issue stemming from this line in the cabal file. Here's the error:

Setup: Encountered missing dependencies:
pandoc >=2.0.4 && <2.7

I get that error when trying to build the project locally using the same "derivation", but the problem is solved if I use pandoc >= 2.0.4 && < 3, pandoc >= 2.0.4 && < 2.8 or even pandoc >= 2.0.4 && < 2.7.3 in patat's cabal file. I do not know why, but I think it has to do with pandoc versions that might be outdated on nixpkgs.


Is there a specific reason it's < 2.7, or can I make a PR to use one of these 👆 ?


This is a very similar issue on clay:

juliendehos commented 5 years ago

Hi, Nix has pandoc 2.7 but patat needs pandoc < 2.7. In fact, patat doesn't seem to need pandoc < 2.7 but that's what the cabal file says. So yes, just changing the corresponding line in the cabal file should make patat build with Nix. You can try that using a nix-shell:

$ nix-shell -p 'haskellPackages.patat.overrideDerivation (attrs: { preConfigure = "sed -i \"s/2.7/2.8/\" patat.cabal"; })'
these derivations will be built:
  /nix/store/21klgzw47m05r1gpg0jkama3ifg42k4w-patat-0.8.2.2.drv
building '/nix/store/21klgzw47m05r1gpg0jkama3ifg42k4w-patat-0.8.2.2.drv'...
...

[nix-shell]$ patat
patat v0.8.2.2

Usage: patat [FILENAME] [-w|--watch]
  Terminal-based presentations using Pandoc
...
rpearce commented 5 years ago

Cool! I'll open a PR

rpearce commented 5 years ago

https://github.com/jaspervdj/patat/pull/66 -- how does that look?

juliendehos commented 5 years ago

Seems good. Thanks. After the PR is merged, you may also update nixpkgs. I don't know how to do that but I guess we need to remove patat from the broken-packages section and add the new version in thedefault-package-overrides section, in https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/configuration-hackage2nix.yaml .

rpearce commented 5 years ago

This was merged; I'll see about that broken-packages bit when I get some free time.

rpearce commented 5 years ago

Looks like patat was removed from the broken list 5 days ago! https://github.com/NixOS/nixpkgs/commit/96ceff97da009d9605287e70cd20b04409ea30c6#diff-d9687f7c9d1aceca689b0868d33211eeL7598

jaspervdj commented 5 years ago

Thanks for fixing @rpearce!

rpearce commented 5 years ago

Anybody know why this ended up back on the broken packages list in this commit? https://github.com/NixOS/nixpkgs/commit/4a8831e38b307e80051757ab04e4e391f5bab97b#diff-d9687f7c9d1aceca689b0868d33211eeR7470

jaspervdj commented 5 years ago

Urgh, that's frustrating! I have no idea how that happened. Let me know if there's anything I should fix from my side.

rpearce commented 5 years ago

Thanks! I've asked about it and will see if there are further problems that might need some fixing.

This might be annoying, but I promise that https://nixos.org is cool!

rpearce commented 5 years ago

Here's the current error:

Setup: Encountered missing dependencies:
skylighting >=0.1 && <0.8.2

I've reopened the issue until I can see about resolving this!

Failed hydra build results for patat: https://hydra.nixos.org/job/nixpkgs/haskell-updates/haskellPackages.patat.x86_64-linux

rpearce commented 5 years ago

Hey, everyone, here is my comment from the PR I've just opened. Any guidance would be helpful:

While I'm not an expert on nixpkgs yet, I've got a feeling that lines like https://github.com/NixOS/nixpkgs/blob/208aad46916d97b5c2a094f630edb7e470254be8/pkgs/development/haskell-modules/configuration-hackage2nix.yaml#L1939 are going to be a problem for continually working with this project, for I believe nixpkgs uses the latest & greatest versions of things.

In this instance, skylighting was set to be < 0.8.2 for the upper version bound, but if 0.8.2 is what nixpkgs only has 0.8.2, then it'll fail to build.

I wonder how other projects handle this? This feels like it shouldn't be this way...

juliendehos commented 5 years ago

Hi, Thanks for the PR. Setting a maximal version is not mandatory. Sometimes it may be simpler to just set the minimal version that we need for the dependency.

jaspervdj commented 5 years ago

Right, it seems unnecessary to restrict skylighting to a minor version like that -- let me do a bump.

jaspervdj commented 5 years ago

I've uploaded patat-v0.8.2.4 which should fix this. @juliendehos @rpearce thanks for the pointers!