Files
nixos/Droidnix/generated/modules/apps/packages.nix
T
2026-03-18 18:37:07 +00:00

58 lines
1.7 KiB
Nix

{ config, lib, pkgs, flakeRoot, inputs, ... }:
let
# --- Path to your packages.conf ---
packagesConfPath = "${flakeRoot}/assets/conf/apps/packages.conf";
# --- Read raw content ---
raw = builtins.readFile packagesConfPath;
# --- Split into lines explicitly on "\n" to avoid accidental char splitting ---
rawLines = lib.splitString "\n" raw;
# --- Guard against accidental character splitting ---
_guard = assert !(
builtins.stringLength raw > 1 &&
builtins.length rawLines == builtins.stringLength raw
); true;
# --- Clean each line: remove CR, inline comments, trim ---
cleanLine = line:
let
noCR = lib.replaceStrings [ "\r" ] [ "" ] line;
noComment = lib.head (lib.splitString "#" noCR);
in
lib.strings.trim noComment;
# --- Filter empty lines ---
entries = builtins.filter (l: l != "") (map cleanLine rawLines);
# --- Resolve a package name from 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}
Hint : check the attribute name on search.nixos.org/packages
''
else
found;
# --- Map entries to actual pkgs ---
packages = builtins.seq _guard (map resolvePkg entries);
# --- Zen Browser package from inputs ---
zenBrowser =
inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.default;
in
{
# --- Add the packages to systemPackages ---
environment.systemPackages = packages ++ [ zenBrowser ];
}