From abe4903e6b3067ca18d82308ce4fbf50ffa080ff Mon Sep 17 00:00:00 2001
From: NullBite <me@nullbite.com>
Date: Sat, 20 Jan 2024 21:50:46 +0100
Subject: [PATCH] add downgraded version of android-tools

---
 flake.nix                 | 9 +++++++--
 modules/nixos/adb-old.nix | 4 ++++
 system/android.nix        | 9 +++++++++
 3 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 system/android.nix

diff --git a/flake.nix b/flake.nix
index 508bfac..89d0703 100644
--- a/flake.nix
+++ b/flake.nix
@@ -33,7 +33,7 @@
     # define extra packages here
     mkExtraPkgs = system: {
       # android-tools = inputs.pkg-android-tools.legacyPackages.${system}.android-tools;
-      inherit (inputs.pkg-android-tools.legacyPackages.${system}) android-tools;
+      inherit (inputs.pkg-android-tools.legacyPackages.${system}) android-tools android-udev-rules;
     };
 
     # Variables to be passed to NixOS modules in the vars attrset
@@ -66,7 +66,7 @@
 
     # This function produces a nixosSystem which imports configuration.nix and
     # a Home Manager home.nix for the given user from ./hosts/${hostname}/
-    mkSystem = {system, hostname, username ? username}:
+    mkSystem = {system, hostname, username ? _username}:
       lib.nixosSystem {
         inherit system;
         modules = [
@@ -102,12 +102,17 @@
           ./system/plasma.nix
           ./system/fragments/opengl.nix
           ./system/gaming.nix
+          ./system/android.nix
           # ./system/hyprland.nix
           (homeManagerInit {
             module = import ./hosts/slab/home.nix;
             inherit system;
           })
         ];
+        specialArgs = {
+          inherit inputs outputs vars;
+          extraPkgs = mkExtraPkgs system;
+        };
       };
       nullbox = lib.nixosSystem rec {
         system = "x86_64-linux";
diff --git a/modules/nixos/adb-old.nix b/modules/nixos/adb-old.nix
index 691508e..75ef1f8 100644
--- a/modules/nixos/adb-old.nix
+++ b/modules/nixos/adb-old.nix
@@ -1,10 +1,14 @@
 { config, lib, pkgs, extraPkgs, ... }:
+# TODO extraPkgs isn't a normal argument, make this somehow accessible if
+# imported into a different configuration; maybe a wrapper function in the flake
 
 with lib;
 
 {
   meta.maintainers = [ maintainers.mic92 ];
 
+  disabledModules = [ "programs/adb.nix" ];
+
   ###### interface
   options = {
     programs.adb = {
diff --git a/system/android.nix b/system/android.nix
new file mode 100644
index 0000000..39a069c
--- /dev/null
+++ b/system/android.nix
@@ -0,0 +1,9 @@
+{ config, lib, pkgs, outputs, vars, ...}@args:
+{
+  imports = [ outputs.nixosModules.adb ];
+  
+  config = {
+    programs.adb.enable = true;
+    users.users.${vars.username}.extraGroups = [ "adbusers" ];
+  };
+}