At work we use flakes to build and as I’m working my way through moving them to 24.11 I got to wondering if we’re using the channel we should be using.
Some info that might be useful:
- We almost exclusively build and deploy Docker images, and only for x86_64-linux.
- We use a mix of languages, the parts written in Haskell are the heaviest users of Nix.
- Our developers can choose to run Linux or Mac.
- None of our developers run NixOS; it’s a mix of Fedora, Ubuntu, Arch, … and MacOS.
After reading Which channel branch should I use? I’m wondering how we should write the inputs of our flakes.
Until now we’ve used
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=24.05";
flake-utils.url = "github:numtide/flake-utils";
};
which I now realise isn’t that good. We probably should have preferred using a branch instead.
The link above says
- On Linux (including NixOS and WSL), use
nixos-*
- On macOS/Darwin, use
nixpkgs-*-darwin
and adds that
All of these “channel branches” follow the corresponding
release-*
So, now that I’m moving the flakes to 24.11, should I use
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=release-24.11";
flake-utils.url = "github:numtide/flake-utils";
};
or should I, to increase the likelihood of increasing cache hits when building the local dev shells, make nixpkgs
depend on the current system? Something like this (maybe not exactly like this, but hopefully my intention is clear)
inputs = {
nixpkgs.url = if builtins.currentSystem == "x86_64-linux" then
"github:nixos/nixpkgs?ref=nixos-24.11"
else
"github:nixos/nixpkgs?ref=nixpkgs-24.11-darwin";
flake-utils.url = "github:numtide/flake-utils";
};
Is there a recommendation on this at all? What do others that use Nix in similar ways do?