prepare_common: simplify nixos-install installation

This commit is contained in:
tv 2016-02-19 19:37:00 +01:00
parent 1226a20038
commit d8d39f5c4a

View File

@ -184,26 +184,21 @@ prepare_common() {(
. /root/.nix-profile/etc/profile.d/nix.sh . /root/.nix-profile/etc/profile.d/nix.sh
for i in \ mkdir -p /mnt/"$target_path"
bash \ mkdir -p "$target_path"
coreutils \
# This line intentionally left blank.
do
if ! nix-env -q $i | grep -q .; then
nix-env -iA nixpkgs.pkgs.$i
fi
done
# install nixos-install if ! mountpoint "$target_path"; then
if ! type nixos-install 2>/dev/null; then mount --rbind /mnt/"$target_path" "$target_path"
nixpkgs_expr='import <nixpkgs> { system = builtins.currentSystem; }' fi
nixpkgs_path=$(find /nix/store -mindepth 1 -maxdepth 1 -name *-nixpkgs-* -type d)
nix-env \ mkdir -p bin
--arg config "{ nix.package = ($nixpkgs_expr).nix; }" \ rm -f bin/nixos-install
--arg pkgs "$nixpkgs_expr" \ cp "$(type -p nixos-install)" bin/nixos-install
--arg modulesPath 'throw "no modulesPath"' \ sed -i "s@^NIX_PATH=\"[^\"]*\"@NIX_PATH=$target_path@" bin/nixos-install
-f $nixpkgs_path/nixpkgs/nixos/modules/installer/tools/tools.nix \
-iA config.system.build.nixos-install if ! grep -q '^PATH.*#krebs' .bashrc; then
echo '. /root/.nix-profile/etc/profile.d/nix.sh' >> .bashrc
echo 'PATH=$HOME/bin:$PATH #krebs' >> .bashrc
fi fi
)} )}