Skip to content

Commit

Permalink
Merge pull request #105 from snowfallorg/dev
Browse files Browse the repository at this point in the history
fix: revert fs path type usage
  • Loading branch information
jakehamilton authored Jun 11, 2024
2 parents c7edfb1 + 5a10d2e commit aa19b02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
12 changes: 6 additions & 6 deletions snowfall-lib/fs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ in {
## ```nix
## "/user-source/systems"
## ```
#@ String -> Path
get-file = path: user-inputs.src + "/${path}";
#@ String -> String
get-file = path: "${user-inputs.src}/${path}";

## Get a file path relative to the user's snowfall directory.
## Example Usage:
Expand All @@ -47,8 +47,8 @@ in {
## ```nix
## "/user-source/snowfall-dir/systems"
## ```
#@ String -> Path
get-snowfall-file = path: snowfall-config.root + "/${path}";
#@ String -> String
get-snowfall-file = path: "${snowfall-config.root}/${path}";

## Get a file path relative to the this flake.
## Example Usage:
Expand All @@ -59,8 +59,8 @@ in {
## ```nix
## "/user-source/systems"
## ```
#@ String -> Path
internal-get-file = path: core-inputs.src + "/${path}";
#@ String -> String
internal-get-file = path: "${core-inputs.src}/${path}";

## Safely read from a directory if it exists.
## Example Usage:
Expand Down
12 changes: 1 addition & 11 deletions snowfall-lib/module/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,7 @@ in {
user-modules = snowfall-lib.fs.get-default-nix-files-recursive src;
create-module-metadata = module: {
name = let
raw-path = 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;
path-name = builtins.replaceStrings [(builtins.toString src) "/default.nix"] ["" ""] (builtins.unsafeDiscardStringContext module);
in
if hasPrefix "/" path-name
then builtins.substring 1 ((builtins.stringLength path-name) - 1) path-name
Expand Down

0 comments on commit aa19b02

Please sign in to comment.