feat(installer): add internet wizard, localization, and software profiles
- Add interactive internet connectivity check with nmtui wizard - Implement searchable timezone selection using gum filter - Add keyboard layout selection with custom input fallback - Implement multi-select software profiles (Dev, Gaming, Media) - Generate clean downstream scaffolding with system.nix/home.nix stubs
This commit is contained in:
@@ -3,6 +3,33 @@ set -e
|
|||||||
|
|
||||||
echo "Welcome to the Nomarchy - A NixOS-based distribution with Omarchy flavour Installer"
|
echo "Welcome to the Nomarchy - A NixOS-based distribution with Omarchy flavour Installer"
|
||||||
|
|
||||||
|
echo "Checking internet connectivity..."
|
||||||
|
while ! ping -c 1 8.8.8.8 &> /dev/null; do
|
||||||
|
echo "Error: No internet connection detected. An active connection is required to install Nomarchy."
|
||||||
|
CHOICE=$(gum choose "Open Network Manager (nmtui)" "Retry Connection" "Exit Installer")
|
||||||
|
if [ "$CHOICE" = "Open Network Manager (nmtui)" ]; then
|
||||||
|
nmtui
|
||||||
|
elif [ "$CHOICE" = "Exit Installer" ]; then
|
||||||
|
echo "Exiting installer."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Re-checking internet connectivity..."
|
||||||
|
done
|
||||||
|
echo "Internet connection verified."
|
||||||
|
|
||||||
|
# 0. Environment Setup
|
||||||
|
NOMARCHY_REPO=""
|
||||||
|
if [ -d "/etc/nomarchy" ]; then
|
||||||
|
NOMARCHY_REPO="/etc/nomarchy"
|
||||||
|
elif [ -d "$(dirname "$0")/.." ] && [ -f "$(dirname "$0")/../flake.nix" ]; then
|
||||||
|
NOMARCHY_REPO="$(realpath "$(dirname "$0")/..")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$NOMARCHY_REPO" ]; then
|
||||||
|
echo "Nomarchy repository not found. Please run this script from the repository root or on a Nomarchy live ISO."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# 1. Hardware Detection & Mapping
|
# 1. Hardware Detection & Mapping
|
||||||
PRODUCT_NAME=$(cat /sys/class/dmi/id/product_name 2>/dev/null || echo "Unknown")
|
PRODUCT_NAME=$(cat /sys/class/dmi/id/product_name 2>/dev/null || echo "Unknown")
|
||||||
BOARD_NAME=$(cat /sys/class/dmi/id/board_name 2>/dev/null || echo "Unknown")
|
BOARD_NAME=$(cat /sys/class/dmi/id/board_name 2>/dev/null || echo "Unknown")
|
||||||
@@ -75,15 +102,24 @@ fi
|
|||||||
|
|
||||||
echo "Select the partition layout:"
|
echo "Select the partition layout:"
|
||||||
LAYOUT=$(gum choose "Standard Ext4" "Encrypted BTRFS (LUKS2)")
|
LAYOUT=$(gum choose "Standard Ext4" "Encrypted BTRFS (LUKS2)")
|
||||||
|
IMPERMANENCE="No"
|
||||||
if [ "$LAYOUT" = "Standard Ext4" ]; then
|
if [ "$LAYOUT" = "Standard Ext4" ]; then
|
||||||
DISKO_NIX="/etc/disko-ext4.nix"
|
DISKO_FILE="installer/disko-ext4.nix"
|
||||||
else
|
else
|
||||||
DISKO_NIX="/etc/disko-btrfs-luks.nix"
|
DISKO_FILE="installer/disko-btrfs-luks.nix"
|
||||||
|
echo "Enable Impermanence? (Erase root partition on every boot)"
|
||||||
|
IMPERMANENCE=$(gum choose "Yes" "No")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "/etc/$(basename "$DISKO_FILE")" ]; then
|
||||||
|
DISKO_NIX="/etc/$(basename "$DISKO_FILE")"
|
||||||
|
else
|
||||||
|
DISKO_NIX="$NOMARCHY_REPO/$DISKO_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TMP_DISKO=$(mktemp --suffix=.nix)
|
TMP_DISKO=$(mktemp --suffix=.nix)
|
||||||
sed "s|@TARGET_DRIVE@|$TARGET_DRIVE|g" "$DISKO_NIX" > "$TMP_DISKO"
|
sed "s|@TARGET_DRIVE@|$TARGET_DRIVE|g" "$DISKO_NIX" > "$TMP_DISKO"
|
||||||
sudo disko --mode disko "$TMP_DISKO"
|
sudo env PATH="$PATH" disko --mode disko "$TMP_DISKO"
|
||||||
|
|
||||||
# 3. User Details
|
# 3. User Details
|
||||||
USERNAME=$(gum input --placeholder "Enter target username")
|
USERNAME=$(gum input --placeholder "Enter target username")
|
||||||
@@ -92,7 +128,52 @@ if [ -z "$USERNAME" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 4. Login Preferences
|
# 4. Localization
|
||||||
|
echo "Select your Timezone (e.g., America/New_York, Europe/London):"
|
||||||
|
TIMEZONES=$(timedatectl list-timezones || echo "UTC")
|
||||||
|
TIMEZONE=$(echo "$TIMEZONES" | gum filter --placeholder "Type to search timezones...")
|
||||||
|
if [ -z "$TIMEZONE" ]; then
|
||||||
|
echo "No timezone selected. Defaulting to UTC."
|
||||||
|
TIMEZONE="UTC"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Select your Keyboard Layout:"
|
||||||
|
LAYOUT_SELECTION=$(gum choose "us" "uk" "de" "fr" "es" "it" "br-abnt2" "latam" "Other...")
|
||||||
|
if [ "$LAYOUT_SELECTION" = "Other..." ]; then
|
||||||
|
KEYBOARD_LAYOUT=$(gum input --placeholder "Enter your keyboard layout (e.g., jp, se, ch)")
|
||||||
|
else
|
||||||
|
KEYBOARD_LAYOUT="$LAYOUT_SELECTION"
|
||||||
|
fi
|
||||||
|
if [ -z "$KEYBOARD_LAYOUT" ]; then
|
||||||
|
echo "No layout selected. Defaulting to us."
|
||||||
|
KEYBOARD_LAYOUT="us"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4.5. Software Profiles
|
||||||
|
echo "Select additional software profiles to install (Press Space to select, Enter to confirm):"
|
||||||
|
PROFILES=$(gum choose --no-limit "Development (VSCode, Docker, DBs)" "Gaming (Steam, Lutris)" "Media Production (OBS, Kdenlive)")
|
||||||
|
|
||||||
|
PROFILE_SYSTEM_PKGS=""
|
||||||
|
PROFILE_HOME_PKGS=""
|
||||||
|
PROFILE_SYSTEM_CONFIG=""
|
||||||
|
|
||||||
|
if [[ $PROFILES == *"Development"* ]]; then
|
||||||
|
PROFILE_HOME_PKGS="$PROFILE_HOME_PKGS\n vscode\n docker-compose\n dbeaver-bin"
|
||||||
|
PROFILE_SYSTEM_CONFIG="$PROFILE_SYSTEM_CONFIG\n virtualisation.docker.enable = true;"
|
||||||
|
fi
|
||||||
|
if [[ $PROFILES == *"Gaming"* ]]; then
|
||||||
|
PROFILE_HOME_PKGS="$PROFILE_HOME_PKGS\n lutris\n protonup-qt\n mangohud"
|
||||||
|
PROFILE_SYSTEM_CONFIG="$PROFILE_SYSTEM_CONFIG\n programs.steam.enable = true;"
|
||||||
|
fi
|
||||||
|
if [[ $PROFILES == *"Media Production"* ]]; then
|
||||||
|
PROFILE_HOME_PKGS="$PROFILE_HOME_PKGS\n obs-studio\n kdenlive\n gimp\n audacity"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$IMPERMANENCE" == "Yes" ]]; then
|
||||||
|
PROFILE_SYSTEM_CONFIG="$PROFILE_SYSTEM_CONFIG\n nomarchy.system.impermanence.enable = true;"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 5. Login Preferences
|
||||||
echo "Select login preference:"
|
echo "Select login preference:"
|
||||||
LOGIN_PREF=$(gum choose "SDDM Auto-login" "Require Password")
|
LOGIN_PREF=$(gum choose "SDDM Auto-login" "Require Password")
|
||||||
|
|
||||||
@@ -105,34 +186,57 @@ cat <<EOF > /mnt/etc/nixos/login-preference.nix
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Generate /mnt/etc/nixos/localization.nix
|
||||||
|
cat <<EOF > /mnt/etc/nixos/localization.nix
|
||||||
|
{
|
||||||
|
time.timeZone = "$TIMEZONE";
|
||||||
|
services.xserver.xkb.layout = "$KEYBOARD_LAYOUT";
|
||||||
|
console.keyMap = "$KEYBOARD_LAYOUT";
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
# Generate /mnt/etc/nixos/hardware-selection.nix
|
# Generate /mnt/etc/nixos/hardware-selection.nix
|
||||||
cat <<EOF > /mnt/etc/nixos/hardware-selection.nix
|
cat <<EOF > /mnt/etc/nixos/hardware-selection.nix
|
||||||
{ inputs, ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
$(echo "$HARDWARE_MODULES")
|
$(echo -e "$HARDWARE_MODULES")
|
||||||
];
|
];
|
||||||
|
|
||||||
$NOMARCHY_HW_OPTS
|
$NOMARCHY_HW_OPTS
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 5. Hardware Config
|
# 6. Hardware Config
|
||||||
nixos-generate-config --root /mnt
|
nixos-generate-config --root /mnt
|
||||||
|
|
||||||
# 6. Modular Downstream Scaffolding
|
# 7. Modular Downstream Scaffolding
|
||||||
mkdir -p /mnt/etc/nixos/
|
mkdir -p /mnt/etc/nixos/
|
||||||
|
|
||||||
# Create system.nix (User System Customization)
|
# Create system.nix (User System Customization)
|
||||||
cat <<EOF > /mnt/etc/nixos/system.nix
|
cat <<EOF > /mnt/etc/nixos/system.nix
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
# Add your personal system-level NixOS modules here.
|
# Add your personal system-level NixOS settings here.
|
||||||
# Example: agenix.nixosModules.default
|
# This file is for your own custom NixOS modules.
|
||||||
|
$(echo -e "$PROFILE_SYSTEM_CONFIG")
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
# Add extra system-wide packages here
|
# Add extra system-wide packages here
|
||||||
|
# wget
|
||||||
|
# htop$(echo -e "$PROFILE_SYSTEM_PKGS")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Example: How to persist extra directories if using Impermanence
|
||||||
|
# environment.persistence."/persist" = {
|
||||||
|
# directories = [
|
||||||
|
# "/var/lib/docker"
|
||||||
|
# "/root/.ssh"
|
||||||
|
# ];
|
||||||
|
# files = [
|
||||||
|
# "/etc/my-secret-token.txt"
|
||||||
|
# ];
|
||||||
|
# };
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -140,11 +244,18 @@ EOF
|
|||||||
cat <<EOF > /mnt/etc/nixos/home.nix
|
cat <<EOF > /mnt/etc/nixos/home.nix
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
# Add your personal Home Manager modules here.
|
# Add your personal Home Manager settings here.
|
||||||
|
# This file is for your own custom user modules.
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
# Add extra user-level packages here
|
# Add extra user-level packages here
|
||||||
|
# neofetch
|
||||||
|
# ripgrep$(echo -e "$PROFILE_HOME_PKGS")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Example: How to override Nomarchy defaults
|
||||||
|
# nomarchy.home.terminal = "kitty";
|
||||||
|
# nomarchy.home.themeOverride = "catppuccin-mocha";
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -154,30 +265,28 @@ cat <<EOF > /mnt/etc/nixos/flake.nix
|
|||||||
description = "My Nomarchy - Downstream Configuration";
|
description = "My Nomarchy - Downstream Configuration";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
|
||||||
nomarchy.url = "path:./nomarchy"; # Offline bundled nomarchy
|
nomarchy.url = "path:./nomarchy"; # Offline bundled nomarchy
|
||||||
|
|
||||||
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
||||||
home-manager = {
|
home-manager = {
|
||||||
url = "github:nix-community/home-manager";
|
url = "github:nix-community/home-manager/release-25.11";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
# EXAMPLE: Add agenix for secrets
|
|
||||||
# agenix.url = "github:ryantm/agenix";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, nomarchy, home-manager, ... }@inputs: {
|
outputs = { self, nixpkgs, nomarchy, home-manager, ... }@inputs: {
|
||||||
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
|
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
specialArgs = { inputs = nomarchy.inputs // inputs; };
|
||||||
specialArgs = { inherit inputs; };
|
|
||||||
modules = [
|
modules = [
|
||||||
|
{ nixpkgs.hostPlatform = "x86_64-linux"; }
|
||||||
# 1. Hardware
|
# 1. Hardware
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./hardware-selection.nix
|
./hardware-selection.nix
|
||||||
|
|
||||||
# 2. Login & Preferences
|
# 2. Login & Preferences
|
||||||
./login-preference.nix
|
./login-preference.nix
|
||||||
|
./localization.nix
|
||||||
|
|
||||||
# 3. Upstream Nomarchy Core
|
# 3. Upstream Nomarchy Core
|
||||||
nomarchy.nixosModules.system
|
nomarchy.nixosModules.system
|
||||||
@@ -197,7 +306,7 @@ cat <<EOF > /mnt/etc/nixos/flake.nix
|
|||||||
];
|
];
|
||||||
home.username = "$USERNAME";
|
home.username = "$USERNAME";
|
||||||
home.homeDirectory = "/home/$USERNAME";
|
home.homeDirectory = "/home/$USERNAME";
|
||||||
home.stateVersion = "24.05";
|
home.stateVersion = "25.11";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -207,8 +316,8 @@ cat <<EOF > /mnt/etc/nixos/flake.nix
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 7. Copy Bundled Flake
|
# 7. Copy Bundled Flake
|
||||||
echo "Copying bundled upstream Nomarchy flake..."
|
echo "Copying bundled upstream Nomarchy flake from $NOMARCHY_REPO..."
|
||||||
cp -rL /etc/nomarchy /mnt/etc/nixos/nomarchy
|
cp -rL "$NOMARCHY_REPO" /mnt/etc/nixos/nomarchy
|
||||||
chmod -R u+w /mnt/etc/nixos/nomarchy
|
chmod -R u+w /mnt/etc/nixos/nomarchy
|
||||||
|
|
||||||
# 8. Version Control
|
# 8. Version Control
|
||||||
@@ -219,5 +328,14 @@ git config user.name "Nomarchy Installer"
|
|||||||
git config user.email "installer@nomarchy"
|
git config user.email "installer@nomarchy"
|
||||||
git commit -m "Initial Nomarchy generation"
|
git commit -m "Initial Nomarchy generation"
|
||||||
|
|
||||||
|
# 8.5. Impermanence Redirection
|
||||||
|
if [[ "$IMPERMANENCE" == "Yes" ]]; then
|
||||||
|
echo "Redirecting /etc/nixos to persistent storage..."
|
||||||
|
mkdir -p /mnt/persist/etc
|
||||||
|
mv /mnt/etc/nixos /mnt/persist/etc/
|
||||||
|
mkdir -p /mnt/etc
|
||||||
|
ln -s /persist/etc/nixos /mnt/etc/nixos
|
||||||
|
fi
|
||||||
|
|
||||||
# 9. Execution
|
# 9. Execution
|
||||||
nixos-install --flake /mnt/etc/nixos#default --no-root-passwd
|
nixos-install --flake /mnt/etc/nixos#default --no-root-passwd
|
||||||
|
|||||||
Reference in New Issue
Block a user