idk
This commit is contained in:
parent
d616cdca1f
commit
9dc034ec86
23 changed files with 354 additions and 26 deletions
0
hosts/buer/default.nix
Normal file → Executable file
0
hosts/buer/default.nix
Normal file → Executable file
0
hosts/buer/hardware.nix
Normal file → Executable file
0
hosts/buer/hardware.nix
Normal file → Executable file
0
hosts/buer/secrets.nix
Normal file → Executable file
0
hosts/buer/secrets.nix
Normal file → Executable file
46
hosts/focalor/backup.nix
Executable file
46
hosts/focalor/backup.nix
Executable file
|
@ -0,0 +1,46 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "sd_mod" ];
|
||||
boot.initrd.kernelModules = [
|
||||
"vfio" "vfio_iommu_type1" "vfio_pci"
|
||||
"nvidia" "nvidia-modeset" "nvidia_uvm" "nvidia_drm"
|
||||
];
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
boot.kernelParams = [
|
||||
"amd_iommu=on"
|
||||
"vfio-pci.ids=10de:2484,10de228b,1022:149c,15b7:5045"
|
||||
];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" =
|
||||
{ device = "/dev/disk/by-uuid/2009b305-f22d-4d5c-a9d3-c49a2303232b";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" =
|
||||
{ device = "/dev/disk/by-uuid/E53C-502F";
|
||||
fsType = "vfat";
|
||||
options = [ "fmask=0077" "dmask=0077" ];
|
||||
};
|
||||
|
||||
swapDevices = [ ];
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
}
|
62
hosts/focalor/default.nix
Normal file → Executable file
62
hosts/focalor/default.nix
Normal file → Executable file
|
@ -6,16 +6,19 @@
|
|||
# Host-specific hardware
|
||||
./hardware.nix
|
||||
./secrets.nix
|
||||
./vfio.nix
|
||||
|
||||
# Common modules shared across hosts
|
||||
../../common/system.nix
|
||||
../../common/users.nix
|
||||
../../common/services.nix
|
||||
../../common/efi.nix
|
||||
../../common/bluetooth.nix
|
||||
|
||||
# Desktop modules
|
||||
../../common/desktop/core.nix
|
||||
../../common/desktop/sway.nix
|
||||
../../common/desktop/vnc.nix
|
||||
|
||||
# Nvidia
|
||||
../../common/nvidia.nix
|
||||
|
@ -24,7 +27,7 @@
|
|||
#../../host-secrets.nix
|
||||
];
|
||||
|
||||
system.stateVersion = "24.11";
|
||||
system.stateVersion = "25.05";
|
||||
|
||||
# pin host platform & microcode
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
|
@ -34,7 +37,37 @@
|
|||
networking.hostName = "focalor";
|
||||
networking.hostId = "84bdc587";
|
||||
|
||||
networking = {
|
||||
systemd.network = {
|
||||
enable = true;
|
||||
netdevs."br0" = {
|
||||
netdevConfig = {
|
||||
Name = "br0";
|
||||
Kind = "bridge";
|
||||
};
|
||||
};
|
||||
networks = {
|
||||
"10-lan" = {
|
||||
matchConfig.Name = ["enp5s0" "vm-*"];
|
||||
networkConfig = {
|
||||
Bridge = "br0";
|
||||
};
|
||||
};
|
||||
"10-lan-bridge" = {
|
||||
matchConfig.Name = "br0";
|
||||
networkConfig = {
|
||||
Address = ["10.0.0.34/24" "2601:5c2:8400:26c0:aaa1:59ff:fe94:5aba/64"];
|
||||
Gateway = "10.0.0.1";
|
||||
DNS = ["10.0.0.210" "1.1.1.1"];
|
||||
IPv6AcceptRA = true;
|
||||
};
|
||||
linkConfig.RequiredForOnline = "routable";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
programs.steam.enable = true;
|
||||
|
||||
/*networking = {
|
||||
firewall.enable = false;
|
||||
firewall.trustedInterfaces = [
|
||||
"tailscale0"
|
||||
|
@ -42,7 +75,7 @@
|
|||
nameservers = [ "10.0.0.210" "1.1.1.1" ];
|
||||
useDHCP = true;
|
||||
firewall.allowedTCPPorts = [22 80 443 2456 2457 9000 9001 9002];
|
||||
};
|
||||
};*/
|
||||
|
||||
services.resolved = {
|
||||
enable = true;
|
||||
|
@ -57,10 +90,22 @@
|
|||
|
||||
#services.zfs.autoScrub.enable = true;
|
||||
#services.zfs.trim.enable = true;
|
||||
|
||||
services.vscode-server.enable = true;
|
||||
services.vscode-server.nodejsPackage = pkgs.nodejs_20;
|
||||
|
||||
|
||||
programs.obs-studio = {
|
||||
enable = true;
|
||||
enableVirtualCamera = true;
|
||||
plugins = with pkgs.obs-studio-plugins; [
|
||||
droidcam-obs
|
||||
];
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
#lm_sensors
|
||||
code-server
|
||||
#code-server
|
||||
inputs.agenix.packages.x86_64-linux.default
|
||||
];
|
||||
|
||||
|
@ -73,4 +118,13 @@
|
|||
buildGoModule = pkgs.buildGo123Module;
|
||||
};
|
||||
};
|
||||
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
wlr.enable = true;
|
||||
extraPortals = with pkgs; [
|
||||
xdg-desktop-portal-gtk
|
||||
xdg-desktop-portal-gnome
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
18
hosts/focalor/hardware.nix
Normal file → Executable file
18
hosts/focalor/hardware.nix
Normal file → Executable file
|
@ -9,30 +9,32 @@
|
|||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "uas" "usbhid" "sd_mod" ];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.initrd.kernelModules = [ "vfio" "vfio_iommu_type1" "vfio_pci" ];
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
boot.kernelParams = [
|
||||
"amd_iommu=on"
|
||||
"vfio-pci.ids=10de:2484,10de228b,1022:149c,15b7:5045,1dbe:5236,1022:149c"
|
||||
];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" =
|
||||
{ device = "/dev/disk/by-uuid/01c4129c-ace4-495a-941e-c5fa893a0bb4";
|
||||
{ device = "/dev/disk/by-uuid/5d42a325-ba0d-4d40-906b-d28603b433ef";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" =
|
||||
{ device = "/dev/disk/by-uuid/6CCE-47E4";
|
||||
{ device = "/dev/disk/by-uuid/404A-728D";
|
||||
fsType = "vfat";
|
||||
options = [ "fmask=0077" "dmask=0077" ];
|
||||
options = [ "fmask=0022" "dmask=0022" ];
|
||||
};
|
||||
|
||||
swapDevices =
|
||||
[ { device = "/dev/disk/by-uuid/3029e270-a5f5-4a97-a29b-f2bc3e3a33a8"; }
|
||||
];
|
||||
swapDevices = [ ];
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
# networking.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true;
|
||||
|
||||
|
|
62
hosts/focalor/scripts/vm-win11-hook.sh
Executable file
62
hosts/focalor/scripts/vm-win11-hook.sh
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
echo "qemu-hook: ${1} ${2}" >> /tmp/qemu-hook.log
|
||||
|
||||
set -x
|
||||
|
||||
readonly GUEST_NAME="$1"
|
||||
readonly HOOK_NAME="$2"
|
||||
readonly STATE_NAME="$3"
|
||||
|
||||
function start_hook() {
|
||||
# Stops GUI
|
||||
systemctl isolate multi-user.target
|
||||
|
||||
# Avoids race condition
|
||||
sleep 2
|
||||
|
||||
# Unloads the NVIDIA drivers
|
||||
modprobe -r nvidia_drm
|
||||
modprobe -r nvidia_uvm
|
||||
modprobe -r nvidia_modeset
|
||||
modprobe -r nvidia
|
||||
|
||||
# Other code you might want to run
|
||||
}
|
||||
|
||||
function revert_hook() {
|
||||
virsh nodedev-reattach pci_0000_0a_00_0
|
||||
virsh nodedev-reattach pci_0000_0a_00_1
|
||||
virsh nodedev-reattach pci_0000_06_00_1
|
||||
virsh nodedev-reattach pci_0000_06_00_3
|
||||
virsh nodedev-reattach pci_0000_0c_00_3
|
||||
|
||||
modprobe -r vfio-pci
|
||||
|
||||
# Loads the NVIDIA drivers
|
||||
modprobe nvidia_modeset
|
||||
modprobe nvidia_uvm
|
||||
modprobe nvidia_drm
|
||||
modprobe nvidia
|
||||
|
||||
modprobe -r xhci_pci
|
||||
modprobe xhci_pci
|
||||
|
||||
# Starts the UI again
|
||||
systemctl restart display-manager
|
||||
systemctl isolate graphical.target
|
||||
}
|
||||
|
||||
# I am not using the script from Passthrough-Post
|
||||
# because hooks option saves it to /var/lib/libvirt/hooks/qemu.d.
|
||||
# It's simpler to just rewrite it for NixOS.
|
||||
if [[ "$GUEST_NAME" != "win11" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$HOOK_NAME" == "prepare" && "$STATE_NAME" == "begin" ]]; then
|
||||
#start_hook
|
||||
echo "do nothing"
|
||||
elif [[ "$HOOK_NAME" == "release" && "$STATE_NAME" == "end" ]]; then
|
||||
revert_hook
|
||||
fi
|
0
hosts/focalor/secrets.nix
Normal file → Executable file
0
hosts/focalor/secrets.nix
Normal file → Executable file
43
hosts/focalor/vfio.nix
Executable file
43
hosts/focalor/vfio.nix
Executable file
|
@ -0,0 +1,43 @@
|
|||
{ config, lib, system, pkgs, modulesPath, inputs, ... }:
|
||||
|
||||
{
|
||||
programs.virt-manager.enable = true;
|
||||
virtualisation.spiceUSBRedirection.enable = true;
|
||||
virtualisation.libvirtd = {
|
||||
enable = true;
|
||||
qemu = {
|
||||
package = pkgs.qemu_kvm;
|
||||
runAsRoot = true;
|
||||
swtpm.enable = true;
|
||||
ovmf = {
|
||||
enable = true;
|
||||
packages = [(pkgs.OVMF.override {
|
||||
secureBoot = true;
|
||||
tpmSupport = true;
|
||||
}).fd];
|
||||
};
|
||||
};
|
||||
hooks.qemu = {
|
||||
win11 = ./scripts/vm-win11-hook.sh;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.libvirtd = {
|
||||
path = let
|
||||
env = pkgs.buildEnv {
|
||||
name = "qemu-hook-env";
|
||||
paths = with pkgs; [
|
||||
bash
|
||||
libvirt
|
||||
kmod
|
||||
systemd
|
||||
ripgrep
|
||||
sd
|
||||
];
|
||||
};
|
||||
in
|
||||
[ env ];
|
||||
};
|
||||
|
||||
users.extraUsers.regent.extraGroups = [ "libvirtd" ];
|
||||
}
|
0
hosts/valefar/default.nix
Normal file → Executable file
0
hosts/valefar/default.nix
Normal file → Executable file
0
hosts/valefar/hardware.nix
Normal file → Executable file
0
hosts/valefar/hardware.nix
Normal file → Executable file
0
hosts/valefar/secrets.nix
Normal file → Executable file
0
hosts/valefar/secrets.nix
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue