0
我想推广并制作一个shell脚本出这个页面上的说明,特别是在这里:https://nixos.org/wiki/How_to_add_files_to_the_nix-store#Large_files,因为Nix没有处理4.5 GB的文件,我得到了内存不足的错误。使用unshare并仍然执行原始功能
因此...
我当前的代码是:
#!/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 "[email protected]"
...的想法,它将与sudo -HE
被调用,问题是unshare
立即开始新的bash shell和“父”代码停止运行,这对我来说当然是不好的,因为我需要这个逻辑来完成。此外,我需要保留当前用户的环境,因为我需要nix-store
等路径仍然有效,因此使用sudo -HE
。