fix: revert fs path type usage

This commit is contained in:
Jake Hamilton 2024-06-05 15:13:19 -07:00
parent 5d6e9f2357
commit 5a10d2e37b
No known key found for this signature in database
GPG key ID: 9762169A1B35EA68
2 changed files with 7 additions and 17 deletions

View file

@ -35,8 +35,8 @@ in {
## ```nix ## ```nix
## "/user-source/systems" ## "/user-source/systems"
## ``` ## ```
#@ String -> Path #@ String -> String
get-file = path: user-inputs.src + "/${path}"; get-file = path: "${user-inputs.src}/${path}";
## Get a file path relative to the user's snowfall directory. ## Get a file path relative to the user's snowfall directory.
## Example Usage: ## Example Usage:
@ -47,8 +47,8 @@ in {
## ```nix ## ```nix
## "/user-source/snowfall-dir/systems" ## "/user-source/snowfall-dir/systems"
## ``` ## ```
#@ String -> Path #@ String -> String
get-snowfall-file = path: snowfall-config.root + "/${path}"; get-snowfall-file = path: "${snowfall-config.root}/${path}";
## Get a file path relative to the this flake. ## Get a file path relative to the this flake.
## Example Usage: ## Example Usage:
@ -59,8 +59,8 @@ in {
## ```nix ## ```nix
## "/user-source/systems" ## "/user-source/systems"
## ``` ## ```
#@ String -> Path #@ String -> String
internal-get-file = path: core-inputs.src + "/${path}"; internal-get-file = path: "${core-inputs.src}/${path}";
## Safely read from a directory if it exists. ## Safely read from a directory if it exists.
## Example Usage: ## Example Usage:

View file

@ -28,17 +28,7 @@ in {
user-modules = snowfall-lib.fs.get-default-nix-files-recursive src; user-modules = snowfall-lib.fs.get-default-nix-files-recursive src;
create-module-metadata = module: { create-module-metadata = module: {
name = let name = let
raw-path = builtins.replaceStrings [(builtins.toString src) "/default.nix"] ["" ""] (builtins.unsafeDiscardStringContext module); path-name = builtins.replaceStrings [(builtins.toString src) "/default.nix"] ["" ""] (builtins.unsafeDiscardStringContext module);
# We want to remove the nix store prefix from the entry.
raw-path-parts = builtins.split "/nix/store/[a-zA-Z0-9]{32}-[^/]*/" raw-path;
path-name-parts = builtins.filter builtins.isString raw-path-parts;
normalized-name-parts =
# We don't include the name of the source directory.
if builtins.length path-name-parts > 1
then tail path-name-parts
else path-name-parts;
path-name = builtins.concatStringsSep "/" normalized-name-parts;
in in
if hasPrefix "/" path-name if hasPrefix "/" path-name
then builtins.substring 1 ((builtins.stringLength path-name) - 1) path-name then builtins.substring 1 ((builtins.stringLength path-name) - 1) path-name