From 208e54b34cf6550740dd48ec6a7a289a698b444e Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 15 Feb 2024 12:01:08 -0600 Subject: [PATCH] improve module system more --- lib/default.nix | 13 ++++++------- overlays/default.nix | 32 ++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 2a36d20..8c08ba9 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -32,15 +32,14 @@ in rec { mkSystem = hostname: nixosSystem { system = "x86_64-linux"; - modules = [ + modules = + [ ../modules/common.nix - - # ({...}: nixpkgs.overlays = [ import ../overlays {}; ]) - (_: - { nixpkgs.overlays = import ../overlays _ ++ - [inputs.pinix.overlays.default]; }) + ../overlays ] - ++ filter isNixFile (listFilesRecursive (../. + "/hosts/${hostname}")); + ++ filter + isNixFile + (listFilesRecursive (../. + "/hosts/${hostname}")); specialArgs = {inherit inputs mkRune;}; }; diff --git a/overlays/default.nix b/overlays/default.nix index 0577342..bdc833c 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,14 +1,18 @@ -# import all nix files in the current folder, -# and execute them with args as parameters -# The return value is a list of all execution results, -# which is the list of overlays -args: -# execute and import all overlay files in the current -# directory with the given args -builtins.map -# execute and import the overlay file -(f: (import (./. + "/${f}") args)) -# find all overlay files in the current directory -(builtins.filter - (f: f != "default.nix") - (builtins.attrNames (builtins.readDir ./.))) +{inputs, ...}: let + defaultOverlays = + # execute and import all overlay files in the current + # directory with the given args + builtins.map + # execute and import the overlay file + (f: (import (./. + "/${f}") {inherit inputs;})) + # find all overlay files in the current directory + (builtins.filter + (f: f != "default.nix") + (builtins.attrNames (builtins.readDir ./.))); +in { + nixpkgs.overlays = + defaultOverlays + ++ [ + inputs.pinix.overlays.default + ]; +}