Update sha256 checksums in copied nixpkgs folder

Hi folks, I have been looking up how to do this but cannot find information on it. I have copied the openra package from the nixpkgs repository and updated it, or tried to rather. And I cannot seem to remember how you’re meant to automatically update all the sha256 checksums in the packaging files. One of the packaging files I want to update it in is a deps.json file (to be clear this file contains sha256 checksums that I want to update). This is the structure of the package directory if you’re curious, it’s basically copied from the official nixpkgs GitHub repository. Is there a way to achieve what I want? Apologies for my ignorance.
Screenshot From 2025-01-22 09-47-47

It’s always case-by-case.
For dotnet, the way to handle it is something like $(nix-build -A FOOBAR.fetch-deps --no-out-link), where FOOBAR is the attribute name of the dotnet package you’re trying to update. Nixpkgs Reference Manual effectively says something similar, but in not-so-easily-grasped terms.

Is FOOBAR meant to be replaced with the package I want to update the sha256 checksums for? If so, I seem to be getting errors.

error: cannot evaluate a function that has an argument without a value ('callPackage')
       Nix attempted to evaluate a function as a top level expression; in
       this case it must have its arguments supplied either by default
       values, or passed explicitly with '--arg' or '--argstr'. See
       https://nixos.org/manual/nix/stable/language/constructs.html#functions.
       at /mnt/nixpkgs/openra/default.nix:1:3:
            1| { callPackage }:
             |   ^

I tried following that URL and I got a “Page not found” error.

Well you have to callPackage it the way nixpkgs does.
See Package parameters and overrides with callPackage — nix.dev documentation.
Then use the correct attribute name from there.

Try nixpkgs/doc/languages-frameworks/dotnet.section.md at 232bc510052ed87bfa38656b46ee93b910d6f6b7 · NixOS/nixpkgs · GitHub then, it’s the code that generates that bit of the manual.

Thank you. I may have resolved that callPackage issue as the package now builds, but I am getting a hash mismatch error after I ran $(nix-build -A FOOBAR.fetch-deps --no-out-link --impure). I added the --impure as I was getting security warnings without it. Essentially, the way I fixed those callPackage errors was by adding the pkgs = import... and pkgs. prefix to these lines in the default.nix:

  pkgs = import <nixpkgs> {};
  buildOpenRAEngine = pkgs.callPackage ./build-engine.nix { };
  callPackage' = path: pkgs.callPackage path { inherit buildOpenRAEngine; };

Is it due to these tweaks that $(nix-build -A FOOBAR.fetch-deps --no-out-link --impure) is failing to update the checksums?

There’s no reason to use --impure with nix-build, as it’s not using pure eval - and I don’t think nix-build even recognises the --impure flag at all.

What’s the command you ran, and what’s the error?

