Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix install instructions are incorrect'ish #980

Open
peti opened this Issue Mar 2, 2019 · 28 comments

Comments

Projects
None yet
3 participants
@peti
Copy link
Contributor

peti commented Mar 2, 2019

https://hledger.org/download.html says that hledger ought to be installed with Nix by running

$ nix-env -iA nixpkgs.haskellPackages.hledger nixpkgs.haskellPackages.hledger-ui \
              nixpkgs.haskellPackages.hledger-web

That command is going to work most of the time, but sometimes it's not because not all installations have Nixpkgs under a nixpkgs prefix. Some use nixos instead. The proper way to specify that you're using a Nixpkgs package is nix-env -f "<nixpkgs>". Then these prefixes can be omitted.

Furthermore, hledger has top-level attributes that reference way fewer dependencies, i.e. these don't depend on ghc at run-time. So I'd recommend using:

$ nix-env -f "<nixpkgs>" -iA hledger hledger-ui hledger-web
@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 2, 2019

P.S.: The command

$ nix-env -i hledger hledger-ui hledger-web

is even simpler and achieves the same result. It's slower and less idiomatic, though. For our purposes it might actually be preferable, though.

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 2, 2019

Thanks! The last one looks great. How much slower ?

Related to nix, I wonder if any mac users know if #613 is resolved.

@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 2, 2019

Thanks! The last one looks great. How much slower ?

Depends on your hard drive / SSD / state of the cache. nix-env -i might run several seconds before it's ready to start installing anything. nix-env -iA does that almost instanteuously.

Related to nix, I wonder if any mac users know if #613 is resolved.

According to Hydra, hledger-ui compiles fine on Darwin.

simonmichael added a commit that referenced this issue Mar 2, 2019

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 2, 2019

Thanks. I've updated the download page with the simpler command.

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 2, 2019

It looked so simple I was inspired to try it. I didn't find nix in homebrew, but guessed that nix-env could be obtained from https://nixos.org/nix/, which worked. And now I can do:

$ nix-env -i hledger hledger-ui hledger-web 
installing 'hledger-1.13.2'
installing 'hledger-ui-1.13.1'
installing 'hledger-web-1.13'
...

I guess this will change to 1.14 before too long.

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 2, 2019

(And that makes sense, because the "nixpkgs unstable package" badge is still showing 1.13.2.)

@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 2, 2019

The 1.4 versions are building already: https://hydra.nixos.org/eval/1507546?filter=hledger&compare=1507440. The packages will show up in the nixpkgs-unstable channel within the next few hours (assuming those builds work properly).

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 2, 2019

End result: working hledger binaries on mac in less than a minute with only 319M used, in /nix. Very nice!

@peti peti closed this Mar 2, 2019

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 3, 2019

If I'm looking in the right place, I believe the 1.14 binaries built yesterday, but the command still seems to see only 1.13. Is there something we should add to force a refresh ?

@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 4, 2019

The command still seems to see only 1.13. Is there something we should add to force a refresh?

You'll need to run nix-channel --update. If you are on nixpkgs-unstable, then you'll have the new binaries already. https://howoldis.herokuapp.com/ has the current state of the various NixOS channels.

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 4, 2019

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 4, 2019

@peti, sorry for the stream of questions but the nix badges on the hledger download page, which we get from https://repology.org/project/hledger/badges seem not to be updating. Would you have any idea why ?

@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 5, 2019

Unfortunately, I don't know how that works. I trust it's going to be updated eventually, but I'm not sure how often that happens or what triggers it.

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 5, 2019

@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 5, 2019

I see that the badge is now up-to-date. :-)

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 5, 2019

Now we just need them to be green/red like the rest.

@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 9, 2019

I've noticed that the download instructions for Nix now say:

nix-channel --update && nix-env -i hledger hledger-ui hledger-web

I don't think that's a good idea. Many people don't follow any particular channel but rather check out Nixpkgs from Github, so running nix-channel makes no sense for them. Furthermore, many people follow a channel that will not receive any updates of hledger this way, like the stable release channels for example. Last but not least, it's certainly inconsistent that the Nix command includes a kind-of "update global package manager data" command in its instructions, but the instructions for ArchLinux, Debian, or Ubuntu do not, i.e. there is no apt update && ... anywhere in the page.

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 9, 2019

