2024-08-05 17:17:33 +03:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
let
|
2024-08-05 18:45:59 +03:00
|
|
|
partition-and-install = pkgs.writeScriptBin "partition-and-install" ''
|
|
|
|
read -p "Erasing disk $1 Are you sure? " -n 1 -r
|
|
|
|
echo
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
parted $1 -- mklabel gpt
|
|
|
|
parted $1 -- mkpart root ext4 512MB 100%
|
|
|
|
parted $1 -- mkpart ESP fat32 1MB 512MB
|
|
|
|
parted $1 -- set 2 esp on
|
|
|
|
|
|
|
|
mkfs.ext4 -L nixos $1$2
|
|
|
|
mkfs.fat -F 32 -n BOOT $1$3
|
|
|
|
|
|
|
|
mount /dev/disk/by-label/nixos /mnt
|
|
|
|
mkdir /mnt/boot
|
|
|
|
mount -o umask=077 /dev/disk/by-label/BOOT /mnt/boot
|
|
|
|
|
2024-08-07 16:59:23 +03:00
|
|
|
fetch-config
|
2024-08-05 18:45:59 +03:00
|
|
|
|
2024-08-07 15:51:07 +03:00
|
|
|
nixos-install
|
2024-08-05 18:45:59 +03:00
|
|
|
fi
|
2024-08-05 17:17:33 +03:00
|
|
|
'';
|
2024-08-07 16:59:23 +03:00
|
|
|
fetch-config = pkgs.writeScriptBin "fetch-config" ''
|
|
|
|
nixos-generate-config --root /mnt
|
|
|
|
mv /mnt/etc/nixos/configuration.nix configuration.nix.old
|
|
|
|
curl https://raw.githubusercontent.com/VSinerva/nixos-conf/main/misc/template-configuration.nix -o /mnt/etc/nixos/configuration.nix
|
|
|
|
'';
|
2024-08-05 17:17:33 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
|
|
|
|
../base.nix
|
|
|
|
];
|
|
|
|
|
2024-08-07 16:59:23 +03:00
|
|
|
environment.systemPackages = [
|
|
|
|
partition-and-install
|
|
|
|
fetch-config
|
|
|
|
];
|
2024-08-05 18:45:59 +03:00
|
|
|
|
|
|
|
#Many installs will need this, and it won't hurt either way
|
|
|
|
services.qemuGuest.enable = true;
|
2024-08-07 15:51:07 +03:00
|
|
|
|
|
|
|
#Prevent user from being locked out of the system before switching to proper config
|
|
|
|
users.mutableUsers = pkgs.lib.mkForce true;
|
2024-08-05 17:17:33 +03:00
|
|
|
}
|