From b95a4e55c25cb5ecf41ef62913d86bb107358044 Mon Sep 17 00:00:00 2001
From: prescientmoon <git@moonythm.dev>
Date: Tue, 27 Aug 2024 16:28:49 +0200
Subject: [PATCH] A lot of iso changes

---
 flake.nix                                     |  2 +-
 home/calypso.nix                              |  2 +-
 home/features/neovim/default.nix              | 12 ++--
 home/iso.nix                                  | 30 +++++----
 hosts/nixos/calypso/filesystems/default.nix   |  5 +-
 .../nixos/calypso/filesystems/partitions.nix  | 25 ++++---
 hosts/nixos/calypso/services/snapper.nix      |  6 ++
 hosts/nixos/iso/default.nix                   | 28 ++++++--
 modules/home-manager/monitors.nix             | 65 ++++++++++---------
 scripts/build-iso.sh                          |  2 +
 scripts/live.sh                               |  2 +-
 11 files changed, 105 insertions(+), 74 deletions(-)
 create mode 100755 scripts/build-iso.sh

diff --git a/flake.nix b/flake.nix
index 4b48a29..aaef727 100644
--- a/flake.nix
+++ b/flake.nix
@@ -151,7 +151,7 @@
                     imports = lib.lists.optionals (builtins.pathExists ./home/${hostname}.nix) [
                       home-manager.nixosModules.home-manager
                       {
-                        home-manager.users.pilot = import ./home/${hostname}.nix;
+                        home-manager.users.pilot = ./home/${hostname}.nix;
                         home-manager.extraSpecialArgs = specialArgs system // {
                           inherit hostname;
                         };
diff --git a/home/calypso.nix b/home/calypso.nix
index e7f6ec8..579269a 100644
--- a/home/calypso.nix
+++ b/home/calypso.nix
@@ -67,7 +67,7 @@
       {
         name = "eDP-1";
         width = 1920;
-        height = 1080;
+        height = 1200;
       }
     ];
   };
diff --git a/home/features/neovim/default.nix b/home/features/neovim/default.nix
index 6652f79..7cdaf00 100644
--- a/home/features/neovim/default.nix
+++ b/home/features/neovim/default.nix
@@ -10,14 +10,14 @@ let
   # Toggles for including tooling related to a given language
   packedTargets = {
     elm = false;
-    latex = !config.satellite.toggles.neovim-minimal.enable;
-    lua = !config.satellite.toggles.neovim-minimal.enable;
+    latex = true;
+    lua = true;
     nix = true;
     purescript = false;
     python = false;
     rust = false;
-    typst = !config.satellite.toggles.neovim-minimal.enable;
-    web = !config.satellite.toggles.neovim-minimal.enable;
+    typst = true;
+    web = true;
     csharp = false;
   };
 
@@ -1699,7 +1699,6 @@ in
   # {{{ Basic config
   # We want other modules to know that we are using neovim!
   satellite.toggles.neovim.enable = true;
-  satellite.toggles.neovim-minimal.enable = lib.mkDefault false;
 
   # Link files in the appropriate places
   xdg.configFile.nvim.source = config.satellite.dev.path "home/features/neovim/config";
