From 1afdcc045e8118741903616aa51a1b9726a8f909 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Sun, 14 Feb 2021 22:03:01 +0100 Subject: pkgs/profpatsch/nman: repurpose old path field in DrvWithOutput The path field wasn't used in DrvWithOutput as we only ever needed rendered. rendered however is a bit of a confusing name as it is not in fact fully rendered in all cases. Since we can pass rendered to nix-store --realise without preprocessing in all cases we rename it to path and add a note in the documentation. The old path field is removed for this without replacement. --- pkgs/profpatsch/nman/nman.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'pkgs/profpatsch/nman/nman.rs') diff --git a/pkgs/profpatsch/nman/nman.rs b/pkgs/profpatsch/nman/nman.rs index 0ea99d99..d3f60f7a 100644 --- a/pkgs/profpatsch/nman/nman.rs +++ b/pkgs/profpatsch/nman/nman.rs @@ -109,20 +109,23 @@ impl<'a> DrvOutput<'a> { /// coupled with a parsed [`DrvOutput`] /// for sorting purposes. struct DrvWithOutput<'a> { + /// The original derivation path as printed + /// by `nix-instantiate` _including_ the output + /// indicator if `output` is not [`DrvOutput::Out`] path: &'a [u8], + /// The parsed output of `path` for sorting purposes output: DrvOutput<'a>, - rendered: &'a [u8], } impl DrvWithOutput<'_> { fn render(&self) -> OsString { match self.output { DrvOutput::Out => { - let mut r = OsStr::from_bytes(self.rendered).to_os_string(); + let mut r = OsStr::from_bytes(self.path).to_os_string(); r.push("!out"); r } - _ => OsStr::from_bytes(self.rendered).to_os_string(), + _ => OsStr::from_bytes(self.path).to_os_string(), } } } @@ -133,16 +136,15 @@ impl<'a> DrvWithOutput<'a> { /// structure. fn parse(drv_path: &'a [u8]) -> Option { let mut split = drv_path.split(|c| char::from(*c) == '!'); - let path = split.next().filter(|s| s.len() > 0)?; + let _ = split.next().filter(|s| s.len() > 0)?; let output = split.next() .map(DrvOutput::parse) .unwrap_or(DrvOutput::Out); match split.next() { None => Some(DrvWithOutput { - path: path, + path: drv_path, output: output, - rendered: drv_path, }), Some(_) => None, } -- cgit 1.4.1