From 74d75a040d1a30e44737aec5afb5dacc67ebdb82 Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Thu, 14 May 2026 22:00:50 +0530 Subject: VMs + broken tailscale --- flake.nix | 2 ++ nixos/apps/browser.nix | 1 - nixos/environment.nix | 4 ++++ nixos/games/default.nix | 3 ++- nixos/home.nix | 14 ++++++++++++-- nixos/opt/default.nix | 2 ++ nixos/opt/tailscale.nix | 24 ++++++++++++++++++++++++ nixos/opt/vm.nix | 18 ++++++++++++++++++ 8 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 nixos/opt/tailscale.nix create mode 100644 nixos/opt/vm.nix diff --git a/flake.nix b/flake.nix index 554b04a..8df8b18 100644 --- a/flake.nix +++ b/flake.nix @@ -36,6 +36,8 @@ hostname = "pegasus"; opt = { nvidia = true; + tailscale = false; + vm = true; llm = true; }; languages = { diff --git a/nixos/apps/browser.nix b/nixos/apps/browser.nix index 52456e8..95d43dc 100644 --- a/nixos/apps/browser.nix +++ b/nixos/apps/browser.nix @@ -7,7 +7,6 @@ value = "zen-browser.desktop"; associations = { - "application/pdf" = "org.kde.okular.desktop"; } // builtins.listToAttrs (map (name: { inherit name value; }) [ diff --git a/nixos/environment.nix b/nixos/environment.nix index b575b96..c8a6f5d 100644 --- a/nixos/environment.nix +++ b/nixos/environment.nix @@ -30,6 +30,7 @@ tokei wiki-tui bluetui + tdf fastfetch pipes @@ -70,4 +71,7 @@ dejavu_fonts nerd-fonts.jetbrains-mono ]; + xdg.mime.defaultApplications = { + "application/pdf" = "org.kde.okular.desktop"; + }; } diff --git a/nixos/games/default.nix b/nixos/games/default.nix index 5894464..d54cae2 100644 --- a/nixos/games/default.nix +++ b/nixos/games/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, games, ... }: +{ config, unstable, pkgs, games, ... }: { imports = (if games.minecraft then [ ./minecraft.nix ] else []); @@ -8,6 +8,7 @@ proton-ge-bin ]; environment.systemPackages = with pkgs; [ + lutris steam-run mangohud freetype diff --git a/nixos/home.nix b/nixos/home.nix index ede2a2f..6271724 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -1,4 +1,4 @@ -{ config, pkgs, username, terminalworkspace, ... }: +{ config, pkgs, username, terminalworkspace, opt, ... }: { users.users.${username} = { isNormalUser = true; @@ -83,7 +83,17 @@ end scrcpy="scrcpy --render-driver=opengl"; wisdom="fortune ~/.config/fortune/showerthoughts | cowsay | lolcat"; search="rg --color=always --line-number --no-heading \"\" | fzf --ansi --phony --query \"\" --bind \"change:reload(rg --color=always --line-number --no-heading {q} || true)\""; - }; + } // (if opt.vm then { + vm = '' + if test "$(virsh --connect qemu:///system domstate ubuntu25.10)" != "running" + virsh --connect qemu:///system start ubuntu25.10 + sleep 5 + end + + ssh vm@192.168.122.232 + ''; + vmstop = "virsh --connect qemu:///system shutdown ubuntu25.10"; + } else {}); }; environment.systemPackages = with pkgs; [ nushell diff --git a/nixos/opt/default.nix b/nixos/opt/default.nix index 58a6dcf..86f4073 100644 --- a/nixos/opt/default.nix +++ b/nixos/opt/default.nix @@ -2,5 +2,7 @@ { imports = (if opt.nvidia then [ ./nvidia.nix ] else []) ++ + (if opt.tailscale then [ ./tailscale.nix ] else []) ++ + (if opt.vm then [ ./vm.nix ] else []) ++ (if opt.llm then [ ./llm.nix ] else []); } diff --git a/nixos/opt/tailscale.nix b/nixos/opt/tailscale.nix new file mode 100644 index 0000000..a14c93b --- /dev/null +++ b/nixos/opt/tailscale.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: +{ + # 1. Enable the service and the firewall + services.tailscale.enable = true; + networking.nftables.enable = true; + networking.firewall = { + enable = true; + # Always allow traffic from your Tailscale network + trustedInterfaces = [ "tailscale0" ]; + # Allow the Tailscale UDP port through the firewall + allowedUDPPorts = [ config.services.tailscale.port ]; + }; + + # 2. Force tailscaled to use nftables (Critical for clean nftables-only systems) + # This avoids the "iptables-compat" translation layer issues. + systemd.services.tailscaled.serviceConfig.Environment = [ + "TS_DEBUG_FIREWALL_MODE=nftables" + ]; + + # 3. Optimization: Prevent systemd from waiting for network online + # (Optional but recommended for faster boot with VPNs) + systemd.network.wait-online.enable = false; + boot.initrd.systemd.network.wait-online.enable = false; +} diff --git a/nixos/opt/vm.nix b/nixos/opt/vm.nix new file mode 100644 index 0000000..0549b41 --- /dev/null +++ b/nixos/opt/vm.nix @@ -0,0 +1,18 @@ +{ config, pkgs, username, ... }: +{ + virtualisation.libvirtd.enable = true; + programs.virt-manager.enable = true; + users.users.${username}.extraGroups = [ + "libvirtd" + ]; + + environment.systemPackages = with pkgs; [ + virt-manager + qemu + mkcert + ]; + + networking.extraHosts = '' + 192.168.122.232 home.arpa + ''; +} -- cgit v1.2.3