From a20af360021387a1e136d6720b8c1faf8ef35688 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 13 Jul 2022 19:15:23 +0800 Subject: [PATCH] flake.nix: add blocklist for exported modules Even though this will most likely extend under `tasks` attribute. Not to mention, it is useless outside of my own setup anyways. Better be accommodating than not, I guess. --- flake.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index db975aad..b2e89f42 100644 --- a/flake.nix +++ b/flake.nix @@ -233,6 +233,17 @@ manpages.enable = true; }; }; + + # A list of module namespaces that will not be imported into the output. + # It could be blocked for whatever reason or as indicated. + blocklist = [ + # The modules under this attribute are often incomplete and needing + # very specific requirements that is 99% going to be absent from the + # outside so we're not going to export it. + "tasks" + ]; + importModules = attrs: + lib'.filterAttrs (n: v: !lib'.elem n blocklist) (lib'.mapAttrsRecursive (_: path: import path) attrs); in { # Exposes only my library with the custom functions to make it easier to # include in other flakes for whatever reason may be. @@ -251,8 +262,7 @@ # We're going to make our custom modules available for our flake. Whether # or not this is a good thing is debatable, I just want to test it. - nixosModules = lib'.mapAttrsRecursive (_: path: import path) - (lib'.filesToAttr ./modules/nixos); + nixosModules = importModules (lib'.filesToAttr ./modules/nixos); # I can now install home-manager users in non-NixOS systems. # NICE! @@ -270,8 +280,7 @@ (lib'.filesToAttr ./users/home-manager); # Extending home-manager with my custom modules, if anyone cares. - homeManagerModules = lib'.mapAttrsRecursive (_: path: import path) - (lib'.filesToAttr ./modules/home-manager); + homeManagerModules = importModules (lib'.filesToAttr ./modules/home-manager); # My custom packages, available in here as well. Though, I mainly support # "x86_64-linux". I just want to try out supporting other systems.