Files
nixos/Droidnix/generated/modules/traveldroid/apps/packages.nix
T
2026-03-23 21:23:50 +00:00

56 lines
1.7 KiB
Nix

{ lib, config, pkgs, flakeRoot, ... }:
let
#################################
# Read package list from config file
#################################
packagesConfPath = "${flakeRoot}/assets/traveldroid/conf/packages.conf";
raw = builtins.readFile packagesConfPath;
rawLines = lib.splitString "\n" raw;
# Guard against splitting into characters accidentally
_guard = assert !(builtins.stringLength raw > 1 && builtins.length rawLines == builtins.stringLength raw); true;
# Clean each line: remove CRs, comments, trim whitespace
cleanLine = line:
let
noCR = lib.replaceStrings [ "\r" ] [ "" ] line;
noInlineComment = lib.head (lib.splitString "#" noCR);
in
lib.strings.trim noInlineComment;
# Filter out empty lines
entries = builtins.filter (l: l != "") (map cleanLine rawLines);
# Resolve attribute paths in 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 : ${packagesConfPath}
Hint : check the attribute name on search.nixos.org/packages
'')
else
found;
# Final system-wide package list
packages = builtins.seq _guard (map resolvePkg entries);
in {
#################################
# Allow unfree packages globally
#################################
nixpkgs.config = { allowUnfree = true; };
#################################
# System packages
#################################
environment.systemPackages = packages;
}