Introduce get-entries-by-kind to eliminate duplication between get-directories
and get-files. Add filter-files helpers to reduce 6 similar filtering functions
into 2 reusable higher-order functions.
Changes:
- Added pipe to imports
- Added get-entries-by-kind using pipe for clearer data flow
- Refactored get-directories and get-files to use get-entries-by-kind
- Added filter-files and filter-files-recursive helpers
- Refactored all 6 file filtering functions to one-liners using helpers
Impact:
- Lines: +30 -49 (net: -19)
- Eliminated duplication in filesystem operations
- Introduced modern pipe pattern for data transformations
- Better composability with higher-order functions
Testing: nix flake check ✓
Use fp.compose for get-output-name and get-directory-name to leverage
existing composition utilities and adopt more idiomatic functional style.
Changes:
- path/default.nix: Convert to point-free using snowfall-lib.fp.compose
Impact: Improved code style, more functional approach
Testing: nix flake check ✓
Fix argument order for fold/foldr - the list element comes before the
accumulator in foldr, not after. This was causing evaluation errors
when using the library.
Add clear documentation for all uses of unsafeDiscardStringContext,
explaining that it's necessary when building flake outputs based on
file paths, as Nix doesn't allow using paths as attribute names directly.
Replace rec keyword with modern Nix patterns:
- Use explicit let...in bindings with inherit statements
- Use fix for recursive package bindings in package/default.nix
- This improves maintainability and follows idiomatic Nix patterns
Files modified:
- snowfall-lib/flake/default.nix
- snowfall-lib/fp/default.nix
- snowfall-lib/home/default.nix
- snowfall-lib/system/default.nix
- snowfall-lib/package/default.nix
Add merge-with-aliases function to attrs module and use it across checks,
modules, packages, shells, and templates to eliminate repeated alias merging
logic. Also optimize get-libs by replacing filter+map with a fold operation.
Previously when you accessed stuff on your lib via snowfall-lib's
internal system-lib (e.g. with lib.snowfall.internal.system-lib.my-namespace.my-lib-function)
the lib which is passed to *your* lib used hardcoded the "internal" name
This makes lib functions in your flake's lib break if they use other lib
functions in your flake's lib