Files
nixos/Droidnix/generated/system/applications/packages.nix
T
2026-03-09 19:24:55 +01:00

47 lines
1.4 KiB
Nix

{
config,
lib,
pkgs,
flakeRoot,
inputs,
...
}:
let
packagesConfPath = "${builtins.toString flakeRoot.outPath}/assets/common/apps/packages.conf";
raw = builtins.readFile packagesConfPath;
# IMPORTANT: explicit "\n" so we never accidentally split into characters
rawLines = lib.splitString "\n" raw;
# Guard: if we accidentally split into characters, rawLines length ~= stringLength raw
_guard =
assert !(builtins.stringLength raw > 1 && builtins.length rawLines == builtins.stringLength raw);
true;
cleanLine =
l:
let
noCR = lib.replaceStrings [ "\r" ] [ "" ] l;
noInlineComment = lib.head (lib.splitString "#" noCR);
in
lib.strings.trim noInlineComment;
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);
zenBrowser = inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.default;
in
{
environment.systemPackages = packages ++ [ zenBrowser ];
}