Package version update has no effect

I am having issues updating a package on my local system. I have confiugred the NIX_PATH to point to a local nixpkgs git repository and updated the default.nix accordingly. Running nixos-rebuild switch --upgrade does not change the package version - I continue to have the original package. Any ideas why?

Could you show us your NIX_PATH value, the diff you are adding to
Nixpkgs and the name of the package you’re updating?

Thanks for your reply. Here are some details:

nixos-version
20.09.git.75d9ae0a47e (Nightingale)

git show

commit 75d9ae0a47eb52fcee4527b2db1a85524eebcf18 (HEAD → nixos-20.09)
Date: Fri Jan 29 18:04:27 2021 +0200
Adopting hplip from master
diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix
index c4b7962122c…a1517c99a4e 100644
— a/pkgs/misc/drivers/hplip/default.nix
+++ b/pkgs/misc/drivers/hplip/default.nix
@@ -2,7 +2,7 @@
, pkgconfig
, cups, zlib, libjpeg, libusb1, python3Packages, sane-backends
, dbus, file, ghostscript, usbutils
-, net-snmp, openssl, perl, nettools
+, net-snmp, openssl, perl, nettools, avahi
, bash, coreutils, utillinux
-name = “hplip-${version}”;
-version = “3.20.5”;
+pname = “hplip”;
+version = “3.20.11”;

…

Please tell me if the NIX_PATH is needed.

You must also update the ‘sha256’ fields, otherwise the old version will be taken from the cache based on that sha256 hash instead of fetching the new version from the network.

You can use nix-prefetch-url to get the sha256 hashes. In this case the first source is fetched via the sourceforge mirror, you can find the ‘actual’ url in nixpkgs/pkgs/build-support/fetchurl/mirrors.nix. So:

$ nix-prefetch-url "https://downloads.sourceforge.net/hplip/hplip-3.20.11.tar.gz"
[25.1 MiB DL]
path is '/nix/store/i8yaf2hifymhr8919ynirnmnzrfmrqk2-hplip-3.20.11.tar.gz'
04fvdyjyjbkviy3awgm7g43p3lrvrsmgaqz8bwra22g7v2rpa5hb
$ nix-prefetch-url "developers.hp.com/sites/default/files/hplip-3.20.11-plugin.run"
[11.0 MiB DL]
path is '/nix/store/iiw2qrbjlrxlr6kriapscx9f2kk4mk23-hplip-3.20.11-plugin.run'
1m0p0amsfh4hbrh0ysj4zvmfbi278c5ighi3r75d33az050yihxg

… the hashes would presumably be 04fvdyjyjbkviy3awgm7g43p3lrvrsmgaqz8bwra22g7v2rpa5hb and 1m0p0amsfh4hbrh0ysj4zvmfbi278c5ighi3r75d33az050yihxg.

Note that nixos-unstable is already at 3.20.11, so it might also be worth considering updating to that.

Thanks for the reply. I have updated the sha256 hashes previously just haven’t cited the whole change in my reply earlier. My system still points to the old version:

ls -l $(which hp-check)
lrwxrwxrwx 1 root root 69 Jan 1 1970 /home/kamen/.nix-profile/bin/hp-check → /nix/store/9g8mk7j8a1wjqrz7xciv8ack5p2ibhwq-hplip-3.20.5/bin/hp-check*

So are you sure, your NIX_PATH actually points to your modified nixpkgs?
You can check this faster than with nixos-rebuild by running
nix build nixpkgs.hplip and checking the resulting result symlink.

Also note that your environments might differ, depending wether you run
commands as root or as your normal user.

1 Like

nix build’s result points to the desired version. Aargh… So far I have set the NIX_PATH in a user’s profile yet I run nixos-rebuild with sudo as it doesn’t work otherwise. This is a single user machine, how would you recommend that I set it up with so that I can make changes in the repo and apply them?

But if the updates are running in a wrong environment why nixos-version shows the correct commit?

nixos-rebuild rebuilds your system profile. The path you’re getting from running hp-* commands contains .nix-profile, which is your user profile and is managed by nix-env. You may have installed a fixed build of HPLIP into your user profile at some point, with nix-env -i.

If you want HPLIP to “just work” system-wide and respect your Nixpkgs changes, then uninstall it from your user profile with nix-env -e hplip, ensure you have the following settings in your /etc/nixos/configuration.nix, and run nixos-rebuild if necessary:

environment.systemPackages = with pkgs; [ hplip ];
services.printing.enable = true;
services.printing.drivers = with pkgs; [ hplip ];

Or replace hplip with hplipWithPlugin if that’s the version you want.

1 Like

This is a single user machine, how would you recommend that I set it up with so that I can make changes in the repo and apply them?

When I used to use NIX_PATH, I set it systemwide with the NixOS option nix.nixPath.

But if the updates are running in a wrong environment why nixos-version shows the correct commit?

If nixos-version shows the right commit that’s a good indicator that the right Nixpkgs version was used. nixos-rebuild can’t run “in the wrong environment”, it either runs successfully or fails. Are you really sure that your modified Nixpkgs produces the right version of your package?