Reshuffling stuff

This commit is contained in:
2026-03-18 18:27:00 +00:00
parent 2fcfe478a8
commit a82e8ed459
2 changed files with 52 additions and 64 deletions
+26 -32
View File
@@ -1,39 +1,33 @@
{ config, lib, pkgs, flakeRoot, inputs, ... }:
# ./modules/apps/packages.nix
{ lib, config, flakeRoot, ... }:
let
packagesConfPath = "${flakeRoot}/assets/system/apps/packages.conf";
raw = builtins.readFile packagesConfPath;
# IMPORTANT: explicit "\n" so we never accidentally split into characters
# split lines safely
rawLines = lib.splitString "\n" raw;
# Guard: if we accidentally split into characters, rawLines length ~= stringLength raw
# guard against accidental character splitting
_guard = assert !(
builtins.stringLength raw > 1 &&
builtins.length rawLines == builtins.stringLength raw
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);
in
{
environment.systemPackages = packages;
# clean a line (remove CR, inline comments, whitespace)
cleanLine = line:
let
noCR = lib.replaceStrings [ "\r" ] [ "" ] line;
noInlineComment = lib.head (lib.splitString "#" noCR);
in
lib.strings.trim noInlineComment;
entries = builtins.filter (l: l != "") (map cleanLine rawLines);
in {
# --- symbolic config only ---
mySystem.apps.packages = {
enable = true;
packageNames = entries; # just the names, no pkgs references
};
}