Nix flake of Nim-lang packages

https://git.sr.ht/~ehmry/nimble_flake

I’ve created a flake repository containing expresssion for all Nimble (the Nim package manger) packages. I’m not familiar with the various *2nix utilities within Nixpkgs so I did a naive implementation of what I thought best fit the Nix flake model.

Any comments or reviews are appreciated. The plan is to make this repository part a of larger flake-based project, but I want to handle Nim packaging in the general case.

To give an overview, the flake packages are every package in the Nimble registry for a given snapshot as well as the Nim compiler (also in Nixpkgs). Package metadata is commited to the repository as per-package JSON files, these files contain fixed-output hashes for each tagged version of the Nimble package sources. The repository is updated by entering the local dev-shell and invoking make.

Packages are built by evaulating an intermediate derivation generated from metadata inside each upstream Nimble repository. This step collects cross-Nimble dependencies but can also collect dependencies from Nixpkgs (example). The former works well, but the later requires that nixpkgs-specific names are commited to upstream metadata.

If this model works, I would like to create similar flakes, perhaps for all of the MirageOS opam packages.

9 Likes

Very cool (although I didn’t look at this in depth, especially as I don’t use Nim myself)! Regarding your plan for opam packages, what is the reason for limiting this to MirageOS packages only?

I figure that some of the Mirage libraries are only useful within Mirage images, but if these libraries are in the opam registry, maybe it makes more sense to package all of opam together. Really I just need to look closely at opam2nix before I say anymore.

Also, this repository is now maintained by the Nix-community group, the canonical URL is GitHub - nix-community/flake-nimble: Nimble packages Nix flake [maintainer=?] (github:nix-community/flake-nimble).

1 Like

@ehmry I started playing last night with your mom flakes and noticed they are quite out-of-date. I was able to get the code updated and the latest nim & nimble now compile. However, running “nim c” on even the simplest file fails. It seems something is wrong with the compiled compiler. I tried using the Linux binaries and they work fine. I’ll open an issue on GitHub when I get a chance after work, just wanted to give you a heads up.

Hey, sorry, just noticed this.

FWIW @akavel has fixed up and updated the flakes, and the Nim compiler in nixpkgs is a much better state.

Thanks to @bandithedoge this repo now get updated automatically.

Note nimble now supports lock files so we should be able to make a function to build your project with Nix using it.