From b3532173c2f04ab3b93a01f88d3f7fef9828e8e1 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Sun, 4 Feb 2024 22:07:22 +0300 Subject: [PATCH] Import better, ignore files starting with _ --- flake.nix | 46 +++++++++++++++++++---------- modules/{python.nix => _python.nix} | 0 2 files changed, 31 insertions(+), 15 deletions(-) rename modules/{python.nix => _python.nix} (100%) diff --git a/flake.nix b/flake.nix index 6070f5b..51a085e 100644 --- a/flake.nix +++ b/flake.nix @@ -2,19 +2,21 @@ description = "All my NixOS configurations."; nixConfig = { - extra-substituters = '' - https://nix-community.cachix.org/ - https://hyprland.cachix.org/ - https://cache.privatevoid.net/ - https://cache.garnix.io/ - ''; + extra-substituters = [ + "https://nix-community.cachix.org/" + "https://ghostty.cachix.org/" + "https://hyprland.cachix.org/" + "https://cache.privatevoid.net/" + "https://cache.garnix.io/" + ]; - extra-trusted-public-keys = '' - nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= - hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc= - cache.privatevoid.net-1:SErQ8bvNWANeAvtsOESUwVYr2VJynfuc9JRwlzTTkVg= - cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= - ''; + extra-trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "ghostty.cachix.org-1:QB389yTa6gTyneehvqG58y0WnHjQOqgnA+wBnpWWxns=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "cache.privatevoid.net-1:SErQ8bvNWANeAvtsOESUwVYr2VJynfuc9JRwlzTTkVg=" + "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" + ]; }; inputs = { @@ -169,7 +171,21 @@ inherit system; specialArgs = { inherit inputs ulib upkgs keys theme; }; - modules = [ + + modules = let + mapDirectory = function: directory: with builtins; + attrValues (mapAttrs function (readDir directory)); + + nullIfUnderscore = name: if (builtins.substring 0 1 name) == "_" then + null + else + name; + + filterNull = builtins.filter (x: x != null); + + importDirectory = directory: + filterNull (mapDirectory (name: _: lib.mapNullable (name: /${directory}/${name}) (nullIfUnderscore name)) directory); + in [ homeManager.nixosModules.default agenix.nixosModules.default @@ -179,8 +195,8 @@ site.nixosModules.default defaultConfiguration - ] ++ (builtins.attrValues (builtins.mapAttrs (name: _: ./modules/${name}) (builtins.readDir ./modules))) - ++ (builtins.attrValues (builtins.mapAttrs (name: _: ./hosts/${host}/${name}) (builtins.readDir ./hosts/${host}))); + ] ++ (importDirectory ./hosts/${host}) + ++ (importDirectory ./modules); }; hosts = (builtins.attrNames (builtins.readDir ./hosts)); diff --git a/modules/python.nix b/modules/_python.nix similarity index 100% rename from modules/python.nix rename to modules/_python.nix