by grep_name · 1y ago · 0 comments
A few weeks ago I needed to update firefox for a bug fix that was causing a crash, but of course that meant updating all of nixpkgs. When I finished the switch, the new version of pipewire was broken in some subtle way and I had to roll it back and have been dealing with firefox crashing once a week instead. I can't imagine pitching this to my team for development when I'm having this kind of avoidable issue just with regular packages that aren't even language dependencies.
To those who say 'if you want to lock your dependencies for a project, you can just build a nix flake from a locked file using the <rust | python | npm> tools' I say, why the hell would I want to do that? Being able to manage multiple ecosystems from the same configuration tool was half the draw of nix in the first place!
Now compare the above with how you would customize a version in other systems, like Debian with apt-pkgs ...
$ nix run nixpkgs#firefox -- --version
Mozilla Firefox 138.0.1
$ nix run github:nixos/nixpkgs/nixos-unstable#firefox -- --version
Mozilla Firefox 139.0.1
$ nix run github:nixos/nixpkgs/b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa#firefox -- --version
Mozilla Firefox 122.0.1
Or, if you want to actually incorporate it into your system, tell the system flake to pull whatever versions you want: {
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-b98a.url = "github:nixos/nixpkgs/b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa";
};
outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-b98a }: {
nixosConfigurations.yourmachinename = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
nixpkgs-unstable = import nixpkgs-unstable {
system = "x86_64-linux";
};
nixpkgs-b98a = import nixpkgs-b98a {
system = "x86_64-linux";
};
};
---snip---
and then when you pull packages say which one you want: packages = with pkgs; [
dillo # from stable nixpkgs
nixpkgs-unstable.firefox # from unstable
nixpkgs-b98a.whatever # from some exact commit of nixpkgs
]
I assume you could do the same thing for project-level flakes, but TBH I don't usually do that so I don't have the code to hand. (In contrast with grabbing system packages from whatever version of nixpkgs I want, which I know works because I pulled the example code from the config on the machine I'm typing this comment on.)Maybe we were holding it wrong, but, we ultimately made the call to move away for that reason (and more)