From 70e75584210fa5d355e49461b514f3ca3fa28982 Mon Sep 17 00:00:00 2001
From: NullBite <me@nullbite.com>
Date: Mon, 22 Jul 2024 02:14:21 -0400
Subject: [PATCH] system: refactor profiles, remove common/desktop

---
 hosts/nullbox/configuration.nix |  6 +--
 hosts/slab/configuration.nix    |  2 +-
 system/common/default.nix       |  1 -
 system/common/desktop.nix       | 66 ---------------------------------
 system/profile/default.nix      |  1 +
 system/profile/pc.nix           | 35 ++++++++++++++++-
 system/profile/workstation.nix  | 51 +++++++++++++++++++++++++
 system/sessions/hyprland.nix    |  3 +-
 system/sessions/plasma.nix      |  3 +-
 9 files changed, 92 insertions(+), 76 deletions(-)
 delete mode 100644 system/common/desktop.nix
 create mode 100644 system/profile/workstation.nix

diff --git a/hosts/nullbox/configuration.nix b/hosts/nullbox/configuration.nix
index c1b1527..6ffabc6 100644
--- a/hosts/nullbox/configuration.nix
+++ b/hosts/nullbox/configuration.nix
@@ -52,7 +52,7 @@
 
     # nixfiles
     nixfiles = {
-      profile.pc.enable = true;
+      profile.workstation.enable = true;
       programs.adb.enable = true;
       workarounds.nvidiaPrimary = true;
       programs.greetd = {
@@ -65,8 +65,8 @@
       };
       programs.unbound.enable = true;
       common.remoteAccess.enable = true;
-      sessions.plasma.enable = lib.mkDefault false;
-      sessions.hyprland.enable = lib.mkDefault true;
+      sessions.plasma.enable = lib.mkDefault true;
+      sessions.hyprland.enable = lib.mkDefault false;
       hardware.nvidia.modesetting.enable = true;
       packageSets.gaming.enable = true;
     };
