diff options
author | sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> | 2021-02-12 15:13:47 +0100 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2021-02-25 19:52:33 +0100 |
commit | 3e62680966ff052638af7abc3ee05ef70bbe9fe0 (patch) | |
tree | 35d10ca215ac4cdb269ebab452f87e9c7ec4409d /pkgs/profpatsch | |
parent | cbef421081f1e65b1dcd81c9a6434e69cbc50f8e (diff) |
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 <drv_path>!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.
Diffstat (limited to 'pkgs/profpatsch')
-rw-r--r-- | pkgs/profpatsch/nman/nman.rs | 14 |
1 files changed, 9 insertions, 5 deletions
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); |