Making a derivation for a Hackage application

I’ve written an application in Haskell and published it on Hackage. It’s called pinboard-notes-backup, and I can run

nix-env -i -A nixpkgs.haskellPackages.pinboard-notes-backup

to install it. That works okay, but I would like to make it a little nicer by

  1. making it available in the “top-level” namespace (or whatever you call this)
  2. installing the man page that comes with the project
  3. installing the bash and zsh completion scripts that can be generated by passing special flags to the program

I’m getting stuck just on step 1. I tried adding the line

pinboard-notes-backup = haskell.lib.justStaticExecutables haskellPackages.pinboard-notes-backup;

to the middle of top-level/all-packages.nix, but if I try to run

nix-env -i -A nixpkgs.pinboard-notes-backup

then I get

error: attribute ‘pinboard-notes-backup’ in selection path ‘nixpkgs.pinboard-notes-backup’ not found

This package is not part of any Stackage snapshots; is that why this formulation in all-packages.nix isn’t working for my package even though it works for others? Assuming I don’t want to add the package to Stackage at the moment, what’s the best way to create a Nix derivation for the program?

If you’ve added your attribute to your local clone of nixpkgs, you can’t use nix-env like this.
You can see whether it works by running nix build -f . pinboard-notes-backup.
Then you can inspect the result symlink to see whether it includes all binaries and manpages that you expect.
To get a shell with that package installed, you can do: nix-shell -I nixpkgs=. -p pinboard-notes-backup

I’m no expert on the nixpkgs Haskell tools but it sounds like juststaticExecutables won’t keep the manpages.

Oh my gosh, I can’t believe I did this. This isn’t the first package I’ve developed, so trying to test with nix-env was just a brainfart, I guess.

Thank you for the pointer! I’m going to need to publish a new version on Hackage before I have a Nix derivation I’m happy with, but I should be able to publish this on Nixpkgs before too long.