···142 inputs:
143 let
144 # Function to stop using `import-tree` by Vic.
145- # Just to lighten the config a bit, written by https://codeberg.org/BANanaD3V
146- # Adaptation stolen from @iynai
147- inherit (inputs.nixpkgs.lib.fileset) toList fileFilter;
148- import-tree =
149- paths:
150- toList (
151- fileFilter (file: file.hasExt "nix" && !(inputs.nixpkgs.lib.hasPrefix "_" file.name)) paths
152- );
153154 # a way to fetch nix files via nvfetcher and import them in the config
155 # basically parse the json crated by nvfetcher, and use fetchTarball
···174 specialArgs = { inherit modules; };
175 }
176 {
177- imports = import-tree ./modules;
178 flake.templates = import ./templates;
179 };
180}
···142 inputs:
143 let
144 # Function to stop using `import-tree` by Vic.
145+ # Just to lighten the config a bit, written by @llakala https://github.com/llakala/synaptic-standard/blob/main/demo/recursivelyImport.nix
146+ import-tree = import ./stuff/recursivelyImport.nix { lib = inputs.nixpkgs.lib; };
000000147148 # a way to fetch nix files via nvfetcher and import them in the config
149 # basically parse the json crated by nvfetcher, and use fetchTarball
···168 specialArgs = { inherit modules; };
169 }
170 {
171+ imports = import-tree [ ./modules ];
172 flake.templates = import ./templates;
173 };
174}
install/impermanence.norg
stuff/impermanence.norg
install/zfs.norg
stuff/zfs.norg
+27
stuff/recursivelyImport.nix
···000000000000000000000000000
···1+{ lib }:
2+let
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;
17+in
18+list:
19+filter
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)