@@ -1710,7 +1709,8 @@ in
   home.packages = [
     neovim
     pkgs.vimclip
-  ] ++ lib.lists.optional (!config.satellite.toggles.neovim-minimal.enable) neovide;
+    neovide
+  ];
   # }}}
   # {{{ Persistence
   satellite.persistence.at.state.apps.neovim.directories = [
diff --git a/home/iso.nix b/home/iso.nix
index 4ec41fc..045bb37 100644
--- a/home/iso.nix
+++ b/home/iso.nix
@@ -1,22 +1,30 @@
 { pkgs, ... }:
 {
+  # {{{ Imports
   imports = [
     ./global.nix
-
-    ./features/desktop/foot.nix
-    ./features/desktop/firefox
     ./features/cli/lazygit.nix
+    ./features/desktop/foot.nix
     ./features/wayland/hyprland
-    ./features/neovim
   ];
+  # }}}
+  # {{{ Arbitrary extra packages
+  programs.firefox.enable = true;
 
-  # Arbitrary extra packages
-  home.packages = with pkgs; [
-    sops # Secret editing
-  ];
+  home.packages =
+    let
+      cloneConfig = pkgs.writeShellScriptBin "liftoff" ''
+        git clone git@github.com:prescientmoon/everything-nix.git
+        cd everything-nix
+      '';
+    in
+    with pkgs;
+    [
+      sops # Secret editing
+      neovim # Text editor
+      cloneConfig # Clones my nixos config from github
+    ];
+  # }}}
 
-  home.username = "moon";
   home.stateVersion = "24.05";
-
-  satellite.toggles.neovim-minimal.enable = true;
 }
diff --git a/hosts/nixos/calypso/filesystems/default.nix b/hosts/nixos/calypso/filesystems/default.nix
index b2fd442..acc5540 100644
--- a/hosts/nixos/calypso/filesystems/default.nix
+++ b/hosts/nixos/calypso/filesystems/default.nix
@@ -32,8 +32,9 @@
     after = [ "systemd-cryptsetup@enc.service" ];
     before = [ "sysroot.mount" ];
     script = ''
-      btrfs subvolume delete /root
-      btrfs subvolume snapshot /blank /root
+      ls /
+      btrfs subvolume delete /
+      btrfs subvolume create /
     '';
   };
   # }}}
