47 lines
1.3 KiB
Nix
47 lines
1.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
# Gebruik relatieve pad binnen module
|
|
packagesConfPath = ../../../assets/system/apps/packages.conf;
|
|
|
|
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);
|
|
|
|
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";
|
|
|
|
config = lib.mkIf (config.mySystem.system.packages.enable or false) {
|
|
environment.systemPackages = packages;
|
|
};
|
|
}
|