DRY musings: how to declare multiple versions of a same software?

Hello, people!

Pratical case: I want to include the master branch of Zig compiler along with the current release and also some past releases. This is because there is some code out there that depends of an older release of Zig (sometimes a tutorial or a project like The Algorithms), and also there is code that depends on the master branch (experimental OS kernels).

How can I do this in an idiomatic way in Nix/Nixpkgs?

I want to do this following a structure like this:

`-- generic.nix 
`-- unstable.nix
`-- default.nix
`-- 0.6.nix
`-- 0.5.nix

The “generic” would be a function that accepts a source description of some Zig version (to fill the fecthXYZ functions and other parameters) along with the traditional inputs, and the other files would be especialized applications of the generic.nix file.

Even if this suggestion does not go in the Zig especifically, I want to know at least that particular solution, just for the sake of knowledge.

1 Like

The Erlang and Elixir packaging both do this to offer access to multiple releases of each language’s tooling. It’s also something of an mildly interesting example, given that there’s a matrix of compatibility between Erlang VM and Elixir releases and you might want to vary one or both in our own projects. Here’s a poorly-ordered list of files to poke through for inspiration, and apologies if you were already aware of them or similar patterns:

TL;DR - you can then reference these via attributes such as beam.packages.erlangR23.elixir_1_10.