このページの指示からシェル スクリプトを一般化して作成しようとしています。具体的にはこちら: https://nixos.org/wiki/How_to_add_files_to_the_nix-store#Large_filesメモリエラーの。
したがって...
私の現在のコードは次のとおりです。
#!/usr/bin/env bash
function do_store {
if [ "$#" -lt 1 ]; then
printf "Must provide the Xcode_dmg\n"
exit 1
fi
unshare -m bash
local
sdk="$1"
name="$(basename $sdk)"
# Hack since the openssl sha and nix-store is super slow
hash="a08d555c4f3fd905c53ee67720d9e6ade01e1b0b"
store_path="$(nix-store --print-fixed-path sha1 $hash $name)"
mount -o remount,rw /nix/store
printf "$storepath\n\n0\n" | nix-store --register-validity --reregister
exit
# printf "name: %s, hash: %s, store_path: %s\n" "$name" "$hash" "$store_path"
}
do_store "$@"
...で呼び出されるという考えでsudo -HE
そして問題はunshare
、新しい bash シェルがすぐに開始され、「親」コードの実行が停止することです。もちろん、そのロジックを終了する必要があるため、これは私にとって悪いことです。nix-store
また、パスなどがまだ有効である必要があるため、現在のユーザーの環境を保持する必要がありsudo -HE
ます。