diff --git a/Droidnix/README.org b/Droidnix/README.org index 99f684018..2e90a16b6 100644 --- a/Droidnix/README.org +++ b/Droidnix/README.org @@ -768,12 +768,13 @@ This is top file of this level which contains just an import statement for all r ** =generated/modules/apps/packages.nix= This will import all packages listed in ./assets/system/apps/packages.conf #+BEGIN_SRC nix :tangle generated/modules/apps/packages.nix :noweb tangle :mkdirp yes :eval never-html -{ config, lib, pkgs, ... }: +{ lib, ... }: let - # Gebruik relatieve pad binnen module - packagesConfPath = ../../../assets/system/apps/packages.conf; + # --- Path naar je packages.conf, relatief aan dit bestand --- + packagesConfPath = ./assets/system/apps/packages.conf; + # --- Lees en split --- raw = builtins.readFile packagesConfPath; rawLines = lib.splitString "\n" raw; @@ -789,29 +790,35 @@ let entries = builtins.filter (l: l != "") (map cleanLine rawLines); - resolvePkg = name: - let - parts = lib.splitString "." name; - found = lib.attrByPath parts null pkgs; - in - if found == null then - throw '' - packages.nix: package not found in pkgs - Token : ${builtins.toJSON name} - packages.conf : ${toString packagesConfPath} - Hint : check the attribute name on search.nixos.org/packages - '' - else - found; - - packages = builtins.seq _guard (map resolvePkg entries); - in { - options.mySystem.system.packages.enable = lib.mkEnableOption "Enable packages from packages.conf"; + # --- Flake NixOS module export --- + flake.nixosModules.packages = { config, pkgs, lib, ... }: - config = lib.mkIf (config.mySystem.system.packages.enable or false) { - environment.systemPackages = packages; + let + # Resolve packages via pkgs + resolvePkg = name: + let + parts = lib.splitString "." name; + found = lib.attrByPath parts null pkgs; + in + if found == null then + throw '' + packages.nix: package not found in pkgs + Token : ${builtins.toJSON name} + packages.conf : ${toString packagesConfPath} + '' + else + found; + + packages = builtins.seq _guard (map resolvePkg entries); + in + { + options.mySystem.system.packages.enable = lib.mkEnableOption "Enable packages from packages.conf"; + + config = lib.mkIf (config.mySystem.system.packages.enable or false) { + environment.systemPackages = packages; + }; }; } #+END_SRC diff --git a/Droidnix/generated/modules/apps/packages.nix b/Droidnix/generated/modules/apps/packages.nix index ec62c282f..0f893650e 100644 --- a/Droidnix/generated/modules/apps/packages.nix +++ b/Droidnix/generated/modules/apps/packages.nix @@ -1,9 +1,10 @@ -{ config, lib, pkgs, ... }: +{ lib, ... }: let - # Gebruik relatieve pad binnen module - packagesConfPath = ../../../assets/system/apps/packages.conf; + # --- Path naar je packages.conf, relatief aan dit bestand --- + packagesConfPath = ./assets/system/apps/packages.conf; + # --- Lees en split --- raw = builtins.readFile packagesConfPath; rawLines = lib.splitString "\n" raw; @@ -19,28 +20,34 @@ let entries = builtins.filter (l: l != "") (map cleanLine rawLines); - resolvePkg = name: - let - parts = lib.splitString "." name; - found = lib.attrByPath parts null pkgs; - in - if found == null then - throw '' - packages.nix: package not found in pkgs - Token : ${builtins.toJSON name} - packages.conf : ${toString packagesConfPath} - Hint : check the attribute name on search.nixos.org/packages - '' - else - found; - - packages = builtins.seq _guard (map resolvePkg entries); - in { - options.mySystem.system.packages.enable = lib.mkEnableOption "Enable packages from packages.conf"; + # --- Flake NixOS module export --- + flake.nixosModules.packages = { config, pkgs, lib, ... }: - config = lib.mkIf (config.mySystem.system.packages.enable or false) { - environment.systemPackages = packages; + let + # Resolve packages via pkgs + resolvePkg = name: + let + parts = lib.splitString "." name; + found = lib.attrByPath parts null pkgs; + in + if found == null then + throw '' + packages.nix: package not found in pkgs + Token : ${builtins.toJSON name} + packages.conf : ${toString packagesConfPath} + '' + else + found; + + packages = builtins.seq _guard (map resolvePkg entries); + in + { + options.mySystem.system.packages.enable = lib.mkEnableOption "Enable packages from packages.conf"; + + config = lib.mkIf (config.mySystem.system.packages.enable or false) { + environment.systemPackages = packages; + }; }; }