small fixes, esp. for cross-building

This commit is contained in:
Niklas Gollenstede
2023-02-05 22:59:39 +01:00
parent 9edfe9c9d8
commit c001ad7f51
11 changed files with 83 additions and 59 deletions

View File

@ -102,3 +102,9 @@ function run-hook-script {( set -eu # 1: title, 2: scriptPath
fi
source "$2"
)}
## Lazily builds a nix derivation at run time, instead of when building the script.
# When maybe-using packages that take long to build, instead of »at{some.package.out}«, use: »$( build-lazy at{some.package.drvPath!unsafeDiscardStringContext} out )«
function build-lazy { # 1: drvPath, 2?: output
PATH=$PATH:@{native.openssh}/bin @{native.nix}/bin/nix --extra-experimental-features nix-command build --no-link --json ${args[quiet]:+--quiet} $1 | @{native.jq}/bin/jq -r .[0].outputs.${2:-out}
}