about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--flake.nix2
-rw-r--r--justfile6
-rw-r--r--nix/flake/hosts.nix12
-rw-r--r--nix/hosts/vm/default.nix29
-rw-r--r--nix/hosts/vm/hardware.nix14
6 files changed, 68 insertions, 0 deletions
diff --git a/README.md b/README.md
index 154709f..ece55f0 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,6 @@
 Tools, scripts, and configurations for my machines.
+
+## Linux VM
+
+- using UTM
+- deploy by running `nixos-rebuild switch --flake ".#vm"` on the VM
diff --git a/flake.nix b/flake.nix
index b37000b..0ceed11 100644
--- a/flake.nix
+++ b/flake.nix
@@ -45,6 +45,8 @@
       systems = [
         "aarch64-darwin"
         "x86_64-darwin"
+
+        "aarch64-linux"
         "x86_64-linux"
       ];
 
diff --git a/justfile b/justfile
index 829e8f9..5179ff1 100644
--- a/justfile
+++ b/justfile
@@ -1,18 +1,24 @@
+# a quick setup
 setup:
 	rye sync
 
+# update dependencies
 update-deps:
 	nix flake update --commit-lock-file
 
+# build (and only build) the configuration for darwin
 build-darwin:
 	darwin-rebuild build --flake .#
 
+# build and switch the configuration for darwin
 switch-darwin:
 	darwin-rebuild switch --flake .#
 
+# a simple check to ensure the nix configuration is OK
 test-nix:
 	nix flake check
 	nix develop -c echo OK
 
+# run various formatting tools
 fmt:
 	nix fmt
diff --git a/nix/flake/hosts.nix b/nix/flake/hosts.nix
index 36821b6..c02fe6c 100644
--- a/nix/flake/hosts.nix
+++ b/nix/flake/hosts.nix
@@ -30,6 +30,14 @@ let
       ];
       specialArgs = { inherit inputs self; };
     };
+
+  mkNixosConfig = system: path: nixpkgs.lib.nixosSystem {
+    inherit system;
+    modules = [
+      path
+    ];
+    specialArgs = { inherit inputs self; };
+  };
 in
 {
   flake = mkMerge [
@@ -38,6 +46,10 @@ in
         mba-fcuny = mkDarwinConfig "aarch64-darwin" "${self}/nix/hosts/mba";
         HQ-C02FK3Q7MD6T = mkDarwinConfig "x86_64-darwin" "${self}/nix/hosts/work";
       };
+
+      nixosConfigurations = {
+        vm = mkNixosConfig "aarch64-linux" "${self}/nix/hosts/vm";
+      };
     }
   ];
 }
diff --git a/nix/hosts/vm/default.nix b/nix/hosts/vm/default.nix
new file mode 100644
index 0000000..a6dff3a
--- /dev/null
+++ b/nix/hosts/vm/default.nix
@@ -0,0 +1,29 @@
+{ pkgs, ... }: {
+  imports = [
+    ./hardware.nix
+  ];
+
+  boot.tmp.cleanOnBoot = true;
+  zramSwap.enable = false;
+
+  networking = {
+    hostName = "nixos";
+    domain = "";
+  };
+
+  services.openssh.enable = true;
+
+  users.users.root.openssh.authorizedKeys.keys = [
+    ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINBkozy+X96u5ciX766bJ/AyQ3xm1tXZTIr5+4PVFZFi''
+  ];
+
+  system.stateVersion = "23.11";
+
+  environment = {
+    systemPackages = with pkgs; [
+      git
+      jq
+      vim
+    ];
+  };
+}
diff --git a/nix/hosts/vm/hardware.nix b/nix/hosts/vm/hardware.nix
new file mode 100644
index 0000000..89c3d8b
--- /dev/null
+++ b/nix/hosts/vm/hardware.nix
@@ -0,0 +1,14 @@
+{ modulesPath, ... }:
+{
+  imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
+  boot.loader.grub = {
+    efiSupport = true;
+    efiInstallAsRemovable = true;
+    device = "nodev";
+  };
+  fileSystems."/boot" = { device = "/dev/disk/by-uuid/E783-E9AE"; fsType = "vfat"; };
+  boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" ];
+  boot.initrd.kernelModules = [ "nvme" ];
+  fileSystems."/" = { device = "/dev/vda2"; fsType = "ext4"; };
+  swapDevices = [{ device = "/dev/vda3"; }];
+}