Nix Flakes configuration for MacOS, NixOS and WSL
1# This files import all modules inside this folder and the subfolders but
2# ignore all files and directories starting with a `_`.
3{ lib, ... }:
4let
5 importDir = dir:
6 let
7 entries = builtins.readDir dir;
8 nixFiles = lib.filterAttrs (name: type:
9 type == "regular" &&
10 lib.hasSuffix ".nix" name &&
11 name != "default.nix" &&
12 !(lib.hasPrefix "_" name)
13 ) entries;
14 subdirs = lib.filterAttrs (name: type:
15 type == "directory" &&
16 !(lib.hasPrefix "_" name)
17 ) entries;
18 in
19 (map (name: dir + "/${name}") (lib.attrNames nixFiles))
20 ++ (lib.concatMap (name: importDir (dir + "/${name}")) (lib.attrNames subdirs));
21in
22{
23 imports = importDir ./.;
24}