From d25f508b259484b33626005051a033fbb3ef2730 Mon Sep 17 00:00:00 2001 From: 4DBug <4DBug@github.com> Date: Tue, 3 Feb 2026 15:05:17 -0600 Subject: [PATCH] push --- etc/nixos/flake.nix | 24 +++- main.nix | 89 ++++++++++++- vms/win10.nix | 314 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 421 insertions(+), 6 deletions(-) create mode 100644 vms/win10.nix diff --git a/etc/nixos/flake.nix b/etc/nixos/flake.nix index 2a06cb1..ede163d 100644 --- a/etc/nixos/flake.nix +++ b/etc/nixos/flake.nix @@ -13,9 +13,29 @@ url = "github:nix-community/stylix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + nixVirt = { + url = "https://flakehub.com/f/AshleyYakeley/NixVirt/*.tar.gz"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + noctalia = { + url = "github:noctalia-dev/noctalia-shell"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + quickshell = { + url = "git+https://git.outfoxxed.me/quickshell/quickshell"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + dms-plugin-registry = { + url = "github:AvengeMedia/dms-plugin-registry"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = inputs@{ self, nixpkgs, stylix, home-manager, flatpaks, hytale-launcher, ... }: + outputs = inputs@{ self, nixpkgs, stylix, home-manager, flatpaks, hytale-launcher, nixVirt, noctalia, quickshell, dms-plugin-registry, ... }: let deviceType = import /etc/nixos/device.nix; system = "x86_64-linux"; @@ -36,7 +56,7 @@ flatpaks.nixosModules.nix-flatpak - stylix.nixosModules.stylix + nixVirt.nixosModules.default ./configuration.nix ]; diff --git a/main.nix b/main.nix index 1b3794d..9664503 100644 --- a/main.nix +++ b/main.nix @@ -1,11 +1,17 @@ { lib, config, inputs, pkgs, options, desktop, ... }: let + #inherit (inputs) nixVirt; + #nixvirt.lib = nixVirt.lib; + nix-gaming = import (builtins.fetchTarball "https://github.com/fufexan/nix-gaming/archive/master.tar.gz"); nix-alien = import ( builtins.fetchTarball "https://github.com/thiagokokada/nix-alien/tarball/master" ) {}; + + #nvramPath = "/home/bug/.local/share/libvirt/qemu"; + #win10Config = import ./vms/win10.nix { inherit pkgs nvramPath; uuid = "c08333dc-33f9-4117-969a-ac46e19ba81f"; }; in { imports = [ @@ -29,7 +35,7 @@ in users.users.bug = { isNormalUser = true; description = "Bug"; - extraGroups = [ "networkmanager" "wheel" "audio" "video" "libvirtd" "ydotool" ]; + extraGroups = [ "networkmanager" "wheel" "audio" "video" "libvirtd" "ydotool" "dialout" ]; }; hardware = { @@ -138,7 +144,6 @@ in }; services.cloudflare-warp.enable = !desktop; - security = { rtkit.enable = true; @@ -318,6 +323,18 @@ in sha256 = "sha256-SUxfyovC2umZmsOj5bOTZ8WfGCpnWcz7svOESwNekV0="; }}"; } + + # add Polytoria client + # https://cdn.polytoria.com/releases/installer/linux/Polytoria%20Setup%204.12.0.flatpak + + { + appId = "com.polytoria.launcher"; + sha256 = "sha256-VjhNiJfSdCtlH2SuP3Mn8jjOrx5xcOqhtDKaWYIwxYg="; + bundle = "${pkgs.fetchurl { + url = "https://github.com/4DBug/poly/releases/download/poly/poly.flatpak"; + sha256 = "sha256-VjhNiJfSdCtlH2SuP3Mn8jjOrx5xcOqhtDKaWYIwxYg="; + }}"; + } ]; overrides = { @@ -400,7 +417,6 @@ in obsidian vesktop nicotine-plus - ptyxis fastfetch tree gh @@ -408,7 +424,6 @@ in samrewritten impression - # resources mission-center authenticator @@ -424,6 +439,8 @@ in kooha loupe + + arduino-ide ]; environment = { @@ -546,7 +563,15 @@ in extraPkgs = pkgs: [ pkgs.xorg.libxshmfence pkgs.linuxPackages.nvidia_x11 ]; }) ] else [ + (nix-gaming.packages.${pkgs.stdenv.hostPlatform.system}.star-citizen.override { + tricks = [ "arial" "vcrun2019" "win10" "sound=alsa" ]; + }) + bambu-studio + + inputs.noctalia.packages.${pkgs.stdenv.hostPlatform.system}.default + + kitty ]); }; @@ -564,11 +589,65 @@ in }; virtualisation = { + /* + libvirt = { + enable = true; + + connections."qemu:///system" = { + networks = [ + { + definition = nixvirt.lib.network.writeXML (nixvirt.lib.network.templates.bridge { + name = "default"; + uuid = "cda3b7dd-71fd-44e3-8093-340f47a88c83"; + subnet_byte = 122; + bridge_name = "virbr0"; + }); + + active = true; + } + ]; + + domains = lib.mkForce [ + { definition = nixvirt.lib.domain.writeXML win10Config; } + ]; + }; + }; + */ + libvirtd.enable = true; + spiceUSBRedirection.enable = true; }; programs = { + hyprland.enable = !desktop; + labwc.enable = !desktop; + + dms-shell = { + enable = false; # !desktop; + + enableSystemMonitoring = true; + enableClipboard = true; + enableDynamicTheming = true; + enableAudioWavelength = true; + enableCalendarEvents = true; + + plugins = { + #nixMonitor.enable = true; + + DankNixMonitor = { + enable = true; + src = pkgs.fetchFromGitHub { + owner = "antonjah"; + repo = "nix-monitor"; + rev = "f3dbe00"; + hash = "sha256-biRc7ESKzPK5Ueus1xjVT8OXCHar3+Qi+Osv/++A+Ls="; + }; + }; + }; + }; + + appimage = { enable = true; binfmt = true; @@ -637,6 +716,8 @@ ssh -R \"$\{name}:80:localhost:$\{port}\" tuns.sh'\'' _"; ]; }; + virt-manager.enable = true; + nix-ld = { enable = true; diff --git a/vms/win10.nix b/vms/win10.nix new file mode 100644 index 0000000..c230a36 --- /dev/null +++ b/vms/win10.nix @@ -0,0 +1,314 @@ +{ + nvramPath, + pkgs, + uuid, +}: + +{ + inherit uuid; + type = "kvm"; + + title = "Windows 10"; + name = "win10"; + description = "A Windows 10 vm define in nix"; + + sysinfo = { + type = "smbios"; + bios.entry = [ + { + name = "vendor"; + value = "INSYDE Corp."; + } + { + name = "version"; + value = "03.02"; + } + { + name = "date"; + value = "01/23/2024"; + } + ]; + system.entry = [ + { + name = "manufacturer"; + value = "Framework"; + } + { + name = "product"; + value = "Laptop 16 (AMD Ryzen 7040 Series)"; + } + { + name = "version"; + value = "AG"; + } + { + name = "serial"; + value = "FRAGADDPAG4096006K"; + } + { + name = "uuid"; + value = uuid; + } + { + name = "sku"; + value = "FRAGACCP0G"; + } + { + name = "family"; + value = "16in"; + } + ]; + }; + vcpu = { + count = 4; + placement = "static"; + }; + memory = { + count = 16; + unit = "GiB"; + }; + cputune = { + vcpupin = [ + { + vcpu = 0; + cpuset = "4"; + } + { + vcpu = 1; + cpuset = "5"; + } + { + vcpu = 2; + cpuset = "6"; + } + { + vcpu = 3; + cpuset = "7"; + } + ]; + }; + cpu = { + mode = "host-passthrough"; + check = "none"; + migratable = true; + cache = { + level = 3; + mode = "emulate"; + }; + feature = [ + { + policy = "disable"; + name = "hypervisor"; + } + { + policy = "require"; + name = "svm"; + } + { + policy = "require"; + name = "topoext"; + } + ]; + topology = { + sockets = 1; + dies = 1; + cores = 2; + threads = 2; + }; + }; + + # OS + os = { + type = "hvm"; + arch = "x86_64"; + machine = "pc-q35-8.2"; + loader = { + readonly = true; + type = "pflash"; + path = "${pkgs.OVMFFull.fd}/FV/OVMF_CODE.ms.fd"; + }; + nvram = { + template = "${pkgs.OVMFFull.fd}/FV/OVMF_VARS.ms.fd"; + path = "${nvramPath}/win10gpu.nvram"; + }; + smbios.mode = "sysinfo"; + }; + + features = { + acpi = { }; + apic = { }; + hyperv = { + mode = "custom"; + relaxed = { + state = true; + }; + vapic = { + state = true; + }; + spinlocks = { + state = true; + retries = 8191; + }; + vendor_id = { + state = true; + value = "1234567890ab"; + }; + }; + kvm.hidden = { + state = true; + }; + vmport.state = false; + }; + + clock = { + offset = "localtime"; + timer = [ + { + name = "rtc"; + tickpolicy = "catchup"; + } + { + name = "pit"; + tickpolicy = "delay"; + } + { + name = "hpet"; + present = false; + } + { + name = "hypervclock"; + present = true; + } + ]; + }; + + pm = { + suspend-to-mem = { + enabled = false; + }; + suspend-to-disk = { + enabled = false; + }; + }; + + devices = { + emulator = "${pkgs.qemu}/bin/qemu-system-x86_64"; + + # Disks + hostdev = []; + + # Input + input = [ + { + type = "keyboard"; + bus = "virtio"; + } + { + type = "mouse"; + bus = "virtio"; + } + ]; + + # Video + Audio + graphics = { + type = "spice"; + autoport = true; + listen = { + type = "address"; + }; + image = { + compression = false; + }; + }; + + video = { + model = { + type = "vga"; + vram = 65536; + heads = 1; + primary = true; + }; + }; + + sound = { + model = "ich9"; + }; + audio = { + id = 1; + type = "spice"; + }; + + # Interfaces + controller = [ + { + type = "usb"; + index = 0; + model = "qemu-xhci"; + ports = 15; + } + { + type = "pci"; + index = 0; + model = "pcie-root"; + } + { + type = "virtio-serial"; + index = 0; + } + ]; + + serial = [ + { + type = "pty"; + target = { + type = "isa-serial"; + port = 0; + model.name = "isa-serial"; + }; + } + ]; + + console = [ + { + type = "pty"; + target = { + type = "serial"; + port = 0; + }; + } + ]; + + channel = [ + { + type = "spicevmc"; + target = { + type = "virtio"; + name = "com.redhat.spice.0"; + }; + } + ]; + + # Other + watchdog = { + model = "itco"; + action = "reset"; + }; + memballoon.model = "none"; + }; + + qemu-commandline = { + arg = [ + { value = "-cpu"; } + { value = "host,kvm=off,hv_time,hv_vendor_id=null,-hypervisor"; } + { value = "-machine"; } + { value = "q35"; } + { value = "-device"; } + { value = "{\"driver\":\"ivshmem-plain\",\"id\":\"shmem0\",\"memdev\":\"looking-glass\"}"; } + { value = "-object"; } + { + value = "{\"qom-type\":\"memory-backend-file\",\"id\":\"looking-glass\",\"mem-path\":\"/dev/kvmfr0\",\"size\":134217728,\"share\":true}"; + } + ]; + }; +} +