From 74499fb6a094923c71af5e7edfff763d01faae96 Mon Sep 17 00:00:00 2001
From: Tom Alexander <tom@fizz.buzz>
Date: Thu, 19 Dec 2024 16:28:40 -0500
Subject: [PATCH] Switch to a different way of building the VM.

---
 nix/configuration/configuration.nix      |  1 +
 nix/configuration/flake.lock             | 99 ++++++++++++++++++++++++
 nix/configuration/flake.nix              | 85 ++++++++++----------
 nix/configuration/roles/sway/default.nix | 13 ++++
 4 files changed, 157 insertions(+), 41 deletions(-)
 create mode 100644 nix/configuration/flake.lock

diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix
index 6d37573..0338085 100644
--- a/nix/configuration/configuration.nix
+++ b/nix/configuration/configuration.nix
@@ -8,6 +8,7 @@
       ./boot.nix
       ./zfs.nix
       ./network.nix
+      ./roles/sway
     ];
 
   nix.settings.experimental-features = [ "nix-command" "flakes" ];
diff --git a/nix/configuration/flake.lock b/nix/configuration/flake.lock
new file mode 100644
index 0000000..96f9515
--- /dev/null
+++ b/nix/configuration/flake.lock
@@ -0,0 +1,99 @@
+{
+  "nodes": {
+    "home-manager": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1734366194,
+        "narHash": "sha256-vykpJ1xsdkv0j8WOVXrRFHUAdp9NXHpxdnn1F4pYgSw=",
+        "owner": "nix-community",
+        "repo": "home-manager",
+        "rev": "80b0fdf483c5d1cb75aaad909bd390d48673857f",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "ref": "release-24.11",
+        "repo": "home-manager",
+        "type": "github"
+      }
+    },
+    "impermanence": {
+      "locked": {
+        "lastModified": 1734200366,
+        "narHash": "sha256-0NursoP4BUdnc+wy+Mq3icHkXu/RgP1Sjo0MJxV2+Dw=",
+        "owner": "nix-community",
+        "repo": "impermanence",
+        "rev": "c6323585fa0035d780e3d8906eb1b24b65d19a48",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "repo": "impermanence",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1734323986,
+        "narHash": "sha256-m/lh6hYMIWDYHCAsn81CDAiXoT3gmxXI9J987W5tZrE=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "394571358ce82dff7411395829aa6a3aad45b907",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-24.11",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs-b93b4e9b5": {
+      "locked": {
+        "lastModified": 1713721570,
+        "narHash": "sha256-R0s+O5UjTePQRb72XPgtkTmEiOOW8n+1q9Gxt/OJnKU=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "b93b4e9b527904aadf52dba6ca35efde2067cbd4",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "b93b4e9b527904aadf52dba6ca35efde2067cbd4",
+        "type": "github"
+      }
+    },
+    "nixpkgs-unstable": {
+      "locked": {
+        "lastModified": 1734424634,
+        "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "d3c42f187194c26d9f0309a8ecc469d6c878ce33",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "home-manager": "home-manager",
+        "impermanence": "impermanence",
+        "nixpkgs": "nixpkgs",
+        "nixpkgs-b93b4e9b5": "nixpkgs-b93b4e9b5",
+        "nixpkgs-unstable": "nixpkgs-unstable"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/nix/configuration/flake.nix b/nix/configuration/flake.nix
index 719d709..24408ee 100644
--- a/nix/configuration/flake.nix
+++ b/nix/configuration/flake.nix
@@ -12,8 +12,52 @@
 
   outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-b93b4e9b5, impermanence, home-manager, ... }@inputs: let
     base-system = {};
+    odoqemu = nixpkgs.lib.nixosSystem rec {
+      system = "x86_64-linux";
+      specialArgs = {
+        pkgs-b93b4e9b5 = import nixpkgs-b93b4e9b5 {
+          inherit system;
+          # config.allowUnfree = true;
+        };
+        pkgs-unstable = import nixpkgs-unstable {
+          inherit system;
+          # config.allowUnfree = true;
+        };
+      };
+      modules = [
+        impermanence.nixosModules.impermanence
+        home-manager.nixosModules.home-manager
+        {
+          home-manager.useGlobalPkgs = true;
+          home-manager.useUserPackages = true;
+        }
+        ./configuration.nix
+        ({lib, ...}: {
+          imports = [ <nixpkgs/nixos/modules/virtualisation/qemu-vm.nix> ];
+          virtualisation.qemu.options = [
+            "-device virtio-vga"
+          ];
+          virtualisation.vmVariant = {
+            # following configuration is added only when building VM with build-vm
+            virtualisation = {
+              memorySize = 2048; # Use 2048MiB memory.
+              cores = 3;
+              graphics = false;
+            };
+          };
+          networking.dhcpcd.enable = lib.mkForce true;
+          networking.useDHCP = lib.mkForce true;
+          boot.loader.efi.canTouchEfiVariables = lib.mkForce true;
+          # doas nixos-rebuild build-vm --flake .#odoqemu
+          #./result/bin/run-nixos-vm
+        })
+      ];
+    };
   in
     {
+      # doas nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#vms.odo
+      # ./result/bin/run-nixos-vim
+      vms.odo = odoqemu.config.system.build.vm;
       nixosConfigurations.odo = nixpkgs.lib.nixosSystem rec {
         system = "x86_64-linux";
         specialArgs = {
@@ -63,46 +107,5 @@
           })
         ];
       };
-      nixosConfigurations.odoqemu = nixpkgs.lib.nixosSystem rec {
-        system = "x86_64-linux";
-        specialArgs = {
-          pkgs-b93b4e9b5 = import nixpkgs-b93b4e9b5 {
-            inherit system;
-            # config.allowUnfree = true;
-          };
-          pkgs-unstable = import nixpkgs-unstable {
-            inherit system;
-            # config.allowUnfree = true;
-          };
-        };
-        modules = [
-          impermanence.nixosModules.impermanence
-          home-manager.nixosModules.home-manager
-          {
-            home-manager.useGlobalPkgs = true;
-            home-manager.useUserPackages = true;
-          }
-          ./configuration.nix
-          ({lib, ...}: {
-            imports = [ <nixpkgs/nixos/modules/virtualisation/qemu-vm.nix> ];
-            virtualisation.qemu.options = [
-              "-device virtio-vga"
-            ];
-            virtualisation.vmVariant = {
-              # following configuration is added only when building VM with build-vm
-              virtualisation = {
-                memorySize = 2048; # Use 2048MiB memory.
-                cores = 3;
-                graphics = false;
-              };
-            };
-            networking.dhcpcd.enable = lib.mkForce true;
-            networking.useDHCP = lib.mkForce true;
-            boot.loader.efi.canTouchEfiVariables = lib.mkForce true;
-            # doas nixos-rebuild build-vm --flake .#odoqemu
-            #./result/bin/run-nixos-vm
-          })
-        ];
-      };
     };
 }
diff --git a/nix/configuration/roles/sway/default.nix b/nix/configuration/roles/sway/default.nix
index 8e42776..4370d73 100644
--- a/nix/configuration/roles/sway/default.nix
+++ b/nix/configuration/roles/sway/default.nix
@@ -3,5 +3,18 @@
 {
   imports = [];
 
+  environment.systemPackages = with pkgs; [
+    grim # screenshot functionality
+    slurp # screenshot functionality
+    wl-clipboard # wl-copy and wl-paste for copy/paste from stdin / stdout
+    mako # notification system developed by swaywm maintainer
+  ];
+
+  # enable Sway window manager
+  programs.sway = {
+    enable = true;
+    wrapperFeatures.gtk = true;
+  };
+
   # foo
 }