Patch hash missmatches when updating to nixos 23.05

Hi, for some reason when I change my nixpkgs url to nixos-23.05 I am getting hash missmatch error for my dwm, st and dmenu builds. The hashes of each patch are the ones returned by nix-prefetch-url and I am successfully able to manually build packages by downloading tarball and applying patches manually but when I try to do rebuild I get hash missmathes with each rebuild pointing to different patch hash being wrong and the original hash not even being correct one. Commenting out patches makes build pass successfully. Removing my getpatch and using plain fetchpatch does nothing.

Errors returned

building the system configuration...
warning: Git tree '/home/ivan/.config/dotfiles' is dirty
error: hash mismatch in fixed-output derivation '/nix/store/f1kxcny0pawhimvfywm1ri25kq8bfzgb-dwm-restartsig-20180523-6.2.diff.drv':
         specified: sha256-x08vQdpVKwyGKd25/se0CgNVgQQc8ZjYGkPUsWt0L2k=
            got:    sha256-OEvtUpbXZrAC/jlcjxigfCQIGYTnr9kFnXOUi7Xzc2k=
error: 1 dependencies of derivation '/nix/store/4wsp1z6a7s45ydxbyscf99pjbjr0gnb6-dwm-6.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/al0l5k1kw565c0j1ms9pn54jirz94c9g-man-paths.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qkws6s6spyx17jc98vv1mnd2cmg9dhxw-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/g888imi31hsl3giwb8sw56zh6ndlvvy0-nixos-system-nixos-23.05.20230604.e7603eb.drv' failed to build
building the system configuration...
warning: Git tree '/home/ivan/.config/dotfiles' is dirty
error: hash mismatch in fixed-output derivation '/nix/store/m9dd1aw41zl41s1g6xi5rbvy7mvd02is-st-anysize-20220718-baa9357.diff.drv':
         specified: sha256-eO8MEPRb3uaCTtBznG+LaojXqlcj4eT422rQgpxopfo=
            got:    sha256-yx9VSwmPACx3EN3CAdQkxeoJKJxQ6ziC9tpBcoWuWHc=
error: 1 dependencies of derivation '/nix/store/wbg6b9icjw9zh4inard3nflpapmlcisw-st-0.9.drv' failed to build
error: 1 dependencies of derivation '/nix/store/al0l5k1kw565c0j1ms9pn54jirz94c9g-man-paths.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qkws6s6spyx17jc98vv1mnd2cmg9dhxw-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/g888imi31hsl3giwb8sw56zh6ndlvvy0-nixos-system-nixos-23.05.20230604.e7603eb.drv' failed to build
building the system configuration...
warning: Git tree '/home/ivan/.config/dotfiles' is dirty
error: hash mismatch in fixed-output derivation '/nix/store/zf805i65vvplbw19vfhzgxfz3vqdfw92-dwm-noborderfloatingfix-6.2.diff.drv':
         specified: sha256-osxrOsizPhOpQ1a+tDPMbmKsjvA+FMC8ZwbfiINnnYQ=
            got:    sha256-CrKItgReKz3G0mEPYiqCHW3xHl6A3oZ0YiQ4oI9KXSw=
error: 1 dependencies of derivation '/nix/store/4wsp1z6a7s45ydxbyscf99pjbjr0gnb6-dwm-6.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/al0l5k1kw565c0j1ms9pn54jirz94c9g-man-paths.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qkws6s6spyx17jc98vv1mnd2cmg9dhxw-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/g888imi31hsl3giwb8sw56zh6ndlvvy0-nixos-system-nixos-23.05.20230604.e7603eb.drv' failed to build

The custom packages are:

dwm

# ../packages/dwm.nix
{ dwm, fetchpatch }:
dwm.override {
  patches = let
    getpatch = path: sha256:
      fetchpatch {
          inherit sha256;
          url = "https://dwm.suckless.org/patches/${path}";
        };
  in [
    # Hide borders when single window is visible
    (getpatch
      "noborder/dwm-noborderfloatingfix-6.2.diff"
      "114xcy1qipq6cyyc051yy27aqqkfrhrv9gjn8fli6gmkr0x6pk52")
    # Allow restarting dwm
    (getpatch
      "restartsig/dwm-restartsig-20180523-6.2.diff"
      "0s9gfimv3m233bc9iw8w0j0ma0qank3zxffx5630qasmv90jyky7")
    # Proper full screen that hides bar
    (getpatch
      "actualfullscreen/dwm-actualfullscreen-20211013-cb3f58a.diff"
      "0882k8w6651c18ina0245b558f1bvqydcycw07lp711hpbg7f9gv")
    # Focus on net active is used in emacs to control frames and by emacs-everywhere
    (getpatch
      "focusonnetactive/dwm-focusonnetactive-6.2.diff"
      "1yznv9mpyjjrhhh42jvi8m8vq6c9shiyzshigrcjwf0c13l9d87w")
    # Font, colors and keybindings
    ../patches/dwm/config.def.h.diff
  ];
}

dmenu

