40 lines
1.2 KiB
Nix
40 lines
1.2 KiB
Nix
{ config, lib, pkgs, flakeRoot, inputs, ... }:
|
|
let
|
|
packagesConfPath = "${flakeRoot}/assets/system/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);
|
|
in
|
|
{
|
|
environment.systemPackages = packages;
|
|
}
|