$ nix-build -A engines.playtest
these 40 derivations will be built:
  /nix/store/0phwg4kv05ywgmgh8mqqqm1zqk764n1j-System.Text.Json.6.0.11.nupkg.drv
  /nix/store/jyx6wza5fi9xs54lpmmxm9awfpj0gwq5-Microsoft.Win32.Registry.6.0.36.nupkg.drv
  /nix/store/0y8vxq3l43p9g4dgg48rkdfg8m32ijvs-Microsoft.Win32.Registry-6.0.36.drv
  /nix/store/2990yf8y642isaf74l2bdn2d0j68k4zv-source.drv
  /nix/store/29vyd247ldy5nk77dnayyi48jqx20n5c-Linguini.Shared.0.8.0.nupkg.drv
  /nix/store/fkvq8mqd64ppbqpws8xyiqykp5yfjqk9-Microsoft.Extensions.DependencyModel.6.0.2.nupkg.drv
  /nix/store/2pwcpbhrkk38h8wxnpzh1wp9klcfb0pl-Microsoft.Extensions.DependencyModel-6.0.2.drv
  /nix/store/pl647waqfy7hl7k12kwbyj195b82gh8n-NuGet.CommandLine.6.12.1.nupkg.drv
  /nix/store/31092crdmaq49lf6rwxqg8q3075gwl8i-NuGet.CommandLine-6.12.1.drv
  /nix/store/sn4nmv9h5d0sygck4s6fbbf7k7lbrg5p-Linguini.Syntax.0.8.0.nupkg.drv
  /nix/store/3lnl2xx17rvcv46vazgw7l97fralv29c-Linguini.Syntax-0.8.0.drv
  /nix/store/5n94mn0k97pcap1lsji2irxik87k85zi-OpenRA-Eluant.1.0.22.nupkg.drv
  /nix/store/73s0279r0h89s64k260y6hvlwds25gjl-TagLibSharp.2.3.0.nupkg.drv
  /nix/store/rnjs9i4ff5i9419qy56srfi18qaimdm8-Linguini.Bundle.0.8.1.nupkg.drv
  /nix/store/78pxj92zrg23lgi0i39vh030w8fa4d5j-Linguini.Bundle-0.8.1.drv
  /nix/store/8y1klifcg94a8fxndhw9zii9sxib0qma-OpenRA-Eluant-1.0.22.drv
  /nix/store/9q41v7r831hh3msvlip3fwighzh9ib5v-dotnet-sdk-6.0.428.drv
  /nix/store/bgsanwi7h750kcwj7hvjwml5irn9p494-System.Text.Encodings.Web.6.0.1.nupkg.drv
  /nix/store/bv0sn0py9qibl41f2qw2lwykr7v91bqa-OpenRA-Freetype6.1.0.11.nupkg.drv
  /nix/store/cmxzrnj1ih2yns2cxnij7i2l95lsk51n-Linguini.Shared-0.8.0.drv
  /nix/store/hwxjry7spby8yrxqz94sddm7q6yk7x8s-NVorbis.0.10.5.nupkg.drv
  /nix/store/fn65nk2ydmfhr748zni5dl8qhwkmq3sq-NVorbis-0.10.5.drv
  /nix/store/gz7pvsqvmz63fslfvff83zp25vpb89kq-System.Text.Encodings.Web-6.0.1.drv
  /nix/store/h556dab495jjnj6a1cqnlvdq6rfalhpn-dotnet-sdk-wrapped-6.0.428.drv
  /nix/store/jg6vyhxx008xdihvhggv0vdxv92lyg65-OpenRA-FuzzyLogicLibrary-1.0.1.drv
  /nix/store/ls8hy55pqlagq53wribmkhb5q50xmryg-System.Text.Json-6.0.11.drv
  /nix/store/mq9cxd254lxvv57plja43cvhxybsagvx-StyleCop.Analyzers.Unstable-1.2.0.435.drv
  /nix/store/r39w2yi4v29bh68pc0ycw7dii95ay0af-TagLibSharp-2.3.0.drv
  /nix/store/zf21hsnc2p2qzwd6iq8qwlk23q2hy2i4-OpenRA-OpenAL-CS.1.0.22.nupkg.drv
  /nix/store/v88ay9b0zxsry126xp2bjvva77322v62-OpenRA-OpenAL-CS-1.0.22.drv
  /nix/store/prny8azl46pb6nik9zn9gh1j9zfv2aja-Pfim.0.11.3.nupkg.drv
  /nix/store/vz0wya6jrbvyi7qgd7sdv88j1kcbzr47-Pfim-0.11.3.drv
  /nix/store/wjayaa7sb6ccjaij7mcr9zhd24y1n5bk-OpenRA-Freetype6-1.0.11.drv
  /nix/store/vn5qhwnwrypj5a0s8h76pfy0mwg8c4md-OpenRA-SDL2-CS.1.0.41.nupkg.drv
  /nix/store/y9xzvhqi2whi5h35v4h9m0wdbc5lfczs-OpenRA-SDL2-CS-1.0.41.drv
  /nix/store/lrdrcyr2zdgsdaghsp7l52diglyvj1fw-Microsoft.Win32.Primitives.6.0.36.nupkg.drv
  /nix/store/ychc3wfvxd6wbwi7pd5wvj0dmajqn4rn-Microsoft.Win32.Primitives-6.0.36.drv
  /nix/store/zrhl9s7xbr5077hqaznjjipnzk694cyg-rix0rrr.BeaconLib-1.0.2.drv
  /nix/store/zvsc91bhq4d38jzx789arvinfhbk15fb-StyleCop.Analyzers-1.2.0-beta.435.drv
  /nix/store/lmaglhh597km52m4ldfb5f08syc8b03v-openra-playtest-20241228.drv
