Jump to content

Nix Hash: Difference between revisions

745 bytes added ,  21 January 2023
m
Replace .nix file hashs theeasy way
imported>Das-g
m (correctly capitalize "PhD")
imported>Pheoxy
m (Replace .nix file hashs theeasy way)
Line 30: Line 30:


If you find a hash that uses colon as a separator (<code><type>:<hash></code>), don't use that. This relies on undocumented behavior and is not officially supported.
If you find a hash that uses colon as a separator (<code><type>:<hash></code>), don't use that. This relies on undocumented behavior and is not officially supported.
=== Updating Packages ===
When you are updating packages in nixpkgs.
An easy way to get the Hash is TOFU, where we replace the hash in a .nix file with:
<syntaxHighlight lang=nix>
{
  hash = "sha256-IdU23rswdtT26QRL2e8VyMWLKfnL1K1AawWDEKVl3rw=";
};
</syntaxHighlight>
<syntaxHighlight lang=nix>
{
  hash = "";
};
</syntaxHighlight>
Nix assumes with blank quotes in the hash means a TOFU on a nix-build is needed and will get the Hash for you enter into the old .nix file.
<syntaxHighlight lang=nix>
{
  hash = "sha256-wlb6er8L2EaqgJbmbATBdSxx1BGcJXNcsu+/4UBmYdQ=";
};
</syntaxHighlight>
Once you have replaced the Hash, run nix-build or equivalent command again and it will verify the Hash and continue your build to update the package.


=== What exactly is hashed ===
=== What exactly is hashed ===
Anonymous user