guix strap done (hopefully)

This commit is contained in:
Freya Murphy 2023-10-07 16:59:12 -04:00
parent 1e27186f00
commit 0be7c27439
No known key found for this signature in database
GPG key ID: 988032A5638EE799
9 changed files with 191 additions and 16 deletions

49
guix-strap/guix-configure Executable file
View file

@ -0,0 +1,49 @@
#!/run/current-system/profile/bin/bash
source ./guix-log
source ./guix-env
HOSTNAME=""
CRYPT_UUID=""
EFI_UUID=""
get_uuid() {
blkid -s UUID -o value $1
}
CRYPT_UUID=$(get_uuid $CRYPT_PARTITION)
EFI_UUID=$(get_uuid $EFI_PARTITION)
get_hostname() {
CONFIRM=""
read -p "Enter system hostname: " HOSTNAME
if [ ! -z "$HOSTNAME" -a "$HOSTNAME" != " " ]; then
(confirm "$HOSTNAME");
if [ "$?" -ne 0 ]; then
get_hostname
fi
else
ERROR "'$HOSTNAME' is not a valid hostname"
fi
}
EVENT "Getting hostname"
get_hostname
EVENT "Hostname set to '$HOSTNAME'"
EVENT "Generating system config file"
cp system.scm "$HOSTNAME.scm"
sed -i "s/SED_CRYPT_UUID/$CRYPT_UUId/" ./$HOSTNAME.scm
sed -i "s/SED_EFI_UUID/$EFI_UUID/" ./$HOSTNAME.scm
sed -i "s/SED_HOSTNAME/$HOSTNAME/" ./$HOSTNAME.scm
mv "$HOSTNAME.scm" ..
EVENT "Successfully configured $HOSTNAME.scm"
echo "HOSTNAME=\"$HOSTNAME\"" >> ./guix-env
echo "CRYPT_UUID=\"$CRYPT_UUID\"" >> ./guix-env
echo "EFI_UUID=\"$EFI_UUID\"" >> ./guix-env

View file

@ -1,3 +0,0 @@
#!/run/current-system/profile/bin/bash
# added by scripts during runtime!!!

25
guix-strap/guix-install Executable file
View file

@ -0,0 +1,25 @@
#!/run/current-system/profile/bin/bash
source ./guix-env
source ./guix-log
EVENT "Mounting /gnu/store to destination disk..."
herd start cow-store /mnt
EVENT "Installing non-guix signing keys for substitutes..."
curl -o /tmp/sign-key.pub https://substitutes.nonguix.org/signing-key.pub
guix archive --authorize < /tmp/sign-key.pub
EVENT "Installing GNU Guix"
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 ../$HOSTNAME.scm /mnt
EVENT "Installing User Environment"
USER=tylerm
guix shell git -- git clone https://g.tylerm.dev/tylerm/dotfiles /mnt/home/$USER/.config/guix
cp ../$HOSTNAME.scm /mnt/home/$USER/.config/guix/$HOSTNAME.scm
cp ./guix-setup-user /mnt/home/$USER/.zprofile
chown 1000:1000 -R /mnt/home/$USER
EVENT "Successflly installed Guix root and user"

View file

@ -8,3 +8,16 @@ EVENT() {
printf "\x1b[95m>>> \x1b[0m\x1b[98m$1\n"
}
CONFIRM=""
confirm() {
if [ "$CONFIRM" == "y" ]; then
exit 0
fi
read -p "Are you sure: ($1)? [y/N] " CONFIRM
if [ "$CONFIRM" == "y" ]; then
exit 0
else
exit 1
fi
}

View file

@ -2,7 +2,6 @@
set -o emacs;
CONFIRM=""
DISK=""
source ./guix-log
@ -10,18 +9,6 @@ source ./guix-env
EVENT "Partitioning disks"
confirm() {
if [ "$CONFIRM" == "y" ]; then
exit 0
fi
read -p "Are you sure: ($1)? [y/N] " CONFIRM
if [ "$CONFIRM" == "y" ]; then
exit 0
else
exit 1
fi
}
check_disk() {
lsblk $1 &> /dev/null || exit 1
FS=$(df $1 | tail -n 1 | awk '{print $1}')

51
guix-strap/guix-password Executable file
View file

@ -0,0 +1,51 @@
#!/run/current-system/profile/bin/bash
USER_PASSWORD=""
ROOT_PASSWORD=""
source ./guix-env
source ./guix-log
get_root_password() {
read -s -p "Root password: " PASSWORD
printf "\n"
read -s -p "Confirm password: " PASSWORD_CONFIRM
printf "\n"
if [ "$PASSWORD" == "$PASSWORD_CONFIRM" ]; then
ROOT_PASSWORD=$PASSWORD
return
else
ERROR "Passwords do not match"
get_root_password
fi
}
get_user_password() {
read -s -p "User password: " PASSWORD
printf "\n"
read -s -p "Confirm password: " PASSWORD_CONFIRM
printf "\n"
if [ "$PASSWORD" == "$PASSWORD_CONFIRM" ]; then
USER_PASSWORD=$PASSWORD
return
else
ERROR "Passwords do not match"
get_user_password
fi
}
EVENT "Setup /etc/shadow for root and user"
get_root_password
get_user_password
cat << EOF | chroot /mnt
passwd
$ROOT_PASSWORD
$ROOT_PASSWORD
passwd tylerm
$USER_PASSWORD
$USER_PASSWORD
EOF
EVENT "Successfully set passwords"

View file

@ -1,5 +1,8 @@
#!/run/current-system/profile/bin/bash
echo "#!/run/current-system/profile/bin/bash" > ./guix-env
echo "" > ./guix-env
welcome() {
cat<<"EOF"
░░░ ░░░
@ -32,3 +35,9 @@ EOF
welcome
./guix-partition
./guix-crypt
./guix-configure
./guix-install
./guix-password
echo "GNU Guix has been installed, you can now reboot..."
exit 0

21
guix-strap/guix-setup-user Executable file
View file

@ -0,0 +1,21 @@
#!/run/current-system/profile/bin/bash
# This should run on user first logon, so let's a go!
# First, we should run a guix pull
guix pull
hash guix
guix home -L ~/.config/guix/modules reconfigure ~/.config/guix/home-config/home-configuration.scm
sudo -E herd restart nix-daemon
nix-channel --update
nix-shell '<home-manager>' -A install
rm ~/.zprofile
source ~/.config/zsh/.zprofile
home-manager switch

23
guix-strap/system.scm Normal file
View file

@ -0,0 +1,23 @@
(use-modules (home-config base-system)
(gnu))
(operating-system
(inherit base-operating-system)
(host-name "SED_HOSTNAME")
(mapped-devices (list (mapped-device
(source (uuid
"SED_CRYPT_UUID"))
(target "cryptroot")
(type luks-device-mapping))))
(file-systems (cons* (file-system
(mount-point "/")
(device "/dev/mapper/cryptroot")
(type "btrfs")
(dependencies mapped-devices))
(file-system
(mount-point "/boot/efi")
(device (uuid "SED_EFI_UUID"
'fat32))
(type "vfat")) %base-file-systems)))