From 5247f96a41a05d64bf4f0b0d990542a1f0eb76b2 Mon Sep 17 00:00:00 2001
From: matt1432 <matt@nelim.org>
Date: Wed, 25 Sep 2024 15:34:56 -0400
Subject: [PATCH] refactor: clean up FIXMEs and overlays

---
 common/packages.nix                         |  1 -
 devices/bbsteamie/modules/desktop/steam.nix |  3 +--
 devices/homie/modules/music/default.nix     | 10 ++++++++++
 devices/nos/modules/llm.nix                 | 10 ++++++++++
 inputs.nix                                  |  3 +--
 lib/default.nix                             |  2 +-
 lib/flake-lib.nix                           |  2 ++
 lib/pkgs.nix                                |  7 ++++++-
 outputs.nix                                 |  4 ++--
 overlays/default.nix                        |  1 -
 overlays/misc/default.nix                   | 12 ------------
 11 files changed, 33 insertions(+), 22 deletions(-)
 delete mode 100644 overlays/misc/default.nix

diff --git a/common/packages.nix b/common/packages.nix
index 5ec00e8b..8141b25f 100644
--- a/common/packages.nix
+++ b/common/packages.nix
@@ -12,7 +12,6 @@ inputs @ {
     ++ (builtins.attrValues {
       inherit
         (self.overlays)
-        misc
         xdg-desktop-portal-kde
         ;
     });
diff --git a/devices/bbsteamie/modules/desktop/steam.nix b/devices/bbsteamie/modules/desktop/steam.nix
index 45310c12..cd450ce4 100644
--- a/devices/bbsteamie/modules/desktop/steam.nix
+++ b/devices/bbsteamie/modules/desktop/steam.nix
@@ -68,8 +68,7 @@ defaultSession: {
 
       self.packages.${pkgs.system}.protonhax
 
-      # FIXME: Ryujinx ACNH crashes on Vulkan
-      # https://github.com/Ryujinx/Ryujinx/issues/6708
+      # FIXME: Ryujinx ACNH crashes on Vulkan https://github.com/Ryujinx/Ryujinx/issues/6708
       pkgs.ryujinx
     ];
   };
diff --git a/devices/homie/modules/music/default.nix b/devices/homie/modules/music/default.nix
index 53f8a96c..fcabdcad 100644
--- a/devices/homie/modules/music/default.nix
+++ b/devices/homie/modules/music/default.nix
@@ -84,4 +84,14 @@
   environment.etc."spotifyd/credentials.json" = {
     source = config.sops.secrets.spotifyd.path;
   };
+
+  nixpkgs.overlays = [
+    (final: prev: {
+      # FIXME: remove this if https://github.com/NixOS/nixpkgs/pull/342913 is merged
+      spotifyd = prev.spotifyd.override {
+        withMpris = false;
+        withKeyring = false;
+      };
+    })
+  ];
 }
diff --git a/devices/nos/modules/llm.nix b/devices/nos/modules/llm.nix
index 2b5684fa..d0cdc631 100644
--- a/devices/nos/modules/llm.nix
+++ b/devices/nos/modules/llm.nix
@@ -6,6 +6,16 @@ in {
   # In case tailscale is down
   boot.kernel.sysctl."net.ipv4.ip_nonlocal_bind" = 1;
 
+  nixpkgs.overlays = [
+    # We can get rid of this once full CUDA support works
+    (final: prev: {
+      ctranslate2 = prev.ctranslate2.override {
+        withCUDA = true;
+        withCuDNN = true;
+      };
+    })
+  ];
+
   services = {
     # Speech-to-Text
     wyoming.faster-whisper.servers."en" = {
diff --git a/inputs.nix b/inputs.nix
index 828b6dc8..cf7c8145 100644
--- a/inputs.nix
+++ b/inputs.nix
@@ -56,8 +56,7 @@ let
       repo = "nixos-pcsd";
     };
 
-    # FIXME: use nixpkgs once this reaches unstable
-    # https://github.com/NixOS/nixpkgs/pull/340054
+    # FIXME: use nixpkgs once this reaches unstable https://pr-tracker.nelim.org/?pr=340054
     headscale = mkDep {
       owner = "juanfont";
       repo = "headscale";
diff --git a/lib/default.nix b/lib/default.nix
index 3c4d86bc..6d5ebb63 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -18,4 +18,4 @@ in
   {inherit lib mkVersion capitalise;}
   // (import ./inputs.nix lib lock)
   // optionalAttrs (inputs != {}) (import ./flake-lib.nix inputs)
-  // optionalAttrs (pkgs != {}) (import ./pkgs.nix pkgs mkVersion capitalise self)
+  // optionalAttrs (pkgs != {}) (import ./pkgs.nix {inherit pkgs mkVersion capitalise self;})
diff --git a/lib/flake-lib.nix b/lib/flake-lib.nix
index e602f4a6..146af196 100644
--- a/lib/flake-lib.nix
+++ b/lib/flake-lib.nix
@@ -13,6 +13,7 @@ inputs: rec {
       };
     };
 
+  # Enable use of `nixpkgs.overlays` on both NixOS and NixOnDroid
   allowModularOverrides = {
     cudaSupport ? false,
     system,
@@ -77,6 +78,7 @@ inputs: rec {
             };
 
             config.environment.packages = config.environment.systemPackages;
+
             # This disables the assertion that fails because of nixpkgs.overlays
             config._module.args.isFlake = mkForce false;
           })
diff --git a/lib/pkgs.nix b/lib/pkgs.nix
index bbe75720..ea585e73 100644
--- a/lib/pkgs.nix
+++ b/lib/pkgs.nix
@@ -1,4 +1,9 @@
-pkgs: mkVersion: capitalise: self: {
+{
+  capitalise,
+  mkVersion,
+  pkgs,
+  self,
+}: {
   buildPlugin = pname: src:
     pkgs.vimUtils.buildVimPlugin {
       inherit pname src;
diff --git a/outputs.nix b/outputs.nix
index dfd39fa1..b845207f 100644
--- a/outputs.nix
+++ b/outputs.nix
@@ -72,7 +72,7 @@
         ];
       };
       binto = mkNixOS {
-        # FIXME: https://github.com/NixOS/nixpkgs/issues/338315
+        # FIXME: https://pr-tracker.nelim.org/?pr=339619
         # cudaSupport = true;
         extraModules = [./devices/binto];
       };
@@ -81,7 +81,7 @@
 
       # NAS
       nos = mkNixOS {
-        # FIXME: https://github.com/NixOS/nixpkgs/issues/338315
+        # FIXME: https://pr-tracker.nelim.org/?pr=339619
         # cudaSupport = true;
         extraModules = [
           ./devices/nos
diff --git a/overlays/default.nix b/overlays/default.nix
index fba6f240..ac9abc78 100644
--- a/overlays/default.nix
+++ b/overlays/default.nix
@@ -1,4 +1,3 @@
 {...}: {
-  misc = import ./misc;
   xdg-desktop-portal-kde = import ./xdg-desktop-portal-kde;
 }
diff --git a/overlays/misc/default.nix b/overlays/misc/default.nix
deleted file mode 100644
index 02643330..00000000
--- a/overlays/misc/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-final: prev: {
-  ctranslate2 = prev.ctranslate2.override {
-    withCUDA = true;
-    withCuDNN = true;
-  };
-
-  # FIXME: remove this if https://github.com/NixOS/nixpkgs/pull/342913 is merged
-  spotifyd = prev.spotifyd.override {
-    withMpris = false;
-    withKeyring = false;
-  };
-}