Merge pull request #3 from oxalica/fast-install

Speed up installPhase for nightly rust-docs
wip/nixpkgs-raku
oxalica 3 years ago committed by GitHub
commit 164fa885dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      rust-installer.py
  2. 14
      rust-overlay.nix

@ -0,0 +1,27 @@
# The install script for rust components.
# Some toolchains have tons of install directives which makes bash script too slow.
import os
from pathlib import Path
from shutil import copy, copytree
out = Path(os.environ['out'])
verbose = os.environ.get('VERBOSE_INSTALL') == '1'
installer_version = int(Path('./rust-installer-version').read_text().strip())
if installer_version == 3:
for component in Path('./components').read_text().splitlines():
print(f'Installing component {component}')
for directive in (Path(component) / 'manifest.in').read_text().splitlines():
cmd, file = directive.split(':')
in_file, out_file = Path(component) / file, out / file
out_file.parent.mkdir(parents=True, exist_ok=True)
if verbose:
print(f'Installing {cmd}: {file}')
if cmd == 'file':
copy(in_file, out_file)
elif cmd == 'dir':
copytree(in_file, out_file)
else:
assert False, f'Unknown command: {cmd}'
else:
assert False, f'Unknown installer version: {installer_version}'

@ -149,11 +149,19 @@ let
# entire unpacked contents after just a little twiddling.
preferLocalBuild = true;
nativeBuildInputs = [ self.python3 ];
# VERBOSE_INSTALL = 1; # No spam by default.
installPhase = ''
runHook preInstall
python3 ${./rust-installer.py}
runHook postInstall
'';
# (@nbp) TODO: Check on Windows and Mac.
# This code is inspired by patchelf/setup-hook.sh to iterate over all binaries.
installPhase = ''
patchShebangs install.sh
CFG_DISABLE_LDCONFIG=1 ./install.sh --prefix=$out --verbose
preFixup = ''
setInterpreter() {
local dir="$1"
[ -e "$dir" ] || return 0

Loading…
Cancel
Save