|
|
|
|
|
by JamesSwift
89 days ago
|
|
You still are pinning to exact versions of packages (and in fact are pinning to specific shas / content hashes of the packages) but you are doing so implicitly by going this "path of least resistance". The only thing that will change what _exact sha_ you are pointed at is an explicit update by someone. There is no risk of someone running install on one box and someone running it on another and them getting different _exact versions_ (or likewise, in CI it also will be the exact same). And in general thats what people are trying to achieve on teams by pinning to full semver. So thats what I mean by its generally not needed on nix. However, to actually address your question it would be something like this (with ruby also added for comparison of whats possible depending on the language ecosystem you are using) ```devenv.yaml```
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
nixpkgs-node:
url: github:nixos/nixpkgs?rev=9c0e2056b3c16190aafe67e4d29e530fc1f8c7c7
nixpkgs-ruby:
url: github:bobvanderlinden/nixpkgs-ruby
inputs:
nixpkgs:
follows: nixpkgs
```devenv.nix```
{ inputs, pkgs, ... }
{
languages.javascript = {
enable = true;
package = inputs.nixpkgs-node.nodejs_24;
};
languages.ruby = {
enable = true;
versionfile = ./.ruby-version;
// alternatively
// version = "3.2.4";
};
}
|
|
Pinning by version number isn’t a crutch; it’s more a question of mental models. Most people find it more intuitive to identify a world by describing the things in it than to fix the states of the things by identifying the world where they have those states. Nix sometimes feels as if someone read Kripke and missed the passage about possible worlds being a figure of speech.
In other words, many of us don’t think that version numbers are a crutch to be used in the absence of a totalizing hash of the entire state of the universe. We actually think that version numbers are, for many practical purposes, better than that.