My NixOS config Part 3: Flake-Parts Crusaders nix.ladas552.me
hjem nix nixos impermanence flake-parts nvfetcher niri noctalia
at master 27 lines 652 B view raw
1{ lib }: 2let 3 inherit (lib) hasSuffix hasPrefix; 4 inherit (builtins) 5 concatMap 6 isPath 7 filter 8 readFileType 9 ; 10 11 expandIfFolder = 12 elem: 13 if !isPath elem || readFileType elem != "directory" then 14 [ elem ] 15 else 16 lib.filesystem.listFilesRecursive elem; 17in 18list: 19filter 20 # Filter out any path that doesn't look like `*.nix`. Don't forget to use 21 # toString to prevent copying paths to the store unnecessarily 22 ( 23 elem: 24 !isPath elem || (hasSuffix ".nix" (toString elem) && !hasPrefix "_" (baseNameOf (toString elem))) 25 ) 26 # Expand any folder to all the files within it. 27 (concatMap expandIfFolder list)