From 6a0c115432e478901545048a22c4d1761baee08c Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Thu, 14 Jul 2022 08:17:02 +0800 Subject: [PATCH] default.nix: support for traditional channels Though, it's limited compared to flakes. I supposed that's better than nothing. --- README.adoc | 1 + default.nix | 11 +++++++++++ flake.nix | 14 ++------------ lib/private.nix | 11 +++++++++++ 4 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 default.nix diff --git a/README.adoc b/README.adoc index bd7dc859..6bc068ee 100644 --- a/README.adoc +++ b/README.adoc @@ -113,6 +113,7 @@ nixos-config ├── shells/ ├── templates/ ├── users/ +├── default.nix ├── flake.lock ├── flake.nix └── README.adoc diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..eea5e362 --- /dev/null +++ b/default.nix @@ -0,0 +1,11 @@ +{ pkgs ? import { } }: + +let + lib' = pkgs.lib.extend (final: prev: + import ./lib { lib = prev; } // import ./lib/private.nix { lib = final; }); +in { + lib = import ./lib { lib = pkgs.lib; }; + modules = lib'.importModules (lib'.filesToAttr ./modules/nixos); + overlays.foo-dogsquared-pkgs = final: prev: import ./pkgs { pkgs = prev; }; + hmModules = lib'.importModules (lib'.filesToAttr ./modules/home-manager); +} // (import ./pkgs { inherit pkgs; }) diff --git a/flake.nix b/flake.nix index 6584d576..2a50ad4a 100644 --- a/flake.nix +++ b/flake.nix @@ -232,16 +232,6 @@ }; }; - # 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. @@ -260,7 +250,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 = importModules (lib'.filesToAttr ./modules/nixos); + nixosModules = lib'.importModules (lib'.filesToAttr ./modules/nixos); # I can now install home-manager users in non-NixOS systems. # NICE! @@ -278,7 +268,7 @@ (lib'.filesToAttr ./users/home-manager); # Extending home-manager with my custom modules, if anyone cares. - homeManagerModules = importModules (lib'.filesToAttr ./modules/home-manager); + homeManagerModules = lib'.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. diff --git a/lib/private.nix b/lib/private.nix index ad2cbdb6..24a40958 100644 --- a/lib/private.nix +++ b/lib/private.nix @@ -35,4 +35,15 @@ rec { getUser = type: user: lib.getAttr user (getUsers type [ user ]); + + # Import modules with a set blocklist. + importModules = let + 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" + ]; + in attrs: + lib.filterAttrs (n: v: !lib.elem n blocklist) (lib.mapAttrsRecursive (_: path: import path) attrs); }