From 3e62680966ff052638af7abc3ee05ef70bbe9fe0 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Fri, 12 Feb 2021 15:13:47 +0100 Subject: pkgs/profpatsch/nman: fix building of default output Unfortunately, nix-instantiate prints only the drv path for the `out` output which causes nix-store to realise all drv outputs. This of course breaks build_man_page since it expects the output to be just one path. We fix this (for now) by using split(). Ideally we would use !out for realising the default output which only builds the output we need. However this is a bit annoying to solve since it means we have to allocate a bit of memory. --- pkgs/profpatsch/nman/nman.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'pkgs/profpatsch/nman') diff --git a/pkgs/profpatsch/nman/nman.rs b/pkgs/profpatsch/nman/nman.rs index 150d9cbe..475b42dd 100644 --- a/pkgs/profpatsch/nman/nman.rs +++ b/pkgs/profpatsch/nman/nman.rs @@ -1,7 +1,7 @@ use std::cmp::Ordering; -use std::ffi::{OsStr,OsString}; +use std::ffi::OsStr; use std::io::{Error, ErrorKind, self, Write}; -use std::os::unix::ffi::{OsStrExt, OsStringExt}; +use std::os::unix::ffi::OsStrExt; use std::path::{Path, PathBuf}; use std::process::{Command,ExitStatus}; @@ -127,11 +127,15 @@ fn build_man_page(drv: DrvWithOutput, section: &str, page: &str, tempdir: &TempD return Err(NmanError::Build); } - // trailing newline - build.stdout.pop(); + // get the first line of the output, usually only one line + // is printed, but this way we also get rid of the trailing '\n' + // TODO(sterni): use the !out suffix for default output drvs to + // prevent nix from realising all drv outputs. + let first_path = build.stdout.split(|c| char::from(*c) == '\n') + .next().ok_or(NmanError::Build)?; // TODO(sterni): 😑😑😑😑😑😑😑😑😑😑😑 - let mut path = PathBuf::from(OsString::from_vec(build.stdout)) + let mut path = PathBuf::from(OsStr::from_bytes(first_path)) .join("share/man") .join(format!("man{}", section)) .join(page); -- cgit 1.4.1