49 lines
1.4 KiB
Nix
49 lines
1.4 KiB
Nix
{ config, lib, pkgs, flakeRoot, ... }:
|
|
# Allowing non-free oftware
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
let
|
|
packagesConfPath = "${flakeRoot}/assets/system/apps/packages.conf";
|
|
raw = builtins.readFile packagesConfPath;
|
|
|
|
# Split lines safely, keep guard against splitting into characters
|
|
rawLines = lib.splitString "\n" raw;
|
|
_guard =
|
|
assert !(builtins.stringLength raw > 1 && builtins.length rawLines == builtins.stringLength raw);
|
|
true;
|
|
|
|
# Clean each line: remove CRs, remove comments, trim
|
|
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 path 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
|
|
{
|
|
environment.systemPackages = packages;
|
|
}
|