mirror of
https://git.in.rschanz.org/ryan77627/guix-config.git
synced 2024-11-07 07:36:09 -05:00
103 lines
3.2 KiB
Bash
Executable file
103 lines
3.2 KiB
Bash
Executable file
#!/run/current-system/profile/bin/bash
|
|
|
|
gather_env() {
|
|
# Gather needed information
|
|
echo -n "Type 'e' for encrypted or 'd' for decrypted install: "
|
|
read install_type
|
|
|
|
echo -n "Type system hostname: "
|
|
read install_hostname
|
|
|
|
echo -n "Type device file for ROOT data: "
|
|
read root_dev
|
|
|
|
echo -n "Type device file for BOOT data: "
|
|
read boot_dev
|
|
|
|
echo -n "Type device file for SWAP: "
|
|
read swap_dev
|
|
|
|
}
|
|
|
|
copy_and_prepare() {
|
|
# Associate devs with uuids
|
|
root_uuid=`blkid $root_dev | awk -F\" '{print $2}'`
|
|
boot_uuid=`blkid $boot_dev | awk -F\" '{print $2}'`
|
|
swap_uuid=`blkid $swap_dev | awk -F\" '{print $2}'`
|
|
# Let's a go!
|
|
echo "Information gathered. Deploying Guix on $root_dev ($root_uuid) with boot on $boot_dev ($boot_uuid) and swap on $swap_dev ($swap_uuid)"
|
|
echo -n "Proceed? (y/n): "
|
|
read install_choice
|
|
|
|
if [ "$install_choice" != "y" ]
|
|
then
|
|
echo "Bailing!"
|
|
exit 1
|
|
fi
|
|
|
|
# We are installing!
|
|
# Copy template to root of repo
|
|
if [ "$install_type" == "e" ]
|
|
then
|
|
cp ./modules/ryan-config/deploy-templates/HostTemplateEncrypted.scm ./$install_hostname.scm
|
|
elif [ "$install_type" == "d" ]
|
|
then
|
|
cp ./modules/ryan-config/deploy-templates/HostTemplate.scm ./$install_hostname.scm
|
|
else
|
|
echo "Invalid install type (not d or e), bailing!"
|
|
exit 1
|
|
fi
|
|
|
|
# Correct the information
|
|
sed -i "s/ChangeMe_ROOT/$root_uuid/" ./$install_hostname.scm
|
|
sed -i "s/ChangeMe_BOOTEFI/$boot_uuid/" ./$install_hostname.scm
|
|
sed -i "s/ChangeMe_SWAP/$swap_uuid/" ./$install_hostname.scm
|
|
sed -i "s/ChangeMe_HOST/$install_hostname/" ./$install_hostname.scm
|
|
|
|
# Install!
|
|
echo "Mounting /gnu/store to destination disk..."
|
|
herd start cow-store /mnt
|
|
|
|
# Install the non-guix signing keys
|
|
echo "Installing non-guix signing keys for substitutes..."
|
|
curl -o sign-key.pub https://substitutes.nonguix.org/signing-key.pub
|
|
guix archive --authorize < sign-key.pub
|
|
}
|
|
|
|
install_system() {
|
|
echo "Beginning install!"
|
|
guix time-machine -C ./channels.scm -- system -L ./modules --substitute-urls='https://substitutes.nonguix.org https://bordeaux.guix.gnu.org https://ci.guix.gnu.org' init $install_hostname.scm /mnt
|
|
}
|
|
|
|
install_user_env() {
|
|
# System should be installed now, we can chroot in and configure the user profile now
|
|
# NOTE: This assumes the user "ryan" for things, so change the USER var if you change your username
|
|
|
|
# Mount the special block devices to prepare for chroot
|
|
mount --rbind /proc /mnt/proc
|
|
mount --rbind /sys /mnt/sys
|
|
mount --rbind /dev /mnt/dev
|
|
|
|
# chroot into system and run commands
|
|
# First copy the file
|
|
cp ~/guix-dotfiles/$install_hostname /mnt/$install_hostname.scm
|
|
USER=ryan
|
|
chroot /mnt <<EOT
|
|
|
|
# Activate commands
|
|
source /var/guix/profiles/system/profile/etc/profile
|
|
/var/guix/profiles/system/activate
|
|
guix-daemon --build-users-group=guixbuild --disable-chroot &
|
|
|
|
guix shell git -- git clone https://git.stationery.faith/ryan77627/guix-dotfiles /home/$USER/.config/guix
|
|
|
|
mv /$install_hostname.scm /home/$USER/.config/guix/$install_hostname.scm
|
|
|
|
EOT
|
|
|
|
}
|
|
|
|
gather_env
|
|
copy_and_prepare
|
|
install_system
|
|
install_user_env
|