mirror of
https://github.com/mjallen18/snowfall-lib.git
synced 2026-04-18 09:05:58 -05:00
refactor: use pipe for clearer data transformations in overlay and home
Replace multiple intermediate let bindings with pipe for clearer data flow in default-overlay creation and split-user-and-host function. Changes: - overlay/default.nix: Added pipe and flatten to imports - overlay/default.nix: Refactored default-overlay using pipe (5 bindings → 1 pipeline) - home/default.nix: Added pipe to imports - home/default.nix: Refactored split-user-and-host using pipe Impact: - Lines: +8 -14 (net: -6) - Eliminated 6 intermediate bindings total - Clearer data transformation flow - More maintainable code Testing: nix flake check ✓
This commit is contained in:
@@ -26,6 +26,7 @@ let
|
||||
types
|
||||
hasInfix
|
||||
hasSuffix
|
||||
pipe
|
||||
;
|
||||
|
||||
user-homes-root = snowfall-lib.fs.get-snowfall-file "homes";
|
||||
@@ -64,9 +65,10 @@ in
|
||||
split-user-and-host =
|
||||
target:
|
||||
let
|
||||
raw-name-parts = builtins.split "@" target;
|
||||
name-parts = builtins.filter builtins.isString raw-name-parts;
|
||||
|
||||
name-parts = pipe target [
|
||||
(builtins.split "@")
|
||||
(builtins.filter builtins.isString)
|
||||
];
|
||||
user = builtins.elemAt name-parts 0;
|
||||
host = if builtins.length name-parts > 1 then builtins.elemAt name-parts 1 else "";
|
||||
in
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
snowfall-config,
|
||||
}:
|
||||
let
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg foldl concatStringsSep;
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg foldl concatStringsSep pipe flatten;
|
||||
|
||||
user-overlays-root = snowfall-lib.fs.get-snowfall-file "overlays";
|
||||
user-packages-root = snowfall-lib.fs.get-snowfall-file "packages";
|
||||
@@ -191,18 +191,12 @@ in
|
||||
|
||||
default-overlay =
|
||||
final: prev:
|
||||
let
|
||||
overlays-list = builtins.attrValues overlays;
|
||||
package-overlays-list = builtins.attrValues package-overlays;
|
||||
|
||||
overlays-results = builtins.map (overlay: overlay final prev) overlays-list;
|
||||
package-overlays-results = builtins.map (overlay: overlay final prev) package-overlays-list;
|
||||
|
||||
merged-results = snowfall-lib.attrs.merge-shallow-packages (
|
||||
package-overlays-results ++ overlays-results
|
||||
);
|
||||
in
|
||||
merged-results;
|
||||
pipe [ package-overlays overlays ] [
|
||||
(builtins.map builtins.attrValues)
|
||||
flatten
|
||||
(builtins.map (overlay: overlay final prev))
|
||||
snowfall-lib.attrs.merge-shallow-packages
|
||||
];
|
||||
in
|
||||
package-overlays // overlays // { default = default-overlay; } // extra-overlays;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user