add package helper

This commit is contained in:
Daylin Morgan 2025-01-06 16:46:07 -06:00
parent e495c7d8bb
commit a5e0fea1ea
Signed by: daylin
GPG key ID: 950D13E9719334AD
4 changed files with 44 additions and 23 deletions

View file

@ -1,22 +0,0 @@
{ pkgs, flake, ... }:
{
environment.systemPackages =
[
(flake.pkg "utils")
(flake.pkg "ghostty")
]
++ (with pkgs; [
sops
attic-client
distrobox
# cachix
zk
graphviz
charm-freeze
quarto
calibre
]);
}

View file

@ -0,0 +1,10 @@
flake:utils
flake:ghostty
sops
attic-client
distrobox
zk
graphviz
charm-freeze
quarto
calibre

View file

@ -21,6 +21,7 @@ let
types types
hasPrefix hasPrefix
splitString splitString
removePrefix
trim trim
; ;
inherit (final.filesystem) listFilesRecursive; inherit (final.filesystem) listFilesRecursive;
@ -147,6 +148,35 @@ let
// (tryreadEnabledAttrsOrEmpty "${p}/settings/modules") // (tryreadEnabledAttrsOrEmpty "${p}/settings/modules")
); );
# convert the following:
# ```txt
# flake:utils
# sops
# graphviz
# ```
# to
# ```nix
# [
# (flake.pkg "utils")
# pkgs.sops
# pkgs.graphviz
# ]
# ```
tryPkgsFromFile =
{
hostName,
pkgs,
flake ? flakeFromSystem "x86_64-linux",
}:
hostName
|> pathFromHostName
|> (p: "${p}/settings/pkgs")
|> tryReadLinesNoComment
|> map (
line:
if hasPrefix "flake:" line then (line |> removePrefix "flake:" |> flake.pkgs) else pkgs.${line}
);
in in
{ {
inherit inherit
@ -169,5 +199,6 @@ in
loadOverlays loadOverlays
hostFiles hostFiles
oizysSettings oizysSettings
tryPkgsFromFile
; ;
} }

View file

@ -3,10 +3,11 @@
lib, lib,
self, self,
hostName, hostName,
pkgs,
... ...
}: }:
let let
inherit (lib) mkEnableOption mkOption loadOverlays oizysSettings; inherit (lib) mkEnableOption mkOption loadOverlays oizysSettings tryPkgsFromFile;
in in
{ {
imports = with self.nixosModules; [ imports = with self.nixosModules; [
@ -61,5 +62,6 @@ in
time.timeZone = "US/Central"; time.timeZone = "US/Central";
nixpkgs.overlays = import ../overlays { inherit inputs loadOverlays; }; nixpkgs.overlays = import ../overlays { inherit inputs loadOverlays; };
oizys = oizysSettings hostName; oizys = oizysSettings hostName;
environment.systemPackages = tryPkgsFromFile {inherit hostName pkgs;};
}; };
} }