Problem
I use flakes everywhere nowadays, managing dependencies with flakes is easy. I just do nix flake lock --update-input
and things are updated. But sometimes I need to use fixed output derivations. For example:
rust-toolchain = fenix.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = lib.fakeSha256;
}
Because fenix fetches a manifest from internet, so I need to specify its sha256.
Or:
((vscode.override { isInsiders = true; }).overrideAttrs (oldAttrs: rec {
src = (builtins.fetchTarball {
url = "https://code.visualstudio.com/sha/download?build=insider&os=linux-x64";
sha256 = lib.fakeSha256;
});
}))
To get the latest vscode insider build.
If I want to update those, I need to edit the file to replace sha256 with fakeSha256
, run nix, and copy from error message to file. This is inconvenient, I want to just run a command like nix flake lock --update-input
and be done with it.
The solution?
The idea I came up with it to separate sha256s into a separate nix file that’s easy to search and replace, then have a script to do the steps to update them. Then I remembered niv
. And yeah, turns out niv
does support adding arbitrary URLs as dependencies, and I can get the sha256 from sources.nix
.
Problem is, niv
won’t update them. You see, niv
expects you to give it an URL template, when you update, you need to assign new values to variables in the template to generate a new URL for niv
to fetch. If the URL is fixed, niv
does nothing.
I opened a feature request for this, but since niv
is not actively maintained anymore, I doubt it will ever be implemented.
Request for help
So, how does everyone else do this? Is there a better way? Maybe flakes should support non-flake inputs?