Skip to content

nixify project

Joël Schwab requested to merge nix into master

This change enables the following ways to interact with this project:

interactive project development shell with nix-shell

If you have nix, you get a shell in an environment with all dependencies set up by running

nix-shell

in this project's top-level directory. You can then e.g. run pytest on the project or start a python session, where gitlab_time_report as well as any dependencies can be imported and used.

I've also included poetry itself, but haven't yet tried to what extent it's usable like that.

fully automatic development environment with lorri and dirvenv

If you also have lorri and direnv working, simply run

direnv enable

once in this project's top-level directory. From then on, most features of the nix-shell environment above will be available without having to explicitly launch nix-shell: Simply cd into the project.

control pinned versions with niv

E.g., use

nix run nixpkgs.niv -c niv update

to update the nixpkgs and poetry2nix versions used by the above. (There's no need to permanently install niv for that. While the versions were pinned using niv, niv itself is not needed to use them.)

Alternatively, nix/sources.json can be modified manually. There should be no need to modify nix/sources.nix.

motivation

Getting this project usable on NixOS using was non-trivial for me: Just using poetry naïvely lead to matplotlib not finding some of this native library (C++ I believe) dependencies at runtime. Simply listing those to the buildInputs of shell.nix didn't resolve that issue.

Thus I decided to try poetry2nix, but I had to tinker around to get that working. To achieve reproducible results across systems and time, I decided to pin the nixpkgs version. To enable easy updating of the pinned version, I tried niv. niv init itself pinned the niv version. Also pinning the poetry2nix version seemed prudent.

caveat

Despite all the version pinning, this does work on nixos-unstable, but not on nixos-20.03 where the build of one of the dependencies fails. As I believe all other relevant things to be pinned, I guess it's a difference in the nix version.

Edited by Joël Schwab

Merge request reports