Working on reshuffling
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
# --- 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;
|
||||
|
||||
_guard = assert !(builtins.stringLength raw > 1 &&
|
||||
builtins.length rawLines == builtins.stringLength raw); true;
|
||||
|
||||
cleanLine = line:
|
||||
let
|
||||
noCR = lib.replaceStrings [ "\r" ] [ "" ] line;
|
||||
noComment = lib.head (lib.splitString "#" noCR);
|
||||
in
|
||||
lib.strings.trim noComment;
|
||||
|
||||
entries = builtins.filter (l: l != "") (map cleanLine rawLines);
|
||||
|
||||
in
|
||||
{
|
||||
# --- Flake NixOS module export ---
|
||||
flake.nixosModules.packages = { config, pkgs, lib, ... }:
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user