Initial NixOS VM config
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
# VM Hardware Configuration
|
||||
boot.loader.grub = {
|
||||
enable = true;
|
||||
device = "/dev/sda";
|
||||
useOSProber = false;
|
||||
};
|
||||
|
||||
# Filesystem — will be generated by nixos-generate-config, but override
|
||||
fileSystems."/" = lib.mkDefault {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
fsType = "ext4";
|
||||
};
|
||||
fileSystems."/boot" = lib.mkDefault {
|
||||
device = "/dev/disk/by-label/boot";
|
||||
fsType = "vfat";
|
||||
};
|
||||
|
||||
# Network
|
||||
networking = {
|
||||
hostName = "nixos-dev";
|
||||
networkmanager.enable = true;
|
||||
useDHCP = true;
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [ 22 8000 8080 3000 ];
|
||||
};
|
||||
};
|
||||
|
||||
# QEMU Guest Agent (for Proxmox integration)
|
||||
services.qemuGuest.enable = true;
|
||||
|
||||
# SSH
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PermitRootLogin = "no";
|
||||
PasswordAuthentication = true; # change to no after keys deployed
|
||||
};
|
||||
};
|
||||
|
||||
# User configuration
|
||||
users.users.konrad = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" "docker" "networkmanager" ];
|
||||
shell = pkgs.zsh;
|
||||
# Temporary password — change after first login
|
||||
initialPassword = "changeme";
|
||||
};
|
||||
|
||||
# System-wide programs
|
||||
programs = {
|
||||
zsh.enable = true;
|
||||
git.enable = true;
|
||||
};
|
||||
|
||||
# System packages (minimal core)
|
||||
environment.systemPackages = with pkgs; [
|
||||
curl
|
||||
git
|
||||
vim
|
||||
htop
|
||||
];
|
||||
|
||||
# Docker
|
||||
virtualisation.docker = {
|
||||
enable = true;
|
||||
enableOnBoot = true;
|
||||
};
|
||||
|
||||
# Nix configuration
|
||||
nix = {
|
||||
settings = {
|
||||
experimental-features = [ "nix-command" "flakes" ];
|
||||
auto-optimise-store = true;
|
||||
};
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "weekly";
|
||||
options = "--delete-older-than 7d";
|
||||
};
|
||||
};
|
||||
|
||||
# Allow unfree packages
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
# Auto-upgrades
|
||||
system = {
|
||||
stateVersion = "24.11";
|
||||
autoUpgrade = {
|
||||
enable = true;
|
||||
allowReboot = false;
|
||||
};
|
||||
};
|
||||
|
||||
# Enable flakes in this boot configuration
|
||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
description = "Konrad's NixOS Dev VM — Proxmox";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, home-manager, ... }: {
|
||||
nixosConfigurations.nixos-dev = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
./configuration.nix
|
||||
./hardware-configuration.nix
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
users.konrad = import ./home.nix;
|
||||
extraSpecialArgs = { inherit nixpkgs; };
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
homeConfigurations.konrad = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
modules = [ ./home.nix ];
|
||||
};
|
||||
};
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# NixOS Proxmox VM install script — paste into NixOS minimal ISO console
|
||||
set -euo pipefail
|
||||
|
||||
echo "=== NixOS VM Install ==="
|
||||
|
||||
# Partition disk
|
||||
parted /dev/sda -- mklabel gpt
|
||||
parted /dev/sda -- mkpart primary 512MiB -8GiB
|
||||
parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
|
||||
parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
|
||||
parted /dev/sda -- set 3 esp on
|
||||
|
||||
# Format partitions
|
||||
mkfs.ext4 -L nixos /dev/sda1
|
||||
mkswap -L swap /dev/sda2
|
||||
mkfs.fat -F 32 -n boot /dev/sda3
|
||||
|
||||
# Mount
|
||||
mount /dev/disk/by-label/nixos /mnt
|
||||
mkdir -p /mnt/boot
|
||||
mount /dev/disk/by-label/boot /mnt/boot
|
||||
swapon /dev/sda2
|
||||
|
||||
# Generate hardware config
|
||||
nixos-generate-config --root /mnt
|
||||
|
||||
# Clone and use our config
|
||||
CONFIG_URL="https://gitea.klhoud.com/konrad/nixos-config-raw"
|
||||
mkdir -p /mnt/etc/nixos
|
||||
|
||||
# Option 1: If config is in a repo, clone it
|
||||
# git clone $CONFIG_URL /mnt/etc/nixos/
|
||||
# Option 2: The user will have pasted the config — placeholder below
|
||||
echo "Place your configuration.nix and flake.nix in /mnt/etc/nixos/"
|
||||
|
||||
# Generate fallback hardware config if needed
|
||||
nixos-generate-config --root /mnt --show-hardware-config > /mnt/etc/nixos/hardware-configuration.nix
|
||||
|
||||
echo "Copy your flake.nix and configuration.nix to /mnt/etc/nixos/"
|
||||
echo "then run: nixos-install --flake /mnt/etc/nixos#nixos-dev"
|
||||
Reference in New Issue
Block a user