building '/nix/store/jg6vyhxx008xdihvhggv0vdxv92lyg65-OpenRA-FuzzyLogicLibrary-1.0.1.drv'...
building '/nix/store/zvsc91bhq4d38jzx789arvinfhbk15fb-StyleCop.Analyzers-1.2.0-beta.435.drv'...
building '/nix/store/mq9cxd254lxvv57plja43cvhxybsagvx-StyleCop.Analyzers.Unstable-1.2.0.435.drv'...
Running phase: unpackPhase
Running phase: patchPhase
Running phase: unpackPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
Running phase: unpackPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
no Makefile or custom buildPhase, doing nothing
Running phase: installPhase
Running phase: patchPhase
no configure script, doing nothing
Running phase: buildPhase
Running phase: fixupPhase
no Makefile or custom buildPhase, doing nothing
Running phase: installPhase
Patching package openra-fuzzylogiclibrary/1.0.1
Running phase: updateAutotoolsGnuConfigScriptsPhase
shrinking RPATHs of ELF executables and libraries in /nix/store/41rxys1wiv5nm6zd6xgpndy2yv6lzy6s-OpenRA-FuzzyLogicLibrary-1.0.1
Running phase: fixupPhase
Running phase: configurePhase
checking for references to /build/ in /nix/store/41rxys1wiv5nm6zd6xgpndy2yv6lzy6s-OpenRA-FuzzyLogicLibrary-1.0.1...
patching script interpreter paths in /nix/store/41rxys1wiv5nm6zd6xgpndy2yv6lzy6s-OpenRA-FuzzyLogicLibrary-1.0.1
Patching package stylecop.analyzers/1.2.0-beta.435
no configure script, doing nothing
Running phase: buildPhase
shrinking RPATHs of ELF executables and libraries in /nix/store/fas359an8b7hz59cxick7hhy7wwg64nw-StyleCop.Analyzers-1.2.0-beta.435
no Makefile or custom buildPhase, doing nothing
checking for references to /build/ in /nix/store/fas359an8b7hz59cxick7hhy7wwg64nw-StyleCop.Analyzers-1.2.0-beta.435...
patching script interpreter paths in /nix/store/fas359an8b7hz59cxick7hhy7wwg64nw-StyleCop.Analyzers-1.2.0-beta.435
Running phase: installPhase
Running phase: fixupPhase
building '/nix/store/rnjs9i4ff5i9419qy56srfi18qaimdm8-Linguini.Bundle.0.8.1.nupkg.drv'...
Patching package stylecop.analyzers.unstable/1.2.0.435
shrinking RPATHs of ELF executables and libraries in /nix/store/5b2ir23i5papaawdv0md32gw141i8p6g-StyleCop.Analyzers.Unstable-1.2.0.435
checking for references to /build/ in /nix/store/5b2ir23i5papaawdv0md32gw141i8p6g-StyleCop.Analyzers.Unstable-1.2.0.435...
patching script interpreter paths in /nix/store/5b2ir23i5papaawdv0md32gw141i8p6g-StyleCop.Analyzers.Unstable-1.2.0.435
building '/nix/store/29vyd247ldy5nk77dnayyi48jqx20n5c-Linguini.Shared.0.8.0.nupkg.drv'...
building '/nix/store/sn4nmv9h5d0sygck4s6fbbf7k7lbrg5p-Linguini.Syntax.0.8.0.nupkg.drv'...

trying https://www.nuget.org/api/v2/package/Linguini.Shared/0.8.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

trying https://www.nuget.org/api/v2/package/Linguini.Syntax/0.8.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

trying https://www.nuget.org/api/v2/package/Linguini.Bundle/0.8.1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   202    0   202    0     0    236      0 --:--:-- --:--:-- --:--:--   236
100   202    0   202    0     0    242      0 --:--:-- --:--:-- --:--:--   243
100 84189  100 84189    0     0  84183      0  0:00:01  0:00:01 --:--:-- 84183
100   202    0   202    0     0    221      0 --:--:-- --:--:-- --:--:--   221
error: hash mismatch in fixed-output derivation '/nix/store/29vyd247ldy5nk77dnayyi48jqx20n5c-Linguini.Shared.0.8.0.nupkg.drv':
         specified: sha256-+t9RP57nOIZQOv1WYAdUehdmgocvBuYpxH3LsDP5srM=
            got:    sha256-BnCgq61zLy6MMG6gNnZiIOjJNy/So1DPUsdR83m5ACM=
error: 1 dependencies of derivation '/nix/store/cmxzrnj1ih2yns2cxnij7i2l95lsk51n-Linguini.Shared-0.8.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/lmaglhh597km52m4ldfb5f08syc8b03v-openra-playtest-20241228.drv' failed to build

The second of these links did actually fix the problem. Namely, these steps fixed it:

  • nix-build -A package.fetch-deps to generate the update script for package
  • Run ./result to regenerate the lockfile to the path passed for nugetDeps (keep in mind if it can’t be resolved to a local path, the script will write to $1 or a temporary path instead)
  • Finally, ensure the correct file was written and the derivation can be built.