105 lines
2.8 KiB
Bash
105 lines
2.8 KiB
Bash
#!/run/current-system/profile/bin/bash
|
|
#
|
|
# Guix Simplified Installer
|
|
#
|
|
# Copyright (C) 2024 Adrien Bourmault <neox@a-lec.org>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
set +x
|
|
set -e
|
|
|
|
# Définition des couleurs
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
LIGHT_RED='\033[1;31m'
|
|
LIGHT_GREEN='\033[1;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[1;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${LIGHT_RED}Welcome to Guix Simplified Installer${NC}"
|
|
echo -e "${NC}Copyright (C) 2024 Adrien Bourmault <neox@a-lec.org>${NC}"
|
|
echo -e "${NC}This program is free software, released under the GNU AGPL version 3 or later.${NC}"
|
|
|
|
|
|
# Chemin vers le disque
|
|
DISK="$1"
|
|
|
|
# Vérification de l'existence du disque
|
|
if [ ! -b "$DISK" ]; then
|
|
echo -e "${RED}Creating disk layout...${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e -n "${BLUE}Downloading configuration...${NC}"
|
|
|
|
rm -f config.scm
|
|
wget forge.chalec.org/neox/guix_jerome/raw/branch/master/config.scm
|
|
|
|
echo -e "${GREEN}OK${NC}"
|
|
echo -e -n "${BLUE}Creating disk layout...${NC}"
|
|
|
|
parted -s "$DISK" mklabel gpt
|
|
parted -s "$DISK" mkpart primary fat32 1MiB 5%
|
|
parted -s "$DISK" mkpart primary ext4 5% 100%
|
|
parted -s "$DISK" print
|
|
|
|
echo -e "${GREEN}OK${NC}"
|
|
echo -e -n "${BLUE}Setting up root partition encryption...${NC}"
|
|
|
|
cryptsetup luksFormat "${DISK}p2"
|
|
|
|
echo -e "${GREEN}OK${NC}"
|
|
echo -e -n "${BLUE}Unlocking root partition...${NC}"
|
|
|
|
cryptsetup open "${DISK}p2" ROOT
|
|
|
|
echo -e "${GREEN}OK${NC}"
|
|
echo -e -n "${BLUE}Formatting disks partitions...${NC}"
|
|
|
|
mkfs.vfat "${DISK}p1"
|
|
mkfs.ext4 -L ROOT /dev/mapper/ROOT
|
|
|
|
echo -e "${GREEN}OK${NC}"
|
|
echo -e -n "${BLUE}Updating disk configuration...${NC}"
|
|
|
|
UUID=$(blkid -o value -s UUID "${DISK}p2")
|
|
sed -i "s/CHANGE_THIS_UUID/${UUID}/g" config.scm
|
|
UUID2=$(blkid -o value -s UUID "${DISK}p1")
|
|
sed -i "s/CHANGE_THIS_DISK/${UUID2}/g" config.scm
|
|
|
|
echo -e "${GREEN}OK${NC}"
|
|
echo -e -n "${BLUE}Mounting disks...${NC}"
|
|
|
|
mount LABEL=ROOT /mnt
|
|
mkdir -p /mnt/boot/efi
|
|
mount "${DISK}p1" /mnt/boot/efi
|
|
|
|
echo -e "${GREEN}OK${NC}"
|
|
echo -e -n "${BLUE}Moving configuration to its final location...${NC}"
|
|
|
|
mkdir /mnt/etc
|
|
mv config.scm /mnt/etc/config.scm
|
|
|
|
echo -e "${GREEN}OK${NC}"
|
|
|
|
echo -e -n "${BLUE}Installing GNU Guix${NC}"
|
|
|
|
herd start cow-store /mnt
|
|
|
|
guix system init /mnt/etc/config.scm /mnt
|
|
|
|
echo -e "${GREEN}OK${NC}"
|