I’m using modules for my NixOS configuration files, and I created a folder for all my services where I have a .nix for each service defined. I’m trying to import these files in my NixOS configuration like this:
imports =
[
"./services/*.nix"
];
But I realize that this is not technically a path. Would it be possible to write some Nix code to add the paths matching the wildcard to the path set?
There is also lib.fileset which IIRC already allows returning lists (right @infinisil?). You can’t use wildcards there but it’s possible to define filters in the Nix language (which is more verbose but I find it easier to reason about since it’s not trying to mash multiple languages into each other).
I don’t think lib.fileset would work well here, because there’s no way to only filter files in a directory without recursing. You can only do ./services/**/*.nix using