This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / tools / build-installer-iso / flake-module.nix
3.3 kB 117 lines
1{ self, nixpkgs, clan-core, ... }: 2let 3 # Shared installer configuration module 4 installerModule = { modulesPath, pkgs, ... }: { 5 imports = [ 6 # ../../2configs/installer-tor.nix 7 (modulesPath + "/image/images.nix") 8 ]; 9 10 # Basic installer configuration 11 networking.hostName = "installer"; 12 13 # Enable emergency access in initrd for debugging 14 boot.initrd.systemd.emergencyAccess = true; 15 16 # Enable serial console for VM usage 17 boot.kernelParams = [ "console=ttyS0,115200n8" "console=tty0" ]; 18 19 # Configure systemd for serial console 20 systemd.services."serial-getty@ttyS0" = { 21 enable = true; 22 wantedBy = [ "getty.target" ]; 23 serviceConfig.Restart = "always"; 24 }; 25 26 # Auto-mount ISO and extract vars 27 systemd.services.extract-vars = { 28 description = "Extract vars from ISO"; 29 wantedBy = [ "multi-user.target" ]; 30 after = [ "local-fs.target" ]; 31 path = with pkgs; [ util-linux coreutils ]; 32 serviceConfig = { 33 Type = "oneshot"; 34 RemainAfterExit = true; 35 }; 36 script = '' 37 set -euxo pipefail 38 39 # Find the ISO device (usually sr0, but could be others) 40 ISO_DEVICE="" 41 for dev in /dev/sr*; do 42 if [ -b "$dev" ]; then 43 ISO_DEVICE="$dev" 44 break 45 fi 46 done 47 48 if [ -z "$ISO_DEVICE" ]; then 49 echo "No ISO device found, checking loop devices..." 50 for dev in /dev/loop*; do 51 if [ -b "$dev" ] && lsblk -no FSTYPE "$dev" 2>/dev/null | grep -q iso9660; then 52 ISO_DEVICE="$dev" 53 break 54 fi 55 done 56 fi 57 58 if [ -n "$ISO_DEVICE" ]; then 59 echo "Found ISO device: $ISO_DEVICE" 60 mkdir -p /mnt/iso 61 if mount -t iso9660 -o ro "$ISO_DEVICE" /mnt/iso; then 62 echo "Successfully mounted ISO" 63 if [ -d /mnt/iso/vars ]; then 64 echo "Extracting vars to /vars" 65 cp -r /mnt/iso/vars /vars 66 chmod -R u+w /vars 67 echo "Vars extracted successfully" 68 else 69 echo "No vars directory found in ISO" 70 fi 71 else 72 echo "Failed to mount ISO device $ISO_DEVICE" 73 fi 74 else 75 echo "No ISO device found" 76 fi 77 ''; 78 }; 79 }; 80in 81{ 82 flake = { 83 # Export the installer module for reuse 84 nixosModules.installer = installerModule; 85 86 # Define installer configurations for each architecture 87 nixosConfigurations = { 88 installer-x86_64-linux = nixpkgs.lib.nixosSystem { 89 system = "x86_64-linux"; 90 modules = [ installerModule ]; 91 }; 92 93 installer-aarch64-linux = nixpkgs.lib.nixosSystem { 94 system = "aarch64-linux"; 95 modules = [ installerModule ]; 96 }; 97 }; 98 }; 99 100 perSystem = 101 { pkgs, ... }: 102 { 103 packages.build-installer-iso = pkgs.writeShellApplication { 104 name = "build-installer-iso"; 105 runtimeInputs = with pkgs; [ 106 xorriso 107 coreutils 108 nix 109 ]; 110 text = '' 111 # Export flake root for the script to use 112 export FLAKE_ROOT="${self}" 113 ${builtins.readFile ./build-installer-iso.sh} 114 ''; 115 }; 116 }; 117}