Shell.nix vs flake.nix for developing GnuCash

Hi there. Just created my first shell.nix for developing GnuCash. Guide at GitHub - christopherlam/gnucash-on-nix and shell.nix created via trial&error works well.

Any feedback appreciated, especially shell.nix vs flake.nix

2 Likes

There is an even simpler alternative, as gnucash is already packaged for NixOS.

git clone git@github.com:NixOS/nixpkgs.git
cd nixpkgs
nix-build -A gnucash

Have a look at the files under ./pkgs/applications/office/gnucash in the git checkout.

1 Like

To expand on @ngiger’s answer: You can be dropped into a development shell for each package in nixpkgs via:

nix-shell "<nixpkgs>" -A gnucash

Alternatively via flakes:

nix develop nixpkgs#gnucash
1 Like

Thanks for suggestions; it’s useful to know other forms.
Forgive my beginner questions.

  1. I find that a self-maintained shell.nix file will give me better control over the packages being used; e.g. I may want to try clang instead of gcc; or test with an older glib.
  2. The environment isn’t pure – it’s crucial to give me access to e.g. emacs and git; if I were to wish a pure environment, how do I specify this in/outside shell.nix?
  3. How would a flake.nix look like? What’s the main advantage over shell.nix? Docs don’t explicitly tell.

Ad 1. Actually you’ll get quite some flexibility without having to write a new expression. E.g. use

nix-shell -E 'with import <nixpkgs> { }; gnucash.override { stdenv = clang10Stdenv; }'

Of course you’re still free to just put the expression into a shell.nix such that you don’t need to type that much.
Ad 2. Not quite sure what you mean here. Have you compared nix-shell to nix-shell --pure?
Ad 3. There’s a couple benefits to using flakes. Easy pinning and updating. Nicer and more uniform UI with the nix command. The downsides are that flakes are not yet officially considered stable and that a flake.nix file forces a bit more fluff/verbosity on you.

1 Like