From bd6c9c002daf14522605b4851606f0422bdf3ed3 Mon Sep 17 00:00:00 2001 From: oxalica Date: Mon, 12 Apr 2021 22:19:10 +0800 Subject: [PATCH] Fix /etc handling --- rust-overlay.nix | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/rust-overlay.nix b/rust-overlay.nix index 3d7e79d..4d851ad 100644 --- a/rust-overlay.nix +++ b/rust-overlay.nix @@ -176,7 +176,7 @@ let map (tuple: { name = tuple.name; src = (getFetchUrl pkgs tuple.name tuple.target stdenv fetchurl); }) pkgsTuplesToInstall; mkComponent = { pname, version, src }: - self.stdenv.mkDerivation ({ + self.stdenv.mkDerivation { inherit pname version src; # No point copying src to a build server, then copying back the @@ -232,41 +232,19 @@ let postFixup = '' # Function moves well-known files from etc/ handleEtc() { - local oldIFS="$IFS" - # Directories we are aware of, given as substitution lists - for paths in \ - "etc/bash_completion.d","share/bash_completion/completions","etc/bash_completions.d","share/bash_completions/completions"; - do - # Some directoties may be missing in some versions. If so we just skip them. - # See https://github.com/mozilla/nixpkgs-mozilla/issues/48 for more infomation. - if [ ! -e $paths ]; then continue; fi - IFS="," - set -- $paths - IFS="$oldIFS" - local orig_path="$1" - local wanted_path="$2" - # Rename the files - if [ -d ./"$orig_path" ]; then - mkdir -p "$(dirname ./"$wanted_path")" - fi - mv -v ./"$orig_path" ./"$wanted_path" - # Fail explicitly if etc is not empty so we can add it to the list and/or report it upstream - rmdir ./etc || { - echo Installer tries to install to /etc: - find ./etc - exit 1 - } - done + if [[ -d "$1" ]]; then + mkdir -p "$(dirname "$2")" + mv -T "$1" "$2" + fi } - if [ -d "$out"/etc ]; then - pushd "$out" - handleEtc - popd + if [[ -e "$out/etc" ]]; then + handleEtc "$out/etc/bash_completion.d" "$out/share/bash-completion/completions" + rmdir $out/etc || { echo "Installer tries to install to /etc: $(ls $out/etc)"; exit 1; } fi ''; dontStrip = true; - }); + }; aggregateComponents = { pname, version, components }: self.pkgs.symlinkJoin {