From cfae461c466d26799ec41dee90886d78218d0709 Mon Sep 17 00:00:00 2001 From: Tristan Druyen Date: Mon, 25 Sep 2023 21:01:34 +0200 Subject: [PATCH] WIP: Add qemu --- .directory | 2 ++ configuration.nix | 42 +++++++++++++++++++++++++++++++++++++++++- flake.lock | 24 ++++++++++++------------ home.nix | 28 ++++++++++++++++++++++++++++ users.nix | 2 +- 5 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 .directory diff --git a/.directory b/.directory new file mode 100644 index 0000000..51769f5 --- /dev/null +++ b/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=nix-snowflake-white diff --git a/configuration.nix b/configuration.nix index bb2f254..53cdf6a 100644 --- a/configuration.nix +++ b/configuration.nix @@ -112,6 +112,10 @@ useRoutingFeatures = "both"; }; + services.mozillavpn = { + enable = true; + }; + services.xserver = { enable = true; layout = "us"; @@ -132,6 +136,13 @@ }; services.printing.enable = true; + services.printing.drivers = with pkgs; [ + gutenprint + gutenprintBin + hplipWithPlugin + brlaser + brgenml1cupswrapper + ]; sound.enable = true; hardware.bluetooth.enable = true; @@ -160,6 +171,8 @@ neovim vim virt-manager + virt-viewer + virt-top wl-clipboard wget ]; @@ -182,6 +195,7 @@ # For SMB services.gvfs.enable = true; services.avahi.enable = true; + services.avahi.nssmdns = true; ## services.openssh.enable = true; @@ -192,7 +206,33 @@ # Samba networking.firewall.extraCommands = ''iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns''; - virtualisation.libvirtd.enable = true; + virtualisation.libvirtd = { + enable = true; + + onShutdown = "suspend"; + onBoot = "ignore"; + + qemu = { + package = pkgs.qemu_kvm; + ovmf.enable = true; + ovmf.packages = [pkgs.OVMFFull.fd]; + swtpm.enable = true; + runAsRoot = false; + }; + }; + + # virtualisation.libvirtd.allowedBridges = [ + # "virbr0" + # "testbr0" + # ]; + + # networking.bridges = { + # testbr0 = { + # interfaces = [ + # "enp5s0f4u1u1c2" + # ]; + # }; + # }; powerManagement.powertop.enable = true; systemd.services.powertop.postStart = '' diff --git a/flake.lock b/flake.lock index 0fd5af7..c269661 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1695604864, - "narHash": "sha256-fDdXFT6nBN7jFobQpofOnp/0KIwZbWj8pnx+VUjnP8k=", + "lastModified": 1695660337, + "narHash": "sha256-4ceXFNIUphgqFo4BR0bUEKh65Lud4x5DF/mB/eDdqEI=", "owner": "nix-community", "repo": "disko", - "rev": "021f2a6fbec292d37caaf37517f7d3cd5e584551", + "rev": "fbfd7567c224134b57ee64a663e95285fe7fe048", "type": "github" }, "original": { @@ -29,11 +29,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1695612850, - "narHash": "sha256-XHndbQIku+3wFuvQj8gkKWuLTbS+BP8j3s41oAJ/wMo=", + "lastModified": 1695667627, + "narHash": "sha256-3scmlAWduBQJELvQtAknQ6M2g5hnb0kY1stTOFeTk30=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "5f0b496aa00886a17cf42faa94dce57e0f7ab20c", + "rev": "d1a316b529df678413ba05c970c0c9bdcb6c0d37", "type": "github" }, "original": { @@ -210,11 +210,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1695416179, - "narHash": "sha256-610o1+pwbSu+QuF3GE0NU5xQdTHM3t9wyYhB9l94Cd8=", + "lastModified": 1695559356, + "narHash": "sha256-kXZ1pUoImD9OEbPCwpTz4tHsNTr4CIyIfXb3ocuR8sI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "715d72e967ec1dd5ecc71290ee072bcaf5181ed6", + "rev": "261abe8a44a7e8392598d038d2e01f7b33cf26d0", "type": "github" }, "original": { @@ -258,11 +258,11 @@ }, "nur": { "locked": { - "lastModified": 1695629172, - "narHash": "sha256-uyX3hb9n8O4DdtRLi3VsNLhhgsgV0NwDC0AJ3FT61rI=", + "lastModified": 1695667635, + "narHash": "sha256-8i1CYSn26gt9Psjzac/OXw8vuirM+lclKrlxSfVKEuk=", "owner": "nix-community", "repo": "NUR", - "rev": "d68e23fbf48d0ac738fccb263ba30c7c3441cbe8", + "rev": "013bd502966a0bca732b03c9c88a487bad6c0d67", "type": "github" }, "original": { diff --git a/home.nix b/home.nix index a4df02b..a913451 100644 --- a/home.nix +++ b/home.nix @@ -358,5 +358,33 @@ in { TERMINAL = "alacritty"; }; + xdg.desktopEntries = { + win10 = { + name = "Win 10 VM"; + type = "Application"; + icon = "windows"; + comment = "start the win10 vm"; + exec = pkgs.lib.strings.concatStrings [ + "bash -c \"" + "virsh --connect=qemu:///system start win10; " + "virt-viewer -a -w -c qemu:///system win10 " + "&& virsh --connect=qemu:///system managedsave win10\"" + ]; + }; + win11 = { + name = "Win 11 VM"; + type = "Application"; + icon = "windows"; + comment = "start the win11 vm"; + exec = pkgs.lib.strings.concatStrings [ + "bash -c \"" + "virsh --connect=qemu:///system start win11; " + "virsh --connect=qemu:///system resume win11; " + "virt-viewer -a -w -c qemu:///system win11 " + "&& virsh --connect=qemu:///system managedsave win11\"" + ]; + }; + }; + home.stateVersion = "23.05"; } diff --git a/users.nix b/users.nix index c7c5f36..a445ba1 100644 --- a/users.nix +++ b/users.nix @@ -8,7 +8,7 @@ users.users.tristand = { isNormalUser = true; description = "Tristan Druyen"; - extraGroups = ["networkmanager" "wheel" "libvirtd"]; + extraGroups = ["networkmanager" "wheel" "libvirtd" "qemu-libvirtd"]; shell = pkgs.fish; home = "/home/tristand"; hashedPassword = "$6$Wj.XY8JgH5EWuog4$HnbtPJXDEqKXFrzkPVEjih3PytcpBCrkfL7TAwkXd0IFced7kGMlZNliNsAqQ3XqfyUzAYiiKTIqoPVJEk.s..";