diff --git a/hosts/slab/configuration.nix b/hosts/slab/configuration.nix
index 89e034c..0610bed 100644
--- a/hosts/slab/configuration.nix
+++ b/hosts/slab/configuration.nix
@@ -49,7 +49,7 @@
   services.displayManager.sddm.enable = false;
 
   nixfiles = {
-    profile.pc.enable = true;
+    profile.workstation.enable = true;
     common.remoteAccess.enable = true;
     hardware.opengl.enable = true;
     packageSets = {
diff --git a/system/common/default.nix b/system/common/default.nix
index 2ce7502..e048c72 100644
--- a/system/common/default.nix
+++ b/system/common/default.nix
@@ -1,7 +1,6 @@
 {...}:
 {
   imports = [
-    ./desktop.nix
     ./me.nix
     ./remote.nix
     ./wm.nix
diff --git a/system/common/desktop.nix b/system/common/desktop.nix
deleted file mode 100644
index 9b8e217..0000000
--- a/system/common/desktop.nix
+++ /dev/null
@@ -1,66 +0,0 @@
-{ config, lib, pkgs, outputs, ...}:
-let
-  cfg = config.nixfiles.common.desktop;
-  inherit (lib) mkIf mkDefault mkForce mkEnableOption;
-in
-{
-  # imports = [
-  #   ./base.nix
-  #   ./fragments/sound.nix
-  #   ./fragments/multimedia.nix
-  #   ./fragments/software/syncthing.nix
-  #   ./fragments/hardware/bluetooth.nix
-  # ];
-
-  options.nixfiles.common.desktop = {
-    enable = mkEnableOption "common desktop configuration";
-  };
-
-  config = mkIf cfg.enable {
-    # enable option sets
-    nixfiles = {
-      profile.base.enable = true;
-      packageSets.multimedia.enable = mkDefault true;
-      programs.syncthing.enable = mkDefault true;
-      hardware = {
-        bluetooth.enable = mkDefault true;
-        sound.enable = mkDefault true;
-      };
-    };
-
-    # Enable the X11 windowing system.
-    services.xserver.enable = true;
-
-    environment.systemPackages = with pkgs; [
-      arc-theme
-      wl-clipboard
-    ];
-
-    # this solves some inconsistent behavior with xdg-open
-    xdg.portal.xdgOpenUsePortal = true;
-
-    # Enable flatpak
-    services.flatpak.enable = mkDefault true;
-
-    # Enable CUPS to print documents.
-    services.printing = {
-      enable = mkDefault true;
-      cups-pdf.enable = mkDefault true;
-    };
-
-    fonts.packages = with pkgs; [
-      (nerdfonts.override { fonts = [ "FiraCode" ]; })
-      font-awesome
-      noto-fonts-cjk
-      (google-fonts.override { fonts = [ "NovaSquare" ];})
-    ];
-
-    # TODO this should be defined in home-manager or not at all probably
-    # FIXME also my name is hardcoded
-    users.users.nullbite = {
-      packages = with pkgs; [
-        firefox
-      ];
-    };
-  };
-}
diff --git a/system/profile/default.nix b/system/profile/default.nix
index bb14035..8c12dce 100644
--- a/system/profile/default.nix
+++ b/system/profile/default.nix
@@ -3,6 +3,7 @@
   imports = [
     ./base.nix
     ./pc.nix
+    ./workstation.nix
     ./server.nix
   ];
 }
diff --git a/system/profile/pc.nix b/system/profile/pc.nix
index 90c2a92..498497d 100644
--- a/system/profile/pc.nix
+++ b/system/profile/pc.nix
@@ -1,17 +1,48 @@
 { pkgs, config, lib, ... }:
 let
   cfg = config.nixfiles.profile.pc;
+  inherit (lib) mkDefault;
 in
 {
-  options.nixfiles.profile.pc.enable = lib.mkEnableOption "the personal computer profile";
+  options.nixfiles.profile.pc.enable = lib.mkEnableOption "minimal PC profile" // {
+    description = ''
+      Whether to enable the minimal PC profile. This profile configures basic
+      system configuration for physical PCs, such as enabling sound and
+      Bluetooth support.
+    '';
+  };
   config = lib.mkIf cfg.enable {
     nixfiles.profile.base.enable = lib.mkDefault true;
-    nixfiles.binfmt.enable = lib.mkDefault true;
+
+    # disabling this for now; it doesn't work in chroot yet (the only reason i
+    # want it) and it takes forever to compile.
+    # nixfiles.binfmt.enable = lib.mkDefault true;
 
     # networking.hostName = "nixos"; # Define your hostname.
     # Pick only one of the below networking options.
     # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
     # FIXME find somewhere else to put this
     networking.networkmanager.enable = lib.mkDefault true;  # Easiest to use and most distros use this by default.
+
+    # enable option sets
+    nixfiles = {
+      hardware = {
+        bluetooth.enable = mkDefault true;
+        sound.enable = mkDefault true;
+      };
+    };
+
+    # probably unnecessary, this will be enabled by whatever session i use
+    # Enable the X11 windowing system.
+    # services.xserver.enable = true;
+
+    # this solves some inconsistent behavior with xdg-open
+    xdg.portal.xdgOpenUsePortal = lib.mkDefault true;
+
+    # Enable CUPS to print documents.
+    services.printing = {
+      enable = mkDefault true;
+      cups-pdf.enable = mkDefault true;
+    };
   };
 }
diff --git a/system/profile/workstation.nix b/system/profile/workstation.nix
new file mode 100644
index 0000000..5508e3d
--- /dev/null
+++ b/system/profile/workstation.nix
@@ -0,0 +1,51 @@
+{ pkgs, config, lib, ... }:
+let
+  cfg = config.nixfiles.profile.workstation;
+  inherit (lib) mkDefault;
+in
+{
+  options.nixfiles.profile.workstation.enable = lib.mkEnableOption "workstation (featureful PC) profile" //
+  {
+    description = ''
+      Whether to enable the workstation (featureful PC) profile. This profile
+      enables the base PC profile, as well as installs and configures various
+      other programs for a more complete computing experience.
+    '';
+  };
+  config = lib.mkIf cfg.enable {
+    nixfiles.profile.pc.enable = lib.mkDefault true;
+    nixfiles.packageSets.multimedia.enable = lib.mkDefault true;
+    nixfiles.programs.syncthing.enable = lib.mkDefault true;
+
+    # probably unnecessary, this will be enabled by whatever session i use
+    # Enable the X11 windowing system.
+    # services.xserver.enable = true;
+
+    environment.systemPackages = with pkgs; [
+      arc-theme
+      wl-clipboard
+      xclip
+    ];
+
+    # this solves some inconsistent behavior with xdg-open
+    xdg.portal.xdgOpenUsePortal = true;
+
+    # Enable flatpak
+    services.flatpak.enable = mkDefault true;
+
+    fonts.packages = with pkgs; [
+      (nerdfonts.override { fonts = [ "FiraCode" ]; })
+      font-awesome
+      noto-fonts-cjk
+      (google-fonts.override { fonts = [ "NovaSquare" ];})
+    ];
+
+    # TODO this should be defined in home-manager or not at all probably
+    # FIXME also my name is hardcoded
+    users.users.nullbite = {
+      packages = with pkgs; [
+        firefox
+      ];
+    };
+  };
+}
diff --git a/system/sessions/hyprland.nix b/system/sessions/hyprland.nix
index e225287..0e50367 100644
--- a/system/sessions/hyprland.nix
+++ b/system/sessions/hyprland.nix
@@ -26,7 +26,6 @@ in
   config = lib.mkIf cfg.enable {
     # enable dependencies
     nixfiles.common = {
-      desktop.enable = true;
       wm.enable = true;
     };
     nixfiles.meta.wayland = true;
@@ -39,6 +38,8 @@ in
       };
     };
 
+    # misleading name
+    services.xserver.enable = true;
     programs.hyprland = {
       enable = true;
       # # TODO base this on if nvidia is enabled
diff --git a/system/sessions/plasma.nix b/system/sessions/plasma.nix
index 2721e27..06a6429 100644
--- a/system/sessions/plasma.nix
+++ b/system/sessions/plasma.nix
@@ -15,8 +15,7 @@ in
   };
 
   config = mkIf cfg.enable {
-    nixfiles.common.desktop.enable = true;
-
+    services.xserver.enable = true;
     services.displayManager.sddm.enable = mkDefault true;
     services.xserver.desktopManager.plasma6.enable = true;
     services.displayManager.defaultSession = "plasma";