From 660b1a13359cd9884a0db41f403fe4a5697126d9 Mon Sep 17 00:00:00 2001 From: Hendrik Sokolowski Date: Sat, 11 Nov 2023 01:04:57 +0100 Subject: [PATCH] load modules from dir --- modules/default.nix | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 modules/default.nix diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 00000000..3358c716 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,61 @@ +{ + self, + lib, + inputs, + ... +}: + +let + mkNixosModule = name: [{ ${name} = import ./${name}; }]; + mkBaseImport = name: [ self.nixosModules.${name} ]; + + # create a list of directory names from given folder + filterModules = dir: builtins.attrNames (lib.attrsets.filterAttrs (n: v: v == "directory") (builtins.readDir dir)); + + # create nixosModules imports from list + flakeNixosModulesList = modules: lib.attrsets.mergeAttrsList (builtins.concatMap mkNixosModule modules); + flakeNixosBaseImports = modules: lib.lists.flatten (builtins.concatMap mkBaseImport modules); +in +{ + # Configuration common to all Linux systems + flake = { + nixosModules = rec {} // + (flakeNixosModulesList (filterModules ./.)) // + { + base.imports = [ + self.nixosModules.home-manager + inputs.agenix.nixosModules.default + inputs.musnix.nixosModules.musnix + + ({ + flake, + pkgs, + lib, + unstable, + master, + ... + }: { + nixpkgs.overlays = (import ../overlays) ++ [ + (prev: next: { + scan2paperless = inputs.scan2paperless.legacyPackages.${prev.system}.scan2paperless; + nixd = inputs.unstable.legacyPackages.${prev.system}.nixd; + + factorio-headless = inputs.master.legacyPackages.${prev.system}.factorio-headless; + paperless-ngx = inputs.master.legacyPackages.${prev.system}.paperless-ngx; + waybar = inputs.master.legacyPackages.${prev.system}.waybar; + element-desktop = inputs.master.legacyPackages.${prev.system}.element-desktop; + + adlist = inputs.adblock-unbound.packages.${prev.system}; + }) + ]; + + nix.nixPath = [ + "nixpkgs=${inputs.nixpkgs}" + "nixos-config=${../lib/compat/nixos}" + "home-manager=${inputs.home-manager}" + ]; + }) + ] ++ (flakeNixosBaseImports (filterModules ./.)); + }; + }; +}