# packages/dmenu.nix
{ dmenu, gawk, fetchurl, fetchpatch }:
dmenu.overrideAttrs (oldAttrs:
  let
    dmenu_run_history = fetchurl {
      url = "http://tools.suckless.org/dmenu/scripts/dmenu_run_with_command_history/dmenu_run_history";
      sha256 = "02fz6i391f6c1f39p0r8p37rbfqfsj3m0w0ylzv857w0w4ibhsp4";
    };
  in rec {
    patches = let
      getpatch = path: sha256:
        fetchpatch {
          inherit sha256;
          url = "https://tools.suckless.org/dmenu/patches/${path}";
        };
    in [
      # Fuzzy matching
      (getpatch
        "fuzzymatch/dmenu-fuzzymatch-4.9.diff"
        "0yababzi655mhpgixzgbca2hjckj16ykzj626zy4i0sirmcyg8fr")
      # Allow adjusting line height
      (getpatch
        "line-height/dmenu-lineheight-5.2.diff"
        "0jabb2ycfn3xw0k2d2rv7nyas5cwjr6zvwaffdn9jawh62c50qy5")
      # Show number of total/matched results
      (getpatch
        "numbers/dmenu-numbers-20220512-28fb3e2.diff"
        "0b3xpky2xkfs7s466dbjrqyw5n9wnk1cca18iw1zbp7mwrp2cw3m")
      # Font, and line height
      ../patches/dmenu/config.def.h.diff
    ];
    # dmenu run with history does not need dmenu_path - remove it
    # Moved sed replacement from postPatch to postInstall since postPatch
    # is run before postInstall and updated dmenu_run is not yet available.
    # There has to be a nicer way to do this but I am too lazy to figure it and
    # this just works
    postPatch = null;
    postInstall = ''
      cp ${dmenu_run_history} $out/bin/dmenu_run
      sed -ri -e 's!\<(dmenu|stest)\>!'"$out/bin"'/&!g' $out/bin/dmenu_run
      sed -ri -e 's!\<(awk)\>!'"${gawk}/bin"'/&!g' $out/bin/dmenu_run
      rm $out/bin/dmenu_path
    '';
  })

st

# packages/st.nix
{ st, fetchpatch }:
st.override {
# st.overrideAttrs (_: rec {
  patches = let
    getpatch = path: sha256:
      fetchpatch {
          inherit sha256;
          url = "https://st.suckless.org/patches/${path}";
        };
  in [
    # Anysize to work properly with tiling WM's that respect hints
    (getpatch
      "anysize/st-anysize-20220718-baa9357.diff"
      "1ym5d2f85l3avgwf9q93aymdg23aidprqwyh9s1fdpjvyh80rvvq")
    # Bold is not bright
    (getpatch
      "bold-is-not-bright/st-bold-is-not-bright-20190127-3be4cf1.diff"
      "1cpap2jz80n90izhq5fdv2cvg29hj6bhhvjxk40zkskwmjn6k49j")
    # Scrollback with additions to allow scrolling with just mouse wheel
    (getpatch
      "scrollback/st-scrollback-20210507-4536f46.diff"
      "072icbmj7my4c134d5apqw7v9q88vcrp6v6gdzf3668dzpkz9n0r")
    (getpatch
      "scrollback/st-scrollback-mouse-20220127-2c5edf2.diff"
      "0xjg9gyd3ag68srhs7fsjs8yp8sp2srhmjq7699i207bpz6rpb26")
    (getpatch
      "scrollback/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff"
      "078hk7k5i0vc2x4dyb65dxd5ykr32pz4f4j6h0f7pm8j7xl1fbwg")
    # Font, colors and keybindings
    ../patches/st/config.def.h.diff
  ];
}
1 Like

Booted old generation and tried updating to latest 22.05 version and I am getting same errors with it.

Tried running nix develop (with latest 22.05 hashes that don’t rebuild) on these packages and getting same error with obscure hashes. Tried removing some of patches and result is that

  • on dwm removing noborderfloatingfix and restartsig removes error
  • on st removing anysize and all scrollback patches removes error
  • dmenu just works
1 Like

Changing hashes to the ones that were returned with error fixed it, should have done it first thing instead of overthinking it. Weird that nix-prefetch-url does no return same hash as fetchpatch and that for some reason hash returned in error is different from the one provided in the file. Not sure if this is a nix issue or nixpkgs issue and where I should report this or is this considered to be an issue in the first place.

2 Likes

Maybe they regenerated the patches files. A patch file could be still used even if the offsets aren’t valid anymore, sometimes they got re-generated by using the correct line numbers. Initially I thought your patches were local, but it seems not.

1 Like

That was my first guess as well, but patches were not changed.

After rebooting old hashes work… I think what is happening is that because I use nix-prefetch-url to get hashes for patches and it adds file to the store nix was just using that file, and when updating to new release for some reason that old file was not being used which broke package definition.
The hash returned by nix-prefetch-url and hash that is fetched by nix seem to be diffirent i.e. using

nix-prefetch-url 'https://st.suckless.org/patches/anysize/st-anysize-20220718-baa9357.diff'

vs

hashFile "sha256" (fetchpatch { sha256 = ""; url = "https://st.suckless.org/patches/anysize/st-anysize-20220718-baa9357.diff"; })`

return different hashes which I think is the cause of hash missmatches here.

1 Like

Looking at source of fetchpatch it normalizes and filters patch. No idea what either does but that should change output hash in theory which explains why hash is different from plain nix-prefetch-url with it.

1 Like