This commit is contained in:
commit
95a533c876
451 changed files with 18255 additions and 0 deletions
7
templates/nix-configs/vm-uefi/hosts/HOSTNAME/boot.nix
Normal file
7
templates/nix-configs/vm-uefi/hosts/HOSTNAME/boot.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
boot.loader.systemd-boot = {
|
||||
enable = true;
|
||||
configurationLimit = 10;
|
||||
};
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
}
|
||||
22
templates/nix-configs/vm-uefi/hosts/HOSTNAME/default.nix
Normal file
22
templates/nix-configs/vm-uefi/hosts/HOSTNAME/default.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
inputs,
|
||||
outputs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./boot.nix
|
||||
./hardware.nix
|
||||
./networking.nix
|
||||
./packages.nix
|
||||
./services
|
||||
./users.nix
|
||||
|
||||
inputs.synix.nixosModules.common
|
||||
|
||||
outputs.nixosModules.common
|
||||
];
|
||||
|
||||
system.stateVersion = "25.11";
|
||||
}
|
||||
59
templates/nix-configs/vm-uefi/hosts/HOSTNAME/disks.sh
Normal file
59
templates/nix-configs/vm-uefi/hosts/HOSTNAME/disks.sh
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SSD='/dev/sda' # FIXME: Replace with your actual disk
|
||||
MNT='/mnt'
|
||||
|
||||
# Helper function to wait for devices
|
||||
wait_for_device() {
|
||||
local device=$1
|
||||
echo "Waiting for device: $device ..."
|
||||
while [[ ! -e $device ]]; do
|
||||
sleep 1
|
||||
done
|
||||
echo "Device $device is ready."
|
||||
}
|
||||
|
||||
# Function to install a package if it's not already installed
|
||||
install_if_missing() {
|
||||
local cmd="$1"
|
||||
local package="$2"
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd not found, installing $package..."
|
||||
nix-env -iA "nixos.$package"
|
||||
fi
|
||||
}
|
||||
|
||||
install_if_missing "sgdisk" "gptfdisk"
|
||||
install_if_missing "partprobe" "parted"
|
||||
|
||||
swapoff --all
|
||||
udevadm settle
|
||||
|
||||
wait_for_device $SSD
|
||||
|
||||
echo "Wiping filesystem on $SSD..."
|
||||
wipefs -a $SSD
|
||||
|
||||
echo "Clearing partition table on $SSD..."
|
||||
sgdisk --zap-all $SSD
|
||||
|
||||
echo "Partitioning $SSD..."
|
||||
sgdisk -n1:1M:+1G -t1:EF00 -c1:BOOT $SSD
|
||||
sgdisk -n2:0:0 -t2:8304 -c2:ROOT $SSD
|
||||
partprobe -s $SSD
|
||||
udevadm settle
|
||||
|
||||
wait_for_device "${SSD}1"
|
||||
wait_for_device "${SSD}2"
|
||||
|
||||
echo "Formatting partitions..."
|
||||
mkfs.vfat -F 32 -n BOOT "${SSD}1"
|
||||
mkfs.ext4 -L ROOT "${SSD}2"
|
||||
|
||||
echo "Mounting partitions..."
|
||||
mount -o X-mount.mkdir "${SSD}2" "$MNT"
|
||||
mkdir -p "$MNT/boot"
|
||||
mount -t vfat -o fmask=0077,dmask=0077,iocharset=iso8859-1 "${SSD}1" "$MNT/boot"
|
||||
|
||||
echo "Partitioning and setup complete:"
|
||||
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
|
||||
41
templates/nix-configs/vm-uefi/hosts/HOSTNAME/hardware.nix
Normal file
41
templates/nix-configs/vm-uefi/hosts/HOSTNAME/hardware.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
inputs,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [ inputs.synix.nixosModules.device.vm ];
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"sd_mod"
|
||||
"sr_mod"
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/ROOT";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-label/BOOT";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"fmask=0077"
|
||||
"dmask=0077"
|
||||
];
|
||||
};
|
||||
|
||||
swapDevices = [ ];
|
||||
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
virtualisation.hypervGuest.enable = true;
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
networking.hostName = "HOSTNAME";
|
||||
networking.domain = "HOSTNAME.local";
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [ ];
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./nginx.nix
|
||||
./openssh.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [ inputs.synix.nixosModules.nginx ];
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
forceSSL = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.synix.nixosModules.openssh
|
||||
];
|
||||
|
||||
services.openssh.enable = true;
|
||||
}
|
||||
9
templates/nix-configs/vm-uefi/hosts/HOSTNAME/users.nix
Normal file
9
templates/nix-configs/vm-uefi/hosts/HOSTNAME/users.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{ inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.synix.nixosModules.normalUsers
|
||||
|
||||
../../users/USERNAME
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue