⛩️ Powerful yet Minimal Nix Dependency Manager
flake flakes home-manager nixos go nix dependency dependencies
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(yae): track sri hash field for sources

Fuwn 4be6e521 73339dda

+22 -3
+1 -1
flake.nix
··· 54 54 inherit meta; 55 55 56 56 pname = name; 57 - version = "2024.11.25"; 57 + version = "2024.12.02"; 58 58 src = pkgs.lib.cleanSource ./.; 59 59 vendorHash = "sha256-XQEB2vgiztbtLnc7BR4WTouPI+2NDQXXFUNidqmvbac="; 60 60 buildInputs = [ pkgs.musl ];
+9 -1
internal/yae/source.go
··· 11 11 type Source struct { 12 12 URL string `json:"url"` 13 13 SHA256 string `json:"sha256"` 14 + Hash string `json:"hash"` 14 15 Unpack bool `json:"unpack"` 15 16 Type string `json:"type"` 16 17 Version string `json:"version,omitempty"` ··· 78 79 return updated, err 79 80 } 80 81 81 - if sha256 != source.SHA256 { 82 + sriHash, err := FetchSRIHash(sha256) 83 + 84 + if err != nil { 85 + return updated, err 86 + } 87 + 88 + if sha256 != source.SHA256 || sriHash != source.Hash || force || source.Force { 82 89 log.Infof("rehashed %s: %s -> %s", name, source.SHA256, sha256) 83 90 84 91 source.SHA256 = sha256 92 + source.Hash = sriHash 85 93 updated = true 86 94 } 87 95
+10
internal/yae/utilities.go
··· 25 25 return strings.Trim(lines[len(lines)-2], "\n"), nil 26 26 } 27 27 28 + func FetchSRIHash(sha256 string) (string, error) { 29 + output, err := command("nix", false, "hash", "convert", "--hash-algo", "sha256", "--from", "nix32", sha256) 30 + 31 + if err != nil { 32 + return "", err 33 + } 34 + 35 + return strings.Trim(output, "\n"), nil 36 + } 37 + 28 38 func command(name string, show bool, args ...string) (string, error) { 29 39 executable, err := exec.LookPath(name) 30 40 out := []byte{}
+2 -1
yae.schema.json
··· 4 4 "properties": { "$schema": { "type": "string" } }, 5 5 "additionalProperties": { 6 6 "type": "object", 7 - "required": ["url", "sha256", "unpack", "type"], 7 + "required": ["url", "sha256", "hash", "unpack", "type"], 8 8 "additionalProperties": false, 9 9 "properties": { 10 10 "url": { "type": "string" }, 11 11 "sha256": { "type": "string" }, 12 + "hash": { "type": "string" }, 12 13 "unpack": { "type": "boolean" }, 13 14 "type": { "type": "string" }, 14 15 "version": { "type": "string" },