Thanks. There might be some inconsistency indeed. The goal on this page is to have a command that as reliably as possible installs the best hledger version available by that method, ie the hledger version advertised just to the right. In practical terms, my experience so far is that with cabal and nix-env, eg, I normally have to run an update command to get the advertised version. With some others, that's automatic (stack, docker) or semiautomatic (brew, which prints a helpful message). With linux distros, significant updates to the hledger packages are very infrequent, also it's likely that the user has done an update somewhat recently as part of system maintenance.

Obviously I'm a bit clueless about some of these platforms (which makes me a useful test subject). What are the potential bad consequences of running nix-channel --update ?

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 9, 2019

And more to the point, what's a better, still reasonably short, command that will get the best available version ?

@simonmichael simonmichael reopened this Mar 9, 2019

@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 10, 2019

I would not list any command other than nix-env -i hledger .... User's of Nix will know how to keep their package database up-to-date, and if they don't know then there's ample documentation available on the Nix website that explains them in great detail how to do it. It doesn't feel like a good idea to me to try and duplicate that information.

What are the potential bad consequences of running nix-channel --update?

I don't think that anything really bad can happen if you run that command. You may end up downloading and installing a new version of Nixpkgs, though, that the following nix-env -i ... command actually doesn't use, which would be a waste of resources. Arguably, people who have a setup like that will typically recognize on their own that the channel update is not useful to them and just won't run it. Still, say that running nix-channel --update is a necessary (or even recommended) step to take before installing hledger. It's inconsistent with the documentation relating to the other package managers and it's also somewhat technically inaccurate.

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 10, 2019

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 10, 2019

Would specifying the versions be enough, as with cabal-install ? Eg

nix-env -i hledger-1.14.1 hledger-ui-1.14 hledger-web-1.14

It seems to work right now, but I'm guessing it might fail if I hadn't done the channel update first.

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 14, 2019

Wanting to educate myself about Nix, I spent some time reading docs and chatting in #nixos today. I thought we had a winner:

nix-env -f channel:nixos-unstable -iA hledger hledger-ui hledger-web

But testing, I found that this and the previous variants were doing an awful lot of building from source and taking up 3.6G unpacked, unlike before. It seems the nix [darwin] hledger builds broke right after that due to a blaze-builder issue. And I guess a transient breakage like this can transform a normally quick install command into a disk-filling build monster. I imagine this happens pretty often, and it would be a poor install experience for non-experts.

Two solutions were mentioned:

  • use a pinned known-good version, eg the first successful build after a hledger release. Once installed, users would have to take some special steps to update it:

     nix-env -f https://github.com/NixOS/nixpkgs/archive/GITREV.tar.gz -iA hledger hledger-ui hledger-web
    
  • add a default.nix to the project, upload our own official builds to cachix.org, and use:

     nix-env -f https://github.com/simonmichael/hledger/archive/master.tar.gz -iA hledger hledger-ui hledger-web
    

If not one of these, I think we'd need some advice about this issue on the download page. Eg recommend trying --dry-run first, and if the size is abnormally large wait for build to be fixed.. a link or badge showing accurate unstable build status.. etc.

simonmichael added a commit that referenced this issue Mar 15, 2019

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 15, 2019

Today I've made these changes at https://hledger.org/download :

  • removed nix-channel --update as you suggested
  • added package version numbers. I am guessing these will cause it to fail until channel is updated, which will be an improvement. The command implies use of nixpkgs-unstable now.
  • added notes about nix-channel --update and the large downloads issue.
@Infinisil

This comment has been minimized.

Copy link

Infinisil commented Mar 15, 2019

It's not a large download issue: Even with it being a large download, the build will just end up failing. The reason is that Nix unfortunately doesn't have any notion of cached failure, only successful builds are cached. Therefore I suggest rewording it to something like "Builds should be cached, unless in case of CI build issues, so check with --dry-run first".

simonmichael added a commit that referenced this issue Mar 15, 2019

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 15, 2019

Thanks!

@peti

This comment has been minimized.

Copy link
Contributor Author

peti commented Mar 15, 2019

@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Mar 15, 2019

Today I tried the pinned option. Since there has been one successful build of the desired hledger release, this works well, adding just 200M to /nix:

nix-env -iA hledger hledger-ui hledger-web -f https://github.com/NixOS/nixpkgs/archive/9c74e2.tar.gz

I'm not sure if there's any significant downside, so I'm tempted to show only this command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.