about summary refs log tree commit diff stats
path: root/system/packages/packages.nix
diff options
context:
space:
mode:
authorene <ene@sils.li>2023-02-01 22:23:43 +0100
committerene <ene@sils.li>2023-02-03 17:34:46 +0100
commitd30db6253ca13316057397e8b1bd106bac0af523 (patch)
tree3c1a21eaf9cc930e08ddf584aab7d07826b4f105 /system/packages/packages.nix
parentFeat: Split the config apart (diff)
downloadnixos-config-d30db6253ca13316057397e8b1bd106bac0af523.tar.gz
nixos-config-d30db6253ca13316057397e8b1bd106bac0af523.zip
Refactor(packages): Refactored Packages
Diffstat (limited to '')
-rw-r--r--system/packages/packages.nix36
1 files changed, 34 insertions, 2 deletions
diff --git a/system/packages/packages.nix b/system/packages/packages.nix
index 1acba85e..c9ac9431 100644
--- a/system/packages/packages.nix
+++ b/system/packages/packages.nix
@@ -2,9 +2,41 @@
   config,
   pkgs,
   ...
-}: {
+}: let
+  output =
+    pkgs.runCommand
+    "packages-cleaner"
+    {}
+    ''
+        mkdir $out
+        echo '[' >> $out/clean.json
+          awk '{
+          if (NF) {
+              gsub(/^[[:blank:]]*/,"")
+              gsub(/[[:blank:]]*$/,"")
+              if ( !/^#/ || !/^\/\// ) {
+                  if ( /.*#/ && !/#!/ ) {
+                      gsub(/#.*/,"")
+                      gsub(/[[:blank:]]*$/,"")
+                      if (NF) {
+                          print "pkgs.%s" $0
+                      }
+                  } else {
+                  print "pkgs.%s" $0
+              }
+          }
+
+      }
+      }' "./packages.conf" >> $out/clean.json
+    echo ']' >> $out/clean.json
+
+
+    '';
+
+  packagesList = builtins.fromJSON "${output}/clean.json"; # TODO could work
+in {
   environment.systemPackages = with pkgs; [
-    (builtins.readFile ./packages.conf) # TODO could work
+    packagesList
   ];
 }
 # QEMU