diff --git a/hosts/nixos/calypso/filesystems/partitions.nix b/hosts/nixos/calypso/filesystems/partitions.nix
index fe1d6ed..0657335 100644
--- a/hosts/nixos/calypso/filesystems/partitions.nix
+++ b/hosts/nixos/calypso/filesystems/partitions.nix
@@ -34,11 +34,8 @@
               extraArgs = [ "-f" ];
 
               subvolumes = {
-                # {{{ /blank
-                "/blank" = { };
-                # }}}
-                # {{{ /root
-                "/root" = {
+                # {{{ /
+                "root" = {
                   mountpoint = "/";
                   mountOptions = [
                     "compress=zstd"
@@ -47,13 +44,13 @@
                 };
                 # }}}
                 # {{{ /swap
-                "/swap" = {
+                "swap" = {
                   mountpoint = "/.swapvol";
                   swap.swapfile.size = "20G";
                 };
                 # }}}
-                # {{{ /root/persist/data
-                "/root/persist/data" = {
+                # {{{ /persist/data
+                "persist-data" = {
                   mountpoint = "/persist/data";
                   mountOptions = [
                     "compress=zstd"
@@ -61,8 +58,8 @@
                   ];
                 };
                 # }}}
-                # {{{ /root/persist/state
-                "/root/persist/state" = {
+                # {{{ /persist/state
+                "persist-state" = {
                   mountpoint = "/persist/state";
                   mountOptions = [
                     "compress=zstd"
@@ -70,8 +67,8 @@
                   ];
                 };
                 # }}}
-                # {{{ /root/local/nix
-                "/root/local/nix" = {
+                # {{{ /local/nix
+                "local-nix" = {
                   mountpoint = "/nix";
                   mountOptions = [
                     "compress=zstd"
@@ -79,8 +76,8 @@
                   ];
                 };
                 # }}}
-                # {{{ /root/local/cache
-                "/root/local/cache" = {
+                # {{{ /local/nix
+                "local-cache" = {
                   mountpoint = "/persist/local/cache";
                   mountOptions = [
                     "compress=zstd"
diff --git a/hosts/nixos/calypso/services/snapper.nix b/hosts/nixos/calypso/services/snapper.nix
index 2c80d17..6d7e2e5 100644
--- a/hosts/nixos/calypso/services/snapper.nix
+++ b/hosts/nixos/calypso/services/snapper.nix
@@ -1,4 +1,10 @@
+{ config, lib, ... }:
 {
+  # Why is this not part of the nixos module...
+  systemd.tmpfiles.rules = lib.mapAttrsToList (
+    _: c: "Q ${c.SUBVOLUME}/.snapshots"
+  ) config.services.snapper.configs;
+
   services.snapper = {
     snapshotInterval = "hourly";
     cleanupInterval = "1d";
diff --git a/hosts/nixos/iso/default.nix b/hosts/nixos/iso/default.nix
index 8e99364..f1a8d1f 100644
--- a/hosts/nixos/iso/default.nix
+++ b/hosts/nixos/iso/default.nix
@@ -1,18 +1,20 @@
+# See the wiki for more details https://wiki.nixos.org/wiki/Creating_a_NixOS_live_CD
+#
+# Can be built with
+# nix build .#nixosConfigurations.iso.config.system.build.isoImage
 { modulesPath, lib, ... }:
 {
+  # {{{ Imports
   imports = [
     "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
 
     ../common/global
+    ../common/users/pilot.nix
+    ../common/optional/desktop
     ../common/optional/wayland/hyprland.nix
+    ../common/optional/services/kanata.nix
   ];
-
-  # Tell sops-nix to use the hermes keys for decrypting secrets
-  sops.age.sshKeyPaths = [ "/hermes/secrets/hermes/ssh_host_ed25519_key" ];
-
-  # Override tailscale service enabled by the `global/default.nix` file
-  services.tailscale.enable = lib.mkForce false;
-
+  # }}}
   # {{{ Automount hermes
   fileSystems."/hermes" = {
     device = "/dev/disk/by-uuid/7FE7-CA68";
@@ -23,4 +25,16 @@
     ];
   };
   # }}}
+
+  # Tell sops-nix to use the hermes keys for decrypting secrets
+  sops.age.sshKeyPaths = [ "/hermes/secrets/hermes/ssh_host_ed25519_key" ];
+
+  # Override tailscale service enabled by the `global/default.nix` file
+  services.tailscale.enable = lib.mkForce false;
+
+  # Fast but bad compression
+  # isoImage.squashfsCompression = "gzip -Xcompression-level 1";
+
+  # Set username
+  satellite.pilot.name = "moon";
 }
diff --git a/modules/home-manager/monitors.nix b/modules/home-manager/monitors.nix
index b9d6de4..c00a150 100644
--- a/modules/home-manager/monitors.nix
+++ b/modules/home-manager/monitors.nix
@@ -3,43 +3,46 @@
 { lib, ... }:
 {
   options.satellite.monitors = lib.mkOption {
-    type = lib.types.listOf (lib.types.submodule {
-      options = {
-        name = lib.mkOption {
-          type = lib.types.str;
-          example = "DP-1";
-        };
+    default = [ ];
+    type = lib.types.listOf (
+      lib.types.submodule {
+        options = {
+          name = lib.mkOption {
+            type = lib.types.str;
+            example = "DP-1";
+          };
 
-        width = lib.mkOption {
-          type = lib.types.int;
-          example = 1920;
-        };
+          width = lib.mkOption {
+            type = lib.types.int;
+            example = 1920;
+          };
 
-        height = lib.mkOption {
-          type = lib.types.int;
-          example = 1080;
-        };
+          height = lib.mkOption {
+            type = lib.types.int;
+            example = 1080;
+          };
 
-        refreshRate = lib.mkOption {
-          type = lib.types.int;
-          default = 60;
-        };
+          refreshRate = lib.mkOption {
+            type = lib.types.int;
+            default = 60;
+          };
 
-        x = lib.mkOption {
-          type = lib.types.int;
-          default = 0;
-        };
+          x = lib.mkOption {
+            type = lib.types.int;
+            default = 0;
+          };
 
-        y = lib.mkOption {
-          type = lib.types.int;
-          default = 0;
-        };
+          y = lib.mkOption {
+            type = lib.types.int;
+            default = 0;
+          };
 
-        workspace = lib.mkOption {
-          type = lib.types.nullOr lib.types.str;
-          default = null;
+          workspace = lib.mkOption {
+            type = lib.types.nullOr lib.types.str;
+            default = null;
+          };
         };
-      };
-    });
+      }
+    );
   };
 }
diff --git a/scripts/build-iso.sh b/scripts/build-iso.sh
new file mode 100755
index 0000000..4a595ae
--- /dev/null
+++ b/scripts/build-iso.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+nix build .#nixosConfigurations.iso.config.system.build.isoImage
diff --git a/scripts/live.sh b/scripts/live.sh
index d6f4988..580e102 100755
--- a/scripts/live.sh
+++ b/scripts/live.sh
@@ -47,7 +47,7 @@ if [ "$action" = "install" ]; then
     > ./hosts/nixos/$host/hardware/generated.nix
   git add .
 
-  echo "❄️  Installing nixos"
+  echo "❄️  nstalling nixos"
   nixos-install --flake ".#$host"
 
   echo "🔑 Copying user ssh keys"