Build cargo nixpkg derivative with upstream code - Need learning pointers

The upstream version of GitHub - danyspin97/wpaperd: Wallpaper daemon for Wayland has features I like to have.

To build from the main branch I added this overlay (nixpkgs for reference https://github.com/NixOS/nixpkgs/blob/85f1ba3e51676fa8cc604a3d863d729026a6b8eb/pkgs/tools/wayland/wpaperd/default.nix)

 nixpkgs.overlays = [ 
    (self: super: {
      wpaperd = super.wpaperd.overrideAttrs (prev: {
        version = "git";
        src = pkgs.fetchFromGitHub {
          owner = "danyspin97";
          repo = "wpaperd";
          rev = "main";
          sha256 = "sha256-Ds0e1lFDydJxvgng4k9WnQL9v9e7Oas+30Cisw1dWoM=";
        };
      });
    })
  ];

results in

error: builder for '/nix/store/ig3xbk1nlx0z0i253yn3qa65xv149vgz-wpaperd-git.drv' failed with exit code 101;
       last 10 log lines:
       > Executing cargoBuildHook
       > ++ env CC_X86_64_UNKNOWN_LINUX_GNU=/nix/store/zlzz2z48s7ry0hkl55xiqp5a73b4mzrg-gcc-wrapper-12.3.0/bin/cc CXX_X86_64_UNKNOWN_LINUX_GNU=/nix/store/zlzz2z48s7ry0hkl55xiqp5a73b4mzrg-gcc-wrapper-12.3.0/bin/c++ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=/nix/store/zlzz2z48s7ry0hkl55xiqp5a73b4mzrg-gcc-wrapper-12.3.0/bin/cc CC_X86_64_UNKNOWN_LINUX_GNU=/nix/store/zlzz2z48s7ry0hkl55xiqp5a73b4mzrg-gcc-wrapper-12.3.0/bin/cc CXX_X86_64_UNKNOWN_LINUX_GNU=/nix/store/zlzz2z48s7ry0hkl55xiqp5a73b4mzrg-gcc-wrapper-12.3.0/bin/c++ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=/nix/store/zlzz2z48s7ry0hkl55xiqp5a73b4mzrg-gcc-wrapper-12.3.0/bin/cc CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu HOST_CC=/nix/store/zlzz2z48s7ry0hkl55xiqp5a73b4mzrg-gcc-wrapper-12.3.0/bin/cc HOST_CXX=/nix/store/zlzz2z48s7ry0hkl55xiqp5a73b4mzrg-gcc-wrapper-12.3.0/bin/c++ cargo build -j 48 --target x86_64-unknown-linux-gnu --frozen --profile release
       > warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
       > note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
       > note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
       > error: failed to select a version for the requirement `clap = "^4.3.1"`
       > candidate versions found which didn't match: 4.1.6, 2.34.0
       > location searched: directory source `/build/cargo-vendor-dir` (which is replacing registry `crates-io`)
       > required by package `wpaperctl v0.1.0 (/build/source/cli)`
       > perhaps a crate was updated and forgotten to be re-vendored?
       For full logs, run 'nix log /nix/store/ig3xbk1nlx0z0i253yn3qa65xv149vgz-wpaperd-git.drv'.

Ok, makes sense I guess. The code in main has no Cargo.lock file.

So I check that repo out and run cargo generate-lockfile.
And I set src = /home/tilli/git/wpaperd; instead of fetchFromGitHub.

       > warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
       > note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
       > note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
       > error: failed to select a version for the requirement `clap = "^4.3.1"`
       > candidate versions found which didn't match: 4.1.6, 2.34.0
       > location searched: directory source `/build/cargo-vendor-dir` (which is replacing registry `crates-io`)
       > required by package `wpaperctl v0.1.0 (/build/wpaperd/cli)`
       > perhaps a crate was updated and forgotten to be re-vendored?
       For full logs, run 'nix log /nix/store/qx0is1bh2s3vwwsz1xlar5k897rggidk-wpaperd-git.drv'.

Progress. But why isn’t it using the version I specified in the lockfile?

I have the suspicion that buildRustPackage will not fetch crates. And I suspect it has to do with this mysterious vendoring process.
I tried to run cargo vendor but that made no change.

Can someone hint me to the required magic? Nixpkgs 23.11 manual | Nix & NixOS would probably be sufficient hints, if I knew more about how cargo works… But it hasn’t clicked yet.

You also need to override other part. E.g. https://github.com/NixOS/nixpkgs/blob/85f1ba3e51676fa8cc604a3d863d729026a6b8eb/pkgs/tools/wayland/wpaperd/default.nix#L21.

I didn’t think that part was relevant, because I wanted the same functionality (except that hardcoded hash, but I will cross that bridge when it comes)

But I had a look again, turns out that path to the ./Cargo.lock is pointing to one in the nixpkgs repo! Not the upstream repo.

I will try to solve that…

Thanks @vccs for the hint. It lead me to understand and discover something.

I updated the postPatch and it’s using a Cargo.lock file paralell to my .nix file now.

  nixpkgs.overlays = [ 
    (self: super: {
      wpaperd = super.wpaperd.overrideAttrs (prev: {
        version = "git";
        src = pkgs.fetchFromGitHub {
          owner = "danyspin97";
          repo = "wpaperd";
          rev = "main";
          sha256 = "sha256-Ds0e1lFDydJxvgng4k9WnQL9v9e7Oas+30Cisw1dWoM=";
        };
        postPatch = ''
          rm Cargo.lock
          ln -s ${./Cargo.lock} Cargo.lock
        '';
      });
    })
  ];

That works, but it’s not happy about the cargo hashes. That makes sense, I expected that part.

error: builder for '/nix/store/5zz1hq7ryqjgajfgvcb02fgpp4fm3imq-wpaperd-git.drv' failed with exit code 1;
       last 10 log lines:
       > ERROR: cargoHash or cargoSha256 is out of date
       >
       > Cargo.lock is not the same in /build/cargo-vendor-dir
       >
       > To fix the issue:
       > 1. Set cargoHash/cargoSha256 to an empty string: `cargoHash = "";`
       > 2. Build the derivation and wait for it to fail with a hash mismatch
       > 3. Copy the "got: sha256-..." value back into the cargoHash field
       >    You should have: cargoHash = "sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=";
       >
       For full logs, run 'nix log /nix/store/5zz1hq7ryqjgajfgvcb02fgpp4fm3imq-wpaperd-git.drv'.

I followed the instructions and added empty strings as cargo hashes. And expected to be told what the hashes are.
But those never came.

cargoHash = "";
cargoSha256 = "";

I suspect the outputHashes in https://github.com/NixOS/nixpkgs/blob/85f1ba3e51676fa8cc604a3d863d729026a6b8eb/pkgs/tools/wayland/wpaperd/default.nix#L23 are a clue?

What is a cargoHash anyway? Is it a hash for every single dependency? If that is the case, why did the original package not need them?

nix log /nix/store/5zz1hq7ryqjgajfgvcb02fgpp4fm3imq-wpaperd-git.drv

Incomplete log
1593c1585
< checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7"
---
> checksum = "4c9afddd2cec1c0909f06b00ef33f94ab2cc0578c4a610aa208ddfec8aa2b43a"
1610c1602
< version = "1.0.50"
---
> version = "1.0.38"
1612c1604
< checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2"
---
> checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
1619c1611
< version = "1.0.50"
---
> version = "1.0.38"
1621c1613
< checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
---
> checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
1630c1622
< version = "0.7.8"
---
> version = "0.5.11"
1632c1624
< checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
---
> checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
1635,1637d1626
<  "serde_spanned",
<  "toml_datetime",
<  "toml_edit 0.19.15",
1642c1631
< version = "0.8.8"
---
> version = "0.7.2"
1644c1633
< checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35"
---
> checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6"
1649c1638
<  "toml_edit 0.21.0",
---
>  "toml_edit",
1654,1663c1643
< version = "0.6.5"
< source = "registry+https://github.com/rust-lang/crates.io-index"
< checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
< dependencies = [
<  "serde",
< ]
< 
< [[package]]
< name = "toml_edit"
< version = "0.19.15"
---
> version = "0.6.1"
1665c1645
< checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
---
> checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
1667d1646
<  "indexmap",
1669,1671d1647
<  "serde_spanned",
<  "toml_datetime",
<  "winnow",
1676c1652
< version = "0.21.0"
---
> version = "0.19.3"
1678c1654
< checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
---
> checksum = "5e6a7712b49e1775fb9a7b998de6635b299237f48b404dde71704f2e0e7f37e5"
1680a1657
>  "nom8",
1684d1660
<  "winnow",
1689c1665
< version = "0.9.9"
---
> version = "0.9.7"
1691c1667
< checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68"
---
> checksum = "09b01702b0fd0b3fadcf98e098780badda8742d4f4a7676615cad90e8ac73622"
1698c1674
< version = "2.7.0"
---
> version = "2.6.0"
1700c1676
< checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
---
> checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
1707c1683
< version = "1.0.12"
---
> version = "1.0.6"
1709c1685
< checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
---
> checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
1713c1689
< version = "0.1.11"
---
> version = "0.1.10"
1715,1721c1691
< checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
< 
< [[package]]
< name = "utf8parse"
< version = "0.2.1"
< source = "registry+https://github.com/rust-lang/crates.io-index"
< checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
---
> checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
1743c1713
< version = "2.4.0"
---
> version = "2.3.2"
1745c1715
< checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
---
> checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
1747a1718
>  "winapi 0.3.9",
1759c1730
< version = "0.2.88"
---
> version = "0.2.84"
1761c1732
< checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce"
---
> checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
1763c1734
<  "cfg-if",
---
>  "cfg-if 1.0.0",
1769c1740
< version = "0.2.88"
---
> version = "0.2.84"
1771c1742
< checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217"
---
> checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
1784c1755
< version = "0.2.88"
---
> version = "0.2.84"
1786c1757
< checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2"
---
> checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
1794c1765
< version = "0.2.88"
---
> version = "0.2.84"
1796c1767
< checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907"
---
> checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
1807c1778
< version = "0.2.88"
---
> version = "0.2.84"
1809c1780
< checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b"
---
> checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
1813c1784
< version = "0.1.2"
---
> version = "0.1.1"
1815c1786
< checksum = "41b48e27457e8da3b2260ac60d0a94512f5cba36448679f3747c0865b7893ed8"
---
> checksum = "79ebd48bfc1178c9190c7ff80cc822b3335ffc83141e9aa723168f377257623e"
1820c1791
<  "nix 0.26.4",
---
>  "nix 0.26.2",
1828c1799
< version = "0.30.2"
---
> version = "0.30.1"
1830c1801
< checksum = "489c9654770f674fc7e266b3c579f4053d7551df0ceb392f153adb1f9ed06ac8"
---
> checksum = "85bde68449abab1a808e5227b6e295f4ae3680911eb7711b4a2cb90141edb780"
1832c1803
<  "bitflags 1.3.2",
---
>  "bitflags",
1834c1805,1806
<  "nix 0.26.4",
---
>  "log",
>  "nix 0.26.2",
1845c1817
<  "nix 0.26.4",
---
>  "nix 0.26.2",
1852c1824
< version = "0.30.1"
---
> version = "0.30.0"
1854c1826
< checksum = "3b28101e5ca94f70461a6c2d610f76d85ad223d042dd76585ab23d3422dd9b4d"
---
> checksum = "7fefbeb8a360abe67ab7c2efe1d297a1a50ee011f5460791bc18870c26bb84e2"
1856c1828
<  "bitflags 1.3.2",
---
>  "bitflags",
1868c1840
<  "bitflags 1.3.2",
---
>  "bitflags",
1877c1849
< version = "0.30.1"
---
> version = "0.30.0"
1879c1851
< checksum = "b9b873b257fbc32ec909c0eb80dea312076a67014e65e245f5eb69a6b8ab330e"
---
> checksum = "4834c14b3edf1d9986c83ca79b1e7e3afbe9874c7c144702f6467063259ce45d"
1899c1871
< version = "4.4.2"
---
> version = "4.4.0"
1901c1873
< checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
---
> checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
1904c1876
<  "home",
---
>  "libc",
1906d1877
<  "rustix",
1910a1882,1887
> version = "0.2.8"
> source = "registry+https://github.com/rust-lang/crates.io-index"
> checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
> 
> [[package]]
> name = "winapi"
1919a1897,1902
> name = "winapi-build"
> version = "0.1.1"
> source = "registry+https://github.com/rust-lang/crates.io-index"
> checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
> 
> [[package]]
1927c1910
< version = "0.1.6"
---
> version = "0.1.5"
1929c1912
< checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
---
> checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
1931c1914
<  "winapi",
---
>  "winapi 0.3.9",
1941,1949d1923
< name = "windows-core"
< version = "0.51.1"
< source = "registry+https://github.com/rust-lang/crates.io-index"
< checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64"
< dependencies = [
<  "windows-targets",
< ]
< 
< [[package]]
1951c1925
< version = "0.48.0"
---
> version = "0.45.0"
1953c1927
< checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
---
> checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
1960c1934
< version = "0.48.5"
---
> version = "0.42.1"
1962c1936
< checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
---
> checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
1975c1949
< version = "0.48.5"
---
> version = "0.42.1"
1977c1951
< checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
---
> checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
1981c1955
< version = "0.48.5"
---
> version = "0.42.1"
1983c1957
< checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
---
> checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
1987c1961
< version = "0.48.5"
---
> version = "0.42.1"
1989c1963
< checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
---
> checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
1993c1967
< version = "0.48.5"
---
> version = "0.42.1"
1995c1969
< checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
---
> checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
1999c1973
< version = "0.48.5"
---
> version = "0.42.1"
2001c1975
< checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
---
> checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
2005c1979
< version = "0.48.5"
---
> version = "0.42.1"
2007c1981
< checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
---
> checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
2011c1985
< version = "0.48.5"
---
> version = "0.42.1"
2013,2032c1987
< checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
< 
< [[package]]
< name = "winnow"
< version = "0.5.19"
< source = "registry+https://github.com/rust-lang/crates.io-index"
< checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b"
< dependencies = [
<  "memchr",
< ]
< 
< [[package]]
< name = "wpaperctl"
< version = "0.1.0"
< dependencies = [
<  "clap 4.4.7",
<  "serde",
<  "serde_json",
<  "wpaperd-ipc",
< ]
---
> checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
2038c1993
<  "clap 4.4.7",
---
>  "clap 4.1.6",
2051c2006
<  "nix 0.26.4",
---
>  "nix 0.26.2",
2054d2008
<  "serde_json",
2056c2010
<  "toml 0.7.8",
---
>  "toml 0.7.2",
2058d2011
<  "wpaperd-ipc",
2063,2064c2016,2019
< name = "wpaperd-ipc"
< version = "0.1.0"
---
> name = "ws2_32-sys"
> version = "0.2.1"
> source = "registry+https://github.com/rust-lang/crates.io-index"
> checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
2066,2067c2021,2022
<  "serde",
<  "xdg",
---
>  "winapi 0.2.8",
>  "winapi-build",
2081,2096c2036
< version = "2.5.2"
< source = "registry+https://github.com/rust-lang/crates.io-index"
< checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546"
< 
< [[package]]
< name = "zerocopy"
< version = "0.7.25"
< source = "registry+https://github.com/rust-lang/crates.io-index"
< checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557"
< dependencies = [
<  "zerocopy-derive",
< ]
< 
< [[package]]
< name = "zerocopy-derive"
< version = "0.7.25"
---
> version = "2.4.1"
2098c2038
< checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b"
---
> checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6"
2100,2102c2040
<  "proc-macro2",
<  "quote",
<  "syn",
---
>  "dirs",

ERROR: cargoHash or cargoSha256 is out of date

Cargo.lock is not the same in /build/cargo-vendor-dir

To fix the issue:
1. Set cargoHash/cargoSha256 to an empty string: `cargoHash = "";`
2. Build the derivation and wait for it to fail with a hash mismatch
3. Copy the "got: sha256-..." value back into the cargoHash field
   You should have: cargoHash = "sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=";


The most promising idea I had was to overwrite cargoLocks. But that’s somehow not possible

cargoLocks = {
  smithay-client-toolkit = {
     sha256 = "";
  };
};
       … while evaluating attribute 'passAsFile' of derivation 'man-paths'

         at /nix/store/35dcag44a0ymww0vy0s4jjgxwpv9g62d-source/pkgs/build-support/trivial-builders/default.nix:88:7:

           87|       inherit buildCommand name;
           88|       passAsFile = [ "buildCommand" ]
             |       ^
           89|         ++ (derivationArgs.passAsFile or []);

       … while evaluating derivation 'wpaperd-git'
         whose name attribute is located at /nix/store/35dcag44a0ymww0vy0s4jjgxwpv9g62d-source/pkgs/stdenv/generic/make-derivation.nix:300:7

       … while evaluating attribute 'cargoLocks' of derivation 'wpaperd-git'

         at /nix/store/xsf0girvbbnsv45jd81ar274cj73ax20-source/nix/common/desktops/wpaperd.nix:16:9:

           15|
           16|         cargoLocks = {
             |         ^
           17|           smithay-client-toolkit = {

       error: cannot coerce a set to a string

If you can read the source code of buildRustPackage you’ll find the solution. If you can’t, take a look at Is it possible to override cargoSha256 in buildRustPackage? - #3 by aszlig.

Basically,

      cargoDeps = rustPlatform.importCargoLock {
        lockFile = ./Cargo.lock;
        outputHashes = {
          "smithay-client-toolkit-0.16.0" = "iPDL7pxTez4EnIBaUH25lLSWpu3RRL2QBF9pfdTDsP8=";
        };
      };
1 Like

Thanks @vccs. I kind of understand why it works.
I shot myself in the foot for a moment because the upstream changed ( need to start tracking a specific commit instead of head of main) but all good.

Final result for posterity

{ pkgs, lib, ... }:
{
  nixpkgs.overlays = [ 
    (self: super: {
      wpaperd = super.wpaperd.overrideAttrs (prev: {
        version = "git";
        src = pkgs.fetchFromGitHub {
          owner = "danyspin97";
          repo = "wpaperd";
          rev = "8dd6bf9f92f88efc6cb6862a9c4143c3b02255d7";
          sha256 = "sha256-sQOz9MU2zqczbJpLE8N6PIT4ZrXg4VlNMsJKIVRSm80=";
        };
        
        cargoDeps = super.rustPlatform.importCargoLock {
          lockFile = ./Cargo.lock;
        };
        postPatch = ''
          rm Cargo.lock
          ln -s ${./Cargo.lock} Cargo.lock
        '';
      });
    })
  ];
}