New structure since I kept struggling with the home-manager implemnentation
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
{ 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;
|
||||
}
|
||||
Reference in New Issue
Block a user