feat: initialize repo with NixOS and Home Manager configs
- Add .gitignore for common languages, tools, and OS/editor artifacts - Configure .gitattributes for Git LFS (fonts, images, archives, ISOs) - Add README with repo description - Add flake.nix defining inputs and outputs for NixOS, Home Manager, and related modules - Introduce home-manager configs: - Base home.nix with packages, services, and programs - Hyprland WM configuration (waybar, fuzzel, keybindings, theming) - Vim (nixvim) setup with LSP and plugins - Zsh setup with aliases, Oh My Zsh, clipboard helpers - Systemd user services (e.g., librespot) - Add scripts (GPU monitor, RAM build helper, install automation) - Add host configurations: - Nixbook (Apple laptop) with hardware, disko, and install script - Nixstation (desktop) with firewall, virtualization, Btrfs scrub timer - Nixtest (test VM) with QEMU + Alpine-based install test harness - Common modules (network, NVIDIA, rclone, screen, keychron, users) - Include statix config for linting
This commit is contained in:
commit
095e9f4f6b
34 changed files with 1954 additions and 0 deletions
29
hosts/Nixtest/default.nix
Normal file
29
hosts/Nixtest/default.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
imports = [
|
||||
./disko.nix
|
||||
];
|
||||
|
||||
networking.hostName = "Nixtest";
|
||||
services = {
|
||||
xserver.enable = true;
|
||||
displayManager.sddm = {
|
||||
enable = true;
|
||||
};
|
||||
openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PermitRootLogin = "yes";
|
||||
PasswordAuthentication = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
git
|
||||
home-manager
|
||||
];
|
||||
|
||||
system.stateVersion = "23.11";
|
||||
}
|
||||
58
hosts/Nixtest/disko.nix
Normal file
58
hosts/Nixtest/disko.nix
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
disko.devices = {
|
||||
disk.main = {
|
||||
type = "disk";
|
||||
device = "/dev/nvme0n1";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
esp = {
|
||||
size = "128M";
|
||||
start = "1M";
|
||||
type = "EF00";
|
||||
label = "EFI";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
|
||||
root = {
|
||||
type = "8300";
|
||||
label = "NixOS";
|
||||
size = "32G";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
mountpoint = "/";
|
||||
subvolumes = {
|
||||
"@root" = {
|
||||
mountpoint = "/";
|
||||
};
|
||||
"@nix" = {
|
||||
mountpoint = "/nix";
|
||||
};
|
||||
"@home" = {
|
||||
mountpoint = "/home";
|
||||
};
|
||||
"@log" = {
|
||||
mountpoint = "/var/log";
|
||||
};
|
||||
};
|
||||
extraArgs = [
|
||||
"-L"
|
||||
"nixos-root"
|
||||
];
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
93
hosts/Nixtest/scripts/install_test.sh
Normal file
93
hosts/Nixtest/scripts/install_test.sh
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
### Configuration ###
|
||||
|
||||
# Find virtual images at: https://alpinelinux.org/downloads/ -> Virtual
|
||||
ALPINE_VERSION="3.19.1"
|
||||
ALPINE_ARCH="x86_64"
|
||||
ALPINE_IMAGE_FILENAME="alpine-virt-${ALPINE_VERSION}-${ALPINE_ARCH}.iso"
|
||||
ALPINE_IMAGE_URL="https://dl-cdn.alpinelinux.org/alpine/v$(echo $ALPINE_VERSION | cut -d. -f1-2)/releases/${ALPINE_ARCH}/${ALPINE_IMAGE_FILENAME}"
|
||||
|
||||
QEMU_MEM="2048"
|
||||
QEMU_CPUS="2"
|
||||
QEMU_SSH_HOST_PORT="2222"
|
||||
QEMU_PID_FILE="qemu_test.pid"
|
||||
|
||||
TARGET_IP="127.0.0.1"
|
||||
TARGET_PORT="${QEMU_SSH_HOST_PORT}"
|
||||
TARGET_USER="root"
|
||||
SSH_KEY_PUB="$HOME/.ssh/id_rsa.pub"
|
||||
SSH_KEY_PRIV="$HOME/.ssh/id_rsa"
|
||||
|
||||
FLAKE_PATH="./#Nixtest"
|
||||
|
||||
### Helper Functions ###
|
||||
cleanup_qemu() {
|
||||
if [ -f "$QEMU_PID_FILE" ]; then
|
||||
echo "🧹 Cleaning up previous QEMU instance..."
|
||||
kill -- "-$(cat $QEMU_PID_FILE)" 2>/dev/null || kill "$(cat $QEMU_PID_FILE)" 2>/dev/null || true
|
||||
rm -f "$QEMU_PID_FILE"
|
||||
sleep 2
|
||||
echo "🧹 Cleanup complete."
|
||||
fi
|
||||
}
|
||||
|
||||
launch_qemu_alpine() {
|
||||
echo "🚀 Launching QEMU with Alpine Linux (${ALPINE_IMAGE_FILENAME})..."
|
||||
qemu-system-x86_64 \
|
||||
-m "${QEMU_MEM}" \
|
||||
-smp "${QEMU_CPUS}" \
|
||||
-enable-kvm \
|
||||
-nic user,model=virtio-net-pci,hostfwd=tcp::${TARGET_PORT}-:22 \
|
||||
-drive file="${ALPINE_IMAGE_FILENAME}",media=cdrom,readonly=on \
|
||||
-boot d \
|
||||
-display none \
|
||||
-daemonize \
|
||||
-pidfile "$QEMU_PID_FILE"
|
||||
|
||||
echo "⏳ Waiting for QEMU to boot and SSH to become available on port ${TARGET_PORT}..."
|
||||
local max_wait=90
|
||||
local waited=0
|
||||
while ! ssh -p "${TARGET_PORT}" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=2 -o ConnectionAttempts=3 "${TARGET_USER}@${TARGET_IP}" exit >/dev/null 2>&1; do
|
||||
sleep 3
|
||||
waited=$((waited + 3))
|
||||
if [ "$waited" -ge "$max_wait" ]; then
|
||||
echo "❌ Timed out waiting for SSH on port ${TARGET_PORT}."
|
||||
cat "$QEMU_PID_FILE"
|
||||
cleanup_qemu
|
||||
exit 1
|
||||
fi
|
||||
echo -n "."
|
||||
done
|
||||
echo
|
||||
echo "✅ QEMU Alpine VM is up and SSH is ready on port ${TARGET_PORT}."
|
||||
}
|
||||
|
||||
### Main Script ###
|
||||
|
||||
trap cleanup_qemu EXIT SIGINT SIGTERM
|
||||
|
||||
if [ ! -f "$ALPINE_IMAGE_FILENAME" ]; then
|
||||
echo "⏬ Downloading Alpine image: ${ALPINE_IMAGE_FILENAME}..."
|
||||
wget --progress=bar:force -O "$ALPINE_IMAGE_FILENAME" "$ALPINE_IMAGE_URL"
|
||||
else
|
||||
echo "✅ Alpine image found locally: ${ALPINE_IMAGE_FILENAME}"
|
||||
fi
|
||||
|
||||
if [ ! -f "$SSH_KEY_PUB" ] || [ ! -f "$SSH_KEY_PRIV" ]; then
|
||||
echo "❌ SSH key not found at $SSH_KEY_PRIV or $SSH_KEY_PUB"
|
||||
echo " Please generate one using 'ssh-keygen' or specify the correct path."
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Using SSH key: ${SSH_KEY_PRIV}"
|
||||
|
||||
cleanup_qemu
|
||||
launch_qemu_alpine
|
||||
|
||||
# --- Installation logic will go here ---
|
||||
|
||||
echo "🏁 Test script placeholder finished. VM is running."
|
||||
echo " PID: $(cat $QEMU_PID_FILE)"
|
||||
echo " To connect: ssh -p ${TARGET_PORT} ${TARGET_USER}@${TARGET_IP}"
|
||||
22
hosts/Nixtest/scripts/install_test_shell.nix
Normal file
22
hosts/Nixtest/scripts/install_test_shell.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{ pkgs ? import <nixpkgs> { }
|
||||
,
|
||||
}:
|
||||
|
||||
pkgs.mkShell {
|
||||
name = "nixos-anywhere-test-env";
|
||||
|
||||
packages = with pkgs; [
|
||||
nix
|
||||
nixos-anywhere
|
||||
openssh
|
||||
sshpass
|
||||
qemu_full
|
||||
wget
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "Entered NixOS Anywhere Test Environment."
|
||||
echo "Alpine image will be downloaded if needed."
|
||||
echo "Run ./install_test.sh to start the QEMU VM and run the installation."
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue