use resholve
This commit is contained in:
parent
605365998b
commit
e677a8a19d
|
@ -6,6 +6,8 @@
|
||||||
writeText,
|
writeText,
|
||||||
writeShellApplication,
|
writeShellApplication,
|
||||||
|
|
||||||
|
resholve,
|
||||||
|
|
||||||
bash,
|
bash,
|
||||||
cacert,
|
cacert,
|
||||||
coreutils,
|
coreutils,
|
||||||
|
@ -44,59 +46,64 @@
|
||||||
|
|
||||||
pacman_conf = concatText "pacman.conf" [ "${pacman}/etc/pacman.conf" pacman_conf_in ];
|
pacman_conf = concatText "pacman.conf" [ "${pacman}/etc/pacman.conf" pacman_conf_in ];
|
||||||
|
|
||||||
bootstrap = writeShellApplication {
|
bootstrap = resholve.writeScriptBin "archlinux-bootstrap" {
|
||||||
name = "archlinux-bootstrap";
|
interpreter = "${bash}/bin/bash";
|
||||||
|
inputs = [ coreutils pacman systemd ];
|
||||||
|
execer = [
|
||||||
|
"cannot:${pacman}/bin/pacman-key"
|
||||||
|
"cannot:${systemd}/bin/systemd-nspawn"
|
||||||
|
];
|
||||||
|
} ''
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
runtimeInputs = [ coreutils pacman systemd ];
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "usage: $0 [directory] [pkgs ...]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
text = ''
|
newroot="$1"
|
||||||
if [ $# -lt 1 ]; then
|
shift
|
||||||
echo "usage: $0 [directory] [pkgs ...]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
newroot="$1"
|
echo "Installing arch linux to $newroot"
|
||||||
shift
|
|
||||||
|
|
||||||
echo "Installing arch linux to $newroot"
|
# set up new base filesystem
|
||||||
|
install -dm0755 "$newroot"
|
||||||
|
install -dm0755 "$newroot"/var/{cache/pacman/pkg,lib/pacman,log}
|
||||||
|
install -dm0755 "$newroot"/{dev,run,etc/pacman.d}
|
||||||
|
install -dm1777 "$newroot"/tmp
|
||||||
|
install -dm0555 "$newroot"/{sys,proc}
|
||||||
|
|
||||||
# set up new base filesystem
|
# set up mountpoint for nix
|
||||||
install -dm0755 "$newroot"
|
install -dm0755 "$newroot"/nix
|
||||||
install -dm0755 "$newroot"/var/{cache/pacman/pkg,lib/pacman,log}
|
|
||||||
install -dm0755 "$newroot"/{dev,run,etc/pacman.d}
|
|
||||||
install -dm1777 "$newroot"/tmp
|
|
||||||
install -dm0555 "$newroot"/{sys,proc}
|
|
||||||
|
|
||||||
# set up mountpoint for nix
|
# temporarily set up /etc/mtab, pacman needs this to work
|
||||||
install -dm0755 "$newroot"/nix
|
ln -sf /proc/mounts "$newroot"/etc/mtab
|
||||||
|
|
||||||
# temporarily set up /etc/mtab, pacman needs this to work
|
# fully initialize the keyring ahead of entering the container
|
||||||
ln -sf /proc/mounts "$newroot"/etc/mtab
|
pacman_conf="${pacman_conf}"
|
||||||
|
pacman-key --gpgdir "$newroot"/etc/pacman.d/gnupg --config "$pacman_conf" --init
|
||||||
|
pacman-key --gpgdir "$newroot"/etc/pacman.d/gnupg --config "$pacman_conf" \
|
||||||
|
--populate archlinux --populate-from "${keyring}/share/pacman/keyrings"
|
||||||
|
|
||||||
# fully initialize the keyring ahead of entering the container
|
# install the config file
|
||||||
pacman_conf="${pacman_conf}"
|
install -Dm0755 "$pacman_conf" "$newroot"/etc/pacman.conf
|
||||||
pacman-key --gpgdir "$newroot"/etc/pacman.d/gnupg --config "$pacman_conf" --init
|
|
||||||
pacman-key --gpgdir "$newroot"/etc/pacman.d/gnupg --config "$pacman_conf" \
|
|
||||||
--populate archlinux --populate-from "${keyring}/share/pacman/keyrings"
|
|
||||||
|
|
||||||
# install the config file
|
# bootstrap the system. allow pacman to overwrite the existing mtab entry
|
||||||
install -Dm0755 "$pacman_conf" "$newroot"/etc/pacman.conf
|
systemd-nspawn -D "$newroot" --bind-ro=/nix \
|
||||||
|
-E SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt \
|
||||||
|
-E PATH=/usr/bin/ \
|
||||||
|
-- \
|
||||||
|
"${pacman}/bin/pacman" -Sy --noconfirm --overwrite /etc/mtab base "$@"
|
||||||
|
|
||||||
# bootstrap the system. allow pacman to overwrite the existing mtab entry
|
# remove nix mount point
|
||||||
systemd-nspawn -D "$newroot" --bind-ro=/nix \
|
rmdir "$newroot"/nix
|
||||||
-E SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt \
|
|
||||||
-E PATH=/usr/bin/ \
|
|
||||||
-- \
|
|
||||||
"${pacman}/bin/pacman" -Sy --noconfirm --overwrite /etc/mtab base "$@"
|
|
||||||
|
|
||||||
# remove nix mount point
|
echo "Done installing!"
|
||||||
rmdir "$newroot"/nix
|
echo "Set root password:"
|
||||||
|
echo " sudo systemd-nspawn -UD \"$newroot\" -- /bin/passwd root"
|
||||||
echo "Done installing!"
|
echo "Boot system:"
|
||||||
echo "Set root password:"
|
echo " sudo systemd-nspawn -bUD \"$newroot\""
|
||||||
echo " sudo systemd-nspawn -UD \"$newroot\" -- /bin/passwd root"
|
'';
|
||||||
echo "Boot system:"
|
|
||||||
echo " sudo systemd-nspawn -bUD \"$newroot\""
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue