-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Tracking: deprecate sha256 attribute in fetchers in favor of hash = "<SRI hash>" #325892
Copy link
Copy link
Open
Open
Copy link
Labels
5.scope: trackingLong-lived issue tracking long-term fixes or multiple sub-problemsLong-lived issue tracking long-term fixes or multiple sub-problems6.topic: architectureRelating to code and API architecture of NixpkgsRelating to code and API architecture of Nixpkgs
Description
When we did not support SRI hash, we wrote a lot of sha256 = "...", and some of new PRs are still written with this attribute. However, when using an empty string to obtain the correct hash from the error, the SRI hash is obtained, which causes some confusion.
Let's move on from this old attribute. I don't expect to remove it within a certain period of time, but we can throw a warning to prevent this type of writing from continuing to appear in nixpkgs.
I did an experiment last time with cargoHash in #323983. I wrote the following script for this:
#!/usr/bin/env bash
process_line() {
local filename=${1%:}
if [[ $4 =~ \"(.*)\"\; ]]; then
local sha256="${BASH_REMATCH[1]}"
fi
[[ -z $sha256 ]] && return 0
local hash=$(nix hash to-sri --type sha256 $sha256)
echo "Processing: $filename"
echo " $sha256 => $hash"
sed -i "s|sha256 = \"$sha256\"|hash = \"$hash\"|" $filename
}
# split output by line
grep -r 'sha256 = ' . | while IFS= read -r line; do
# split them further by space
read -r -a parts <<< "$line"
process_line "${parts[@]}"
doneWe can deprecate each fetcher's sha256 separately, instead of the entire hash, to avoid the burden of review:
I collapsed the check list because it's not feasible to deprecate one by one
- buildBazelPackage buildBazelPackage: support
fetchAttrs.hash#342037 - fetch-scm
- fetchCrate
- fetchDebianPatch
- fetchDockerConfig
- fetchDockerLayer
- fetchFirefoxAddon
- fetchFrom9Front
- fetchFromBitbucket fetchFromBitBucket: deprecate sha256 attribute #326028
- fetchFromGitHub
- fetchFromGitLab
- fetchFromGitea
- fetchFromGithub
- fetchFromGitiles
- fetchFromRepoOrCz
- fetchFromSavannah
- fetchFromSourcehut
- fetchHex
- fetchMavenArtifact
- fetchNextcloudApp
- fetchNpmDeps
- fetchNuGet
- fetchPypi
- fetchPypiLegacy
- fetchRepoProject fetchRepoProject: support
hashattribute #342031 - fetchTarball
- fetchYarnDeps
- fetchbower
- fetchbzr
- fetchcvs
- fetchdarcs
- fetchdocker
- fetchegg
- fetchfossil
- fetchgit
- fetchgitLocal
- fetchgx
- fetchhg
- fetchipfs
- fetchit
- fetchmail
- fetchmail_7
- fetchmtn
- fetchpatch
- fetchpatch2
- fetchpijul
- fetchs3
- fetchsvn
- fetchsvnrevision
- fetchsvnssh
- fetchtorrent (Looks like there is no support for sha256 attribute?)
- fetchurl
- fetchutils
- fetchzip
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
5.scope: trackingLong-lived issue tracking long-term fixes or multiple sub-problemsLong-lived issue tracking long-term fixes or multiple sub-problems6.topic: architectureRelating to code and API architecture of NixpkgsRelating to code and API architecture of Nixpkgs
Fields
Give feedbackNo fields configured for issues without a type.