42 lines
1.2 KiB
Nix
42 lines
1.2 KiB
Nix
{ lib, pkgs, ... }:
|
|
|
|
let
|
|
# Adjust this path if you place apps.nix elsewhere in the repo.
|
|
# Best practice: keep it relative to the flake repo so flakes can read it.
|
|
packagesConfPath = ../assets/conf/apps/packages.conf;
|
|
|
|
raw = builtins.readFile packagesConfPath;
|
|
|
|
# Split into lines, trim whitespace, drop empty lines and comment lines.
|
|
lines =
|
|
let
|
|
all = lib.splitString "\n" raw;
|
|
trimmed = map lib.strings.trim all;
|
|
in
|
|
builtins.filter (l: l != "" && !(lib.hasPrefix "#" l)) trimmed;
|
|
|
|
# Resolve a name like:
|
|
# "wget" -> pkgs.wget
|
|
# "kdePackages.okular" -> pkgs.kdePackages.okular
|
|
# "_1password-gui" -> pkgs."_1password-gui"
|
|
resolvePkg = name:
|
|
let
|
|
parts = lib.splitString "." name;
|
|
found = lib.attrByPath parts null pkgs;
|
|
in
|
|
if found == null then
|
|
throw ''
|
|
apps.nix: Package "${name}" from ${toString packagesConfPath} not found in pkgs.
|
|
Only packages available on https://search.nixos.org/packages can be installed.
|
|
Fix the name (or attribute path) and rebuild.
|
|
''
|
|
else
|
|
found;
|
|
|
|
packages = map resolvePkg lines;
|
|
|
|
in
|
|
{
|
|
environment.systemPackages = packages;
|
|
}
|