7 ms·
You can do version pinning with flakes: https://nixos.wiki/wiki/Flakes https://nixos.wiki/wiki/Flakes
by ducktective 5y ago
You can do version pinning with flakes:
https://nixos.wiki/wiki/Flakes https://nixos.wiki/wiki/Flakes
- dmitriid 5y ago> You can do version pinning with flakes: https://nixos.wiki/wiki/Flakes https://nixos.wiki/wiki/Flakes 1. How? You'd think such a simple thing, especially in the context of "ditch version managers" would be easy and warrant at least an example. So far I've had: - ignoring the question or avoiding the answer - one answer "just use overlays" with no example - one answer "just use flakes" with no example 2. It's a separate, unstable feature It amazes me that after 18 years, you still need (probably? no idea) to use some entirely separate feature that is still unstable/experimental and uses an entirely different system of describing what's needed than nix proper. And still no answer how to do the thing that is literally required for every single reproducible build: pin a tool to a specific version. Meanwhile tools that we're supposed to ditch are as simple as rvm install 2.1.1 rvm use 2.1.1
- ducktective 5y agoLooks like you are right. Relevant issue: https://github.com/NixOS/nixpkgs/issues/93327 https://github.com/NixOS/nixpkgs/issues/93327
- dmitriid 5y agoIt amazes me how many people in that thread keep saying that we shouldn't even want it, that this is not what nix is about, that no one should install historical versions etc. BTW, another issues linked is from 2015 https://github.com/NixOS/nixpkgs/issues/9682 https://github.com/NixOS/nixpkgs/issues/9682 Given that my question never got an answer in HN (not until I had a discussion with the original article's author on Twitter and he posted this solution), it's clear that: - this issue still exists - how to do this is still not properly documented - no one really knows how to do it in nix - this extremely common functionality that is literally required for actual reproducible builds is entirely glossed over in all the articles praising nix
- ducktective 5y agoLink to the thread for other people: https://nitter.net/dmitriid/status/1439957729909559298#m https://nitter.net/dmitriid/status/1439957729909559298#m Ju (@Arkham) proposed a solution: 1- Finding the commit hash of of nixpkgs which contains a specific version of a dependency (e.g. ruby 2.6.3) and use that to bring in the dependency 2- If a specific version does not exist in any of the hashes, we should patch the `.nix` file and build the dependency ourselves. This causes all other transitive dependencies to be rebuilt. Arguments against 1: Why should we rely on an external thrid-party webservice to find the hashes of a specific package? This should be integrated to the `nix` tooling. Hope the community incorporates history search into the tooling :) Arguments against 2: @dimitriid says the solution is cumbersome. Arguments for 2: - What if rvm or nvm don't have a specific version or deprecate that version from their repos? At least there is a solution via Nix. - What are you going to do for other languages which don't have a package/VM manager like Java, C/C++, etc? At least the Nix solution is universal and you don't have to learn the tooling of every technology. I think @technomancy over at Lobste.rs has a wise take on this issue: https://lobste.rs/s/emyfhx/ditch_your_version_manager#c_5acgpf https://lobste.rs/s/emyfhx/ditch_your_version_manager#c_5acg... > I feel like Nix/Guix vs Docker is like … do you want the right idea with not-enough-polish-applied, or do you want the wrong idea with way-too-much-polish-applied?
- dmitriid 5y ago> Arguments for 2: > - What if rvm or nvm don't have a specific version Let's get back to reality for a second. For most development needs this is a hypothetical situation. Right now, in reality, ruby-lang hosts versions dating to 2002. Also, right now, in reality nix limits the number of available versions. Quote: "in NixPkgs we choose to restrict the number of maintained versions", https://github.com/NixOS/nixpkgs/issues/93327#issuecomment-661986395 https://github.com/NixOS/nixpkgs/issues/93327#issuecomment-6... So it's already worse than the hypothetical "what if rvm don't have a specific version". Also, right now, in reality there's no easy way to pin a version of a tool in nix. Except going to a third-party website (lazamar's site), hope that your specific version is listed there (he only maintains a snapshot of a few years), and dig through nixpckg commit hashes. And this has been a known issue for as long as nix has been around. 18 years, at least. And we're still hoping that someone somewhere will incorporate this into standard tooling. You yourself linked to an issue on this. I'd like to link to a reply in that issue: https://github.com/NixOS/nixpkgs/issues/93327#issuecomment-661960469 https://github.com/NixOS/nixpkgs/issues/93327#issuecomment-6... And to this reply: https://github.com/NixOS/nixpkgs/issues/93327#issuecomment-778546569 https://github.com/NixOS/nixpkgs/issues/93327#issuecomment-7... > What are you going to do for other languages which don't have a package/VM manager like Java, C/C++, etc? That varies between languages, of course. I have several Java versions installed side-by-side. C/C++ is worse because they are mostly stuck in 1960s, tooling-wise (though on windows you can have multiple msvcrt versions installed side-by-side). This still can be (and is) handled. And nix doesn't offer great advantages, except providing a complex, complicated, poorly documented tool.
- Arkh4m 5y agoHere's an example https://gist.github.com/Arkham/31297c1d75fc59f723a50063bc0f5739 https://gist.github.com/Arkham/31297c1d75fc59f723a50063bc0f5... I used this tool to find the specific nixpkgs version https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=ruby https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable...
- ducktective 5y agoThanks. What if we want `ruby 2.3.1` not in any nixpkgs channel?
- Arkh4m 5y agoThen you'd have to learn to read Nix expressions. The original expression that builds all ruby versions is here: https://github.com/NixOS/nixpkgs/blob/6120ac5cd201f6cb593d1b80e861be0342495be9/pkgs/development/interpreters/ruby/default.nix https://github.com/NixOS/nixpkgs/blob/6120ac5cd201f6cb593d1b... Here's an example that shows how to build a customized version for NodeJS https://www.breakds.org/post/nix-shell-for-nodejs https://www.breakds.org/post/nix-shell-for-nodejs
- dmitriid 5y agoWe had this discussion on twitter, so we probably shouldn't repeat it here :) But more-or-less this is a takeaway: https://news.ycombinator.com/item?id=28602561 https://news.ycombinator.com/item?id=28602561
- zepolen 5y agoI'm not on the nix train but this affects rvm too if a particular version isn't available.
- dmitriid 5y agoI wish people stopped coming up with hypotheticals and focused on reality: https://news.ycombinator.com/item?id=28603631 https://news.ycombinator.com/item?id=28603631