Files
Nomarchy/installer/install-nomarchy.sh
Bernardo Magri 29cc0d2547 feat: implement modular foundation and core system services
- Update flake.nix with 25.11 release and core inputs
- Add dedicated modules for audio (Pipewire), bluetooth, and networking
- Update GEMINI.md with the new Modular Merging Architecture blueprint
- Configure graphical installer ISO and test VM outputs
2026-04-03 21:06:42 +01:00

224 lines
7.2 KiB
Bash

#!/usr/bin/env bash
set -e
echo "Welcome to the Nomarchy - A NixOS-based distribution with Omarchy flavour Installer"
# 1. Hardware Detection & Mapping
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")
CPU_VENDOR=$(lscpu | grep "Vendor ID" | awk '{print $3}')
echo "Detected hardware: $PRODUCT_NAME ($BOARD_NAME)"
echo "Detected CPU: $CPU_VENDOR"
HARDWARE_MODULES=""
NOMARCHY_HW_OPTS=""
# Add generic CPU optimizations
if [[ "$CPU_VENDOR" == "AuthenticAMD" ]]; then
HARDWARE_MODULES="inputs.nixos-hardware.nixosModules.common-cpu-amd"
elif [[ "$CPU_VENDOR" == "GenuineIntel" ]]; then
HARDWARE_MODULES="inputs.nixos-hardware.nixosModules.common-cpu-intel"
fi
# Comprehensive Hardware Selection
echo "Searching for optimized hardware profiles..."
echo "Select your hardware vendor/category:"
VENDOR=$(gum choose --header "Select Vendor" \
"acer" "apple" "asus" "dell" "framework" "google" "hp" "lenovo" "microsoft" "msi" "purism" "samsung" "starlabs" "system76" "toshiba" "None/Generic")
if [ "$VENDOR" != "None/Generic" ]; then
echo "Select specific model for $VENDOR:"
case $VENDOR in
dell)
MODEL=$(gum choose "xps-13-9300" "xps-13-9310" "xps-13-9343" "xps-13-9360" "xps-13-9370" "xps-13-9380" "xps-15-7590" "xps-15-9500" "xps-15-9510" "xps-15-9550" "precision-5510" "precision-5530")
HARDWARE_MODULES="$HARDWARE_MODULES\n inputs.nixos-hardware.nixosModules.dell-$MODEL"
[[ "$MODEL" == *"xps"* ]] && NOMARCHY_HW_OPTS="nomarchy.hardware.isXPS = true;"
;;
lenovo)
MODEL=$(gum choose "thinkpad-x1-carbon-gen7" "thinkpad-x1-carbon-gen8" "thinkpad-x1-carbon-gen9" "thinkpad-x1-carbon-gen10" "thinkpad-x1-extreme" "thinkpad-t480" "thinkpad-t490" "thinkpad-t14-amd" "thinkpad-t14-intel" "thinkpad-p1-gen3")
HARDWARE_MODULES="$HARDWARE_MODULES\n inputs.nixos-hardware.nixosModules.lenovo-$MODEL"
;;
framework)
MODEL=$(gum choose "13-7040-amd" "13-intel-12th-gen" "13-intel-13th-gen" "16-7040-amd")
HARDWARE_MODULES="$HARDWARE_MODULES\n inputs.nixos-hardware.nixosModules.framework-$MODEL"
NOMARCHY_HW_OPTS="nomarchy.hardware.isFramework = true;"
;;
microsoft)
MODEL=$(gum choose "surface-pro-7" "surface-pro-8" "surface-pro-9" "surface-laptop-3" "surface-laptop-4")
HARDWARE_MODULES="$HARDWARE_MODULES\n inputs.nixos-hardware.nixosModules.microsoft-$MODEL"
;;
apple)
MODEL=$(gum choose "macbook-pro-12-1" "macbook-air-6-2" "t2")
if [ "$MODEL" == "t2" ]; then
NOMARCHY_HW_OPTS="nomarchy.hardware.isT2Mac = true;"
else
HARDWARE_MODULES="$HARDWARE_MODULES\n inputs.nixos-hardware.nixosModules.apple-$MODEL"
fi
;;
*)
echo "Enter the nixos-hardware module path (e.g. inputs.nixos-hardware.nixosModules.common-cpu-amd):"
INPUT_MOD=$(gum input --placeholder "inputs.nixos-hardware.nixosModules.xxx")
HARDWARE_MODULES="$HARDWARE_MODULES\n $INPUT_MOD"
;;
esac
fi
# 2. Storage Setup
echo "Select the target drive for installation:"
DRIVES=$(lsblk -d -n -p -o NAME,SIZE | grep -v loop)
TARGET_DRIVE=$(echo "$DRIVES" | gum choose | awk '{print $1}')
if [ -z "$TARGET_DRIVE" ]; then
echo "No drive selected. Exiting."
exit 1
fi
echo "Select the partition layout:"
LAYOUT=$(gum choose "Standard Ext4" "Encrypted BTRFS (LUKS2)")
if [ "$LAYOUT" = "Standard Ext4" ]; then
DISKO_NIX="/etc/disko-ext4.nix"
else
DISKO_NIX="/etc/disko-btrfs-luks.nix"
fi
TMP_DISKO=$(mktemp --suffix=.nix)
sed "s|@TARGET_DRIVE@|$TARGET_DRIVE|g" "$DISKO_NIX" > "$TMP_DISKO"
sudo disko --mode disko "$TMP_DISKO"
# 3. User Details
USERNAME=$(gum input --placeholder "Enter target username")
if [ -z "$USERNAME" ]; then
echo "No username entered. Exiting."
exit 1
fi
# 4. Login Preferences
echo "Select login preference:"
LOGIN_PREF=$(gum choose "SDDM Auto-login" "Require Password")
# Generate /mnt/etc/nixos/login-preference.nix
mkdir -p /mnt/etc/nixos/
cat <<EOF > /mnt/etc/nixos/login-preference.nix
{
services.displayManager.autoLogin.enable = $(if [ "$LOGIN_PREF" = "SDDM Auto-login" ]; then echo "true"; else echo "false"; fi);
services.displayManager.autoLogin.user = "$USERNAME";
}
EOF
# Generate /mnt/etc/nixos/hardware-selection.nix
cat <<EOF > /mnt/etc/nixos/hardware-selection.nix
{ inputs, ... }:
{
imports = [
$(echo "$HARDWARE_MODULES")
];
$NOMARCHY_HW_OPTS
}
EOF
# 5. Hardware Config
nixos-generate-config --root /mnt
# 6. Modular Downstream Scaffolding
mkdir -p /mnt/etc/nixos/
# Create system.nix (User System Customization)
cat <<EOF > /mnt/etc/nixos/system.nix
{ pkgs, ... }:
{
# Add your personal system-level NixOS modules here.
# Example: agenix.nixosModules.default
environment.systemPackages = with pkgs; [
# Add extra system-wide packages here
];
}
EOF
# Create home.nix (User Home Customization)
cat <<EOF > /mnt/etc/nixos/home.nix
{ pkgs, ... }:
{
# Add your personal Home Manager modules here.
home.packages = with pkgs; [
# Add extra user-level packages here
];
}
EOF
# Create the Master Flake
cat <<EOF > /mnt/etc/nixos/flake.nix
{
description = "My Nomarchy - Downstream Configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nomarchy.url = "path:./nomarchy"; # Offline bundled nomarchy
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# EXAMPLE: Add agenix for secrets
# agenix.url = "github:ryantm/agenix";
};
outputs = { self, nixpkgs, nomarchy, home-manager, ... }@inputs: {
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
# 1. Hardware
./hardware-configuration.nix
./hardware-selection.nix
# 2. Login & Preferences
./login-preference.nix
# 3. Upstream Nomarchy Core
nomarchy.nixosModules.system
# 4. User System Customization
./system.nix
# 5. Home Manager Integration
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.$USERNAME = {
imports = [
nomarchy.nixosModules.home
./home.nix
];
home.username = "$USERNAME";
home.homeDirectory = "/home/$USERNAME";
home.stateVersion = "24.05";
};
}
];
};
};
}
EOF
# 7. Copy Bundled Flake
echo "Copying bundled upstream Nomarchy flake..."
cp -rL /etc/nomarchy /mnt/etc/nixos/nomarchy
chmod -R u+w /mnt/etc/nixos/nomarchy
# 8. Version Control
cd /mnt/etc/nixos/
git init
git add .
git config user.name "Nomarchy Installer"
git config user.email "installer@nomarchy"
git commit -m "Initial Nomarchy generation"
# 9. Execution
nixos-install --flake /mnt/etc/nixos#default --no-root-passwd