diff --git a/flake.lock b/flake.lock
index cd17dc9..7853c7e 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,23 +1,23 @@
{
"nodes": {
- "disko": {
+ "NixVirt": {
"inputs": {
"nixpkgs": [
"nixpkgs"
- ]
+ ],
+ "nixpkgs-ovmf": "nixpkgs-ovmf"
},
"locked": {
- "lastModified": 1733168902,
- "narHash": "sha256-8dupm9GfK+BowGdQd7EHK5V61nneLfr9xR6sc5vtDi0=",
- "owner": "nix-community",
- "repo": "disko",
- "rev": "785c1e02c7e465375df971949b8dcbde9ec362e5",
- "type": "github"
+ "lastModified": 1712439808,
+ "narHash": "sha256-QoONoZPBpNTw5cia05QSvDlaxXo3moKAJQOw7c5hMXA=",
+ "rev": "9f1cdca730d92461075709e867c1e9ad93d58a8d",
+ "revCount": 284,
+ "type": "tarball",
+ "url": "https://api.flakehub.com/f/pinned/AshleyYakeley/NixVirt/0.5.0/018eb55e-7beb-75c5-919f-5b5b26136e06/source.tar.gz"
},
"original": {
- "owner": "nix-community",
- "repo": "disko",
- "type": "github"
+ "type": "tarball",
+ "url": "https://flakehub.com/f/AshleyYakeley/NixVirt/%2A.tar.gz"
}
},
"flake-compat": {
@@ -135,6 +135,22 @@
"type": "github"
}
},
+ "nixpkgs-ovmf": {
+ "locked": {
+ "lastModified": 1708984720,
+ "narHash": "sha256-gJctErLbXx4QZBBbGp78PxtOOzsDaQ+yw1ylNQBuSUY=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "13aff9b34cc32e59d35c62ac9356e4a41198a538",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
"nixpkgs_2": {
"locked": {
"lastModified": 1733759999,
@@ -173,7 +189,7 @@
},
"root": {
"inputs": {
- "disko": "disko",
+ "NixVirt": "NixVirt",
"home-manager": "home-manager",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs",
diff --git a/flake.nix b/flake.nix
index 28c30ff..35c4526 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,13 +15,13 @@
url = "github:nix-community/NixOS-WSL/2405.5.4";
inputs.nixpkgs.follows = "nixpkgs";
};
- disko = {
- url = "github:nix-community/disko";
+ NixVirt = {
+ url = "https://flakehub.com/f/AshleyYakeley/NixVirt/*.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
};
- outputs = { self, nixpkgs, nur, home-manager, nixos-wsl, disko }:
+ outputs = { self, nixpkgs, nur, home-manager, nixos-wsl, NixVirt }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
@@ -53,6 +53,8 @@
./src/system/machines/workstation
home-manager.nixosModules.home-manager
(import ./src/system/machines/workstation/modules/home-manager)
+ NixVirt.nixosModules.default
+ (import ./src/system/VMs)
];
};
@@ -82,8 +84,6 @@
./src/system/machines/vm
home-manager.nixosModules.home-manager
(import ./src/system/machines/vm/modules/home-manager)
- disko.nixosModules.disko
- (import ./src/system/machines/vm/modules/disko)
];
};
};
diff --git a/justfile b/justfile
index 7a367f0..e30b07f 100644
--- a/justfile
+++ b/justfile
@@ -27,6 +27,7 @@ out TYPE SYSTEM="desktop":
"nix")
if
[ "{{SYSTEM}}" = "desktop" ] || \
+ [ "{{SYSTEM}}" = "workstation" ] || \
[ "{{SYSTEM}}" = "server" ] || \
[ "{{SYSTEM}}" = "wsl" ] || \
[ "{{SYSTEM}}" = "vm" ] || \
@@ -40,6 +41,7 @@ out TYPE SYSTEM="desktop":
Error: Unknown argument - '{{SYSTEM}}'
Use one of:
desktop
+ workstation
server
laptop
vm
@@ -72,6 +74,7 @@ test TYPE SYSTEM="desktop":
"nix")
if
[ "{{SYSTEM}}" = "desktop" ] || \
+ [ "{{SYSTEM}}" = "workstation" ] || \
[ "{{SYSTEM}}" = "server" ] || \
[ "{{SYSTEM}}" = "wsl" ] || \
[ "{{SYSTEM}}" = "vm" ] || \
@@ -85,6 +88,7 @@ test TYPE SYSTEM="desktop":
Error: Unknown argument - '{{SYSTEM}}'
Use one of:
desktop
+ workstation
server
laptop
vm
@@ -117,6 +121,7 @@ build TYPE SYSTEM="desktop":
"nix")
if
[ "{{SYSTEM}}" = "desktop" ] || \
+ [ "{{SYSTEM}}" = "workstation" ] || \
[ "{{SYSTEM}}" = "server" ] || \
[ "{{SYSTEM}}" = "wsl" ] || \
[ "{{SYSTEM}}" = "vm" ] || \
@@ -132,6 +137,7 @@ build TYPE SYSTEM="desktop":
Error: Unknown argument - '{{SYSTEM}}'
Use one of:
desktop
+ workstation
server
laptop
vm
@@ -162,6 +168,7 @@ vm SYSTEM:
set -euo pipefail
if
[ "{{SYSTEM}}" = "desktop" ] || \
+ [ "{{SYSTEM}}" = "workstation" ] || \
[ "{{SYSTEM}}" = "server" ] || \
[ "{{SYSTEM}}" = "wsl" ] || \
[ "{{SYSTEM}}" = "vm" ] || \
@@ -182,6 +189,7 @@ vm SYSTEM:
Error: Unknown argument - '{{SYSTEM}}'
Use one of:
desktop
+ workstation
server
laptop
vm
diff --git a/src/system/VMs/config/machines/Test_Bench1.xml b/src/system/VMs/config/machines/Test_Bench1.xml
new file mode 100644
index 0000000..3e08cf6
--- /dev/null
+++ b/src/system/VMs/config/machines/Test_Bench1.xml
@@ -0,0 +1,192 @@
+
+ Test_Bench1
+ 6dab32d2-aa81-469f-a0d7-dbe4a12c2337
+
+ Rocky 9.2
+ Redhawk 9.2
+ SimWB 2024.2-0
+
+
+
+
+
+
+ 4194304
+ 4194304
+ 4
+
+ hvm
+ /run/libvirt/nix-ovmf/OVMF_CODE.fd
+ /var/lib/libvirt/qemu/nvram/Test_Bench1_VARS.fd
+
+
+
+
+
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ destroy
+
+
+
+
+
+ /run/libvirt/nix-emulators/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /dev/urandom
+
+
+
+
+
diff --git a/src/system/VMs/config/networks/virbr0.xml b/src/system/VMs/config/networks/virbr0.xml
new file mode 100644
index 0000000..f002c29
--- /dev/null
+++ b/src/system/VMs/config/networks/virbr0.xml
@@ -0,0 +1,17 @@
+
+ default
+ 14667e27-1e89-40fb-ba5a-381a6c79bd5f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/system/VMs/config/storage/pools/default.xml b/src/system/VMs/config/storage/pools/default.xml
new file mode 100644
index 0000000..02bf597
--- /dev/null
+++ b/src/system/VMs/config/storage/pools/default.xml
@@ -0,0 +1,18 @@
+
+ default
+ 70edbae5-7ea6-4996-a457-bc1d450b6be4
+ 536608768000
+ 31873052672
+ 504735715328
+
+
+
+ /var/lib/libvirt/images
+
+ 0711
+ 0
+ 0
+
+
+
+
diff --git a/src/system/VMs/config/storage/volumes/rocky9.xml b/src/system/VMs/config/storage/volumes/rocky9.xml
new file mode 100644
index 0000000..ca934d5
--- /dev/null
+++ b/src/system/VMs/config/storage/volumes/rocky9.xml
@@ -0,0 +1,28 @@
+
+ rocky9.qcow2
+ /var/lib/libvirt/images/rocky9.qcow2
+ 107374182400
+ 10468622336
+ 107390828544
+
+ /var/lib/libvirt/images/rocky9.qcow2
+
+
+ 0600
+ 0
+ 0
+
+
+ 1738001245.563436511
+ 1738001224.380580475
+ 1738001224.667578536
+ 0
+
+ 1.1
+ 65536
+
+
+
+
+
+
diff --git a/src/system/VMs/default.nix b/src/system/VMs/default.nix
new file mode 100644
index 0000000..4a772b4
--- /dev/null
+++ b/src/system/VMs/default.nix
@@ -0,0 +1,35 @@
+{ pkgs, lib, config, ... }:
+
+{
+ virtualisation.libvirt = {
+ enable = true;
+ verbose = true;
+
+ connections."qemu:///system" = {
+ domains = [
+ {
+ definition = ./config/machines/Test_Bench1.xml;
+ }
+ ];
+
+ pools = [
+ {
+ definition = ./config/storage/pools/default.xml;
+ active = true;
+ volumes = [
+ {
+ definition = ./config/storage/volumes/rocky9.xml;
+ }
+ ];
+ }
+ ];
+
+ networks = [
+ {
+ definition = ./config/networks/virbr0.xml;
+ active = true;
+ }
+ ];
+ };
+ };
+}
diff --git a/src/system/machines/workstation/hardware.nix b/src/system/machines/workstation/hardware.nix
index 200250e..e4df2d9 100644
--- a/src/system/machines/workstation/hardware.nix
+++ b/src/system/machines/workstation/hardware.nix
@@ -60,14 +60,6 @@
};
};
- virtualisation.libvirtd = {
- enable = true;
- qemu = {
- runAsRoot = true;
- ovmf.enable = true;
- };
- };
-
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
}
diff --git a/src/system/machines/workstation/system.nix b/src/system/machines/workstation/system.nix
index 3706c50..4c7289d 100644
--- a/src/system/machines/workstation/system.nix
+++ b/src/system/machines/workstation/system.nix
@@ -1,5 +1,6 @@
{ pkgs, lib, config, ... }:
+with lib;
{ system.stateVersion = "23.11";
users.users = {
@@ -9,7 +10,7 @@
++ [ "video" "audio" "kvm" "libvirtd" "dialout" ];
openssh.authorizedKeys.keys = [
"${config.user.keys.ssh.primary}"
- "${config.user.keys.ssh.ccur}"
+ "${config.user.keys.ssh.work}"
];
};
};
@@ -98,6 +99,7 @@
"3.pool.ntp.org"
];
};
+
pipewire = {
enable = true;
audio.enable = true;
@@ -109,6 +111,7 @@
alsa.enable = true;
alsa.support32Bit = true;
};
+
openssh = {
enable = true;
startWhenNeeded = false;
diff --git a/src/user/config/keys/ssh/ccur.pub.key b/src/user/config/keys/ssh/work.pub.key
similarity index 100%
rename from src/user/config/keys/ssh/ccur.pub.key
rename to src/user/config/keys/ssh/work.pub.key
diff --git a/src/user/modules/bash/config/prompt.nix b/src/user/modules/bash/config/prompt.nix
index 08aee56..008cd80 100644
--- a/src/user/modules/bash/config/prompt.nix
+++ b/src/user/modules/bash/config/prompt.nix
@@ -32,13 +32,12 @@ check_venv() {
js="js"
nix="nix"
- ${if gui.enable then ''
+ ${optionalString gui.enable ''
if [ -n "$DISPLAY" ]; then
py=""
js=""
nix=""
fi
- '' else ''
''}
python_icon="\[\033[01;33m\]$py\[\033[00m\]"
diff --git a/src/user/modules/security/modules/gpg/default.nix b/src/user/modules/security/modules/gpg/default.nix
index 9930a14..52a48ea 100644
--- a/src/user/modules/security/modules/gpg/default.nix
+++ b/src/user/modules/security/modules/gpg/default.nix
@@ -1,4 +1,4 @@
-{ pkgs, lib, config, ... }:
+{ pkgs, lib, config, osConfig, ... }:
with lib;
let
@@ -18,10 +18,12 @@ in
text = "${config.user.keys.pgp.primary}";
trust = 5;
}
+ ] ++ optionals (osConfig.networking.hostName == "desktop") [
{
text = "${config.user.keys.pgp.windows}";
trust = 5;
}
+ ] ++ optionals (osConfig.networking.hostName == "workstation") [
{
text = "${config.user.keys.pgp.work}";
trust = 5;
diff --git a/src/user/modules/utils/modules/dev/default.nix b/src/user/modules/utils/modules/dev/default.nix
index 6c3a736..23eb2ed 100644
--- a/src/user/modules/utils/modules/dev/default.nix
+++ b/src/user/modules/utils/modules/dev/default.nix
@@ -1,4 +1,4 @@
-{ pkgs, lib, config, ... }:
+{ pkgs, lib, config, osConfig, ... }:
with lib;
let
@@ -16,6 +16,7 @@ in
qrencode
docker
+ ] ++ optionals (osConfig.virtualisation.libvirt.enable) [
virt-manager
];