fix(nix-compat): support Deriver: unknown-deriver NARInfos
According to c60715e937
,
these were produced by a legacy tool and should be considered as if
Deriver was not passed at all.
See: https://github.com/kalbasit/ncps/issues/171
Reported-In: https://github.com/nix-community/go-nix/pull/128
Change-Id: If285a11c3275cb3c857c68782bd13473c46f04bf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12940
Reviewed-by: edef <edef@edef.eu>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
parent
5a50b39d76
commit
bd73dff0bf
1 changed files with 29 additions and 1 deletions
|
@ -84,6 +84,9 @@ bitflags! {
|
|||
// Format quirks encountered in the cache.nixos.org dataset
|
||||
const REFERENCES_OUT_OF_ORDER = 1 << 2;
|
||||
const NAR_HASH_HEX = 1 << 3;
|
||||
|
||||
/// Deriver: unknown-deriver, produced by a legacy tool
|
||||
const EXPLICIT_UNKNOWN_DERIVER = 1 << 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +244,11 @@ impl<'a> NarInfo<'a> {
|
|||
}
|
||||
}
|
||||
None => {
|
||||
return Err(Error::InvalidDeriverStorePathMissingSuffix);
|
||||
if val == "unknown-deriver" {
|
||||
flags |= Flags::EXPLICIT_UNKNOWN_DERIVER;
|
||||
} else {
|
||||
return Err(Error::InvalidDeriverStorePathMissingSuffix);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -525,6 +532,27 @@ Sig: cache.nixos.org-1:92fl0i5q7EyegCj5Yf4L0bENkWuVAtgveiRcTEEUH0P6HvCE1xFcPbz/0
|
|||
assert_eq!(parsed.compression, Some("bzip2"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_unknown_deriver() {
|
||||
// This is a NARInfo "produced by a legacy tool" according to Nix commit
|
||||
// c60715e937e3773bbb8a114fc9b9c6577f8c5cb5
|
||||
let parsed = NarInfo::parse(r#"StorePath: /nix/store/00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432
|
||||
URL: nar/1094wph9z4nwlgvsd53abfz8i117ykiv5dwnq9nnhz846s7xqd7d.nar.xz
|
||||
Compression: xz
|
||||
FileHash: sha256:1094wph9z4nwlgvsd53abfz8i117ykiv5dwnq9nnhz846s7xqd7d
|
||||
FileSize: 114980
|
||||
NarHash: sha256:0lxjvvpr59c2mdram7ympy5ay741f180kv3349hvfc3f8nrmbqf6
|
||||
NarSize: 464152
|
||||
References: 7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27
|
||||
Deriver: unknown-deriver
|
||||
Sig: cache.nixos.org-1:sn5s/RrqEI+YG6/PjwdbPjcAC7rcta7sJU4mFOawGvJBLsWkyLtBrT2EuFt/LJjWkTZ+ZWOI9NTtjo/woMdvAg==
|
||||
Sig: hydra.other.net-1:JXQ3Z/PXf0EZSFkFioa4FbyYpbbTbHlFBtZf4VqU0tuMTWzhMD7p9Q7acJjLn3jofOtilAAwRILKIfVuyrbjAA==
|
||||
"#).expect("should parse");
|
||||
|
||||
assert!(parsed.flags.contains(Flags::EXPLICIT_UNKNOWN_DERIVER));
|
||||
assert!(parsed.deriver.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nar_hash_hex() {
|
||||
let parsed = NarInfo::parse(r#"StorePath: /nix/store/0vpqfxbkx0ffrnhbws6g9qwhmliksz7f-perl-HTTP-Cookies-6.01
|
||||
|
|
Loading…
Reference in a new issue