From 903e38d999c942ebceb3fd554381c49059dd792f Mon Sep 17 00:00:00 2001 From: anntnzrb Date: Wed, 8 Oct 2025 23:39:54 -0500 Subject: [PATCH] feat: add path.get-directory-name helper for consistent directory name extraction --- snowfall-lib/path/default.nix | 13 +++++++++++++ snowfall-lib/template/default.nix | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/snowfall-lib/path/default.nix b/snowfall-lib/path/default.nix index bd39e1f..894b5b2 100644 --- a/snowfall-lib/path/default.nix +++ b/snowfall-lib/path/default.nix @@ -133,5 +133,18 @@ in #@ Path -> String get-output-name = path: builtins.unsafeDiscardStringContext (get-parent-directory path); + + ## Get the directory name for flake outputs. + ## Example Usage: + ## ```nix + ## get-directory-name /templates/foo + ## ``` + ## Result: + ## ```nix + ## "foo" + ## ``` + #@ Path -> String + get-directory-name = path: + builtins.unsafeDiscardStringContext (baseNameOf path); }; } diff --git a/snowfall-lib/template/default.nix b/snowfall-lib/template/default.nix index ad3f828..0ad43e3 100644 --- a/snowfall-lib/template/default.nix +++ b/snowfall-lib/template/default.nix @@ -41,7 +41,7 @@ in description = flake-attrs.description or null; in { - name = builtins.unsafeDiscardStringContext (baseNameOf template); + name = snowfall-lib.path.get-directory-name template; path = template; } // (if description != null then { inherit description; } else { });