From 27d75659d09deabfec1bb7b047aa22e6d73d49ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vili=20Sinerv=C3=A4?= Date: Mon, 5 Aug 2024 18:45:59 +0300 Subject: [PATCH] Create rough-and-ready full auto-install script for custom ISO --- misc/custom-iso.nix | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/misc/custom-iso.nix b/misc/custom-iso.nix index 7b99aca..f68ca78 100644 --- a/misc/custom-iso.nix +++ b/misc/custom-iso.nix @@ -1,8 +1,28 @@ { config, pkgs, ... }: let - fetch-config-template = pkgs.writeScriptBin "fetch-config-template" '' - mv configuration.nix configuration.nix.old - ${pkgs.curl}/bin/curl https://raw.githubusercontent.com/VSinerva/nixos-conf/main/misc/template-configuration.nix -o configuration.nix + 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 + + 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 + + nixos-install --no-root-password + fi ''; in { @@ -13,5 +33,8 @@ in ]; networking.networkmanager.enable = pkgs.lib.mkForce false; - environment.systemPackages = [ fetch-config-template ]; + environment.systemPackages = [ partition-and-install ]; + + #Many installs will need this, and it won't hurt either way + services.qemuGuest.enable = true; }