From 8719858970d428142e3a0d8adbd7e887ca457482 Mon Sep 17 00:00:00 2001 From: oxalica Date: Mon, 12 Apr 2021 21:51:22 +0800 Subject: [PATCH] Use cpio instead of python for install script --- rust-installer.py | 27 --------------------------- rust-overlay.nix | 14 ++++++++++---- 2 files changed, 10 insertions(+), 31 deletions(-) delete mode 100644 rust-installer.py diff --git a/rust-installer.py b/rust-installer.py deleted file mode 100644 index 45c8786..0000000 --- a/rust-installer.py +++ /dev/null @@ -1,27 +0,0 @@ -# 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}' diff --git a/rust-overlay.nix b/rust-overlay.nix index 41e7045..3d7e79d 100644 --- a/rust-overlay.nix +++ b/rust-overlay.nix @@ -183,13 +183,19 @@ let # entire unpacked contents after just a little twiddling. preferLocalBuild = true; - nativeBuildInputs = [ self.python3 ]; - - # VERBOSE_INSTALL = 1; # No spam by default. + nativeBuildInputs = [ self.cpio ]; installPhase = '' runHook preInstall - python3 ${./rust-installer.py} + installerVersion=$(< ./rust-installer-version) + if [[ "$installerVersion" != 3 ]]; then + echo "Unknown installer version: $installerVersion" + fi + while read -r comp; do + echo "Installing component $comp" + # Use cpio with file list instead of forking tons of cp. + cut -d: -f2 <"$comp/manifest.in" | cpio --quiet -pdD "$comp" "$out" + done <./components runHook postInstall '';