Reshuffling stuff
This commit is contained in:
@@ -1,33 +1,57 @@
|
||||
# ./modules/apps/packages.nix
|
||||
{ lib, config, flakeRoot, ... }:
|
||||
{ config, lib, pkgs, flakeRoot, inputs, ... }:
|
||||
|
||||
let
|
||||
packagesConfPath = "${flakeRoot}/assets/system/apps/packages.conf";
|
||||
# --- Path to your packages.conf ---
|
||||
packagesConfPath = "${flakeRoot}/assets/conf/apps/packages.conf";
|
||||
|
||||
# --- Read raw content ---
|
||||
raw = builtins.readFile packagesConfPath;
|
||||
|
||||
# split lines safely
|
||||
# --- Split into lines explicitly on "\n" to avoid accidental char splitting ---
|
||||
rawLines = lib.splitString "\n" raw;
|
||||
|
||||
# guard against accidental character splitting
|
||||
# --- Guard against accidental character splitting ---
|
||||
_guard = assert !(
|
||||
builtins.stringLength raw > 1 &&
|
||||
builtins.length rawLines == builtins.stringLength raw
|
||||
); true;
|
||||
|
||||
# clean a line (remove CR, inline comments, whitespace)
|
||||
# --- Clean each line: remove CR, inline comments, trim ---
|
||||
cleanLine = line:
|
||||
let
|
||||
noCR = lib.replaceStrings [ "\r" ] [ "" ] line;
|
||||
noInlineComment = lib.head (lib.splitString "#" noCR);
|
||||
noComment = lib.head (lib.splitString "#" noCR);
|
||||
in
|
||||
lib.strings.trim noInlineComment;
|
||||
lib.strings.trim noComment;
|
||||
|
||||
# --- Filter empty lines ---
|
||||
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
|
||||
};
|
||||
# --- 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 ];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user