diff --git a/flake.nix b/flake.nix index 92fbad1..adaf647 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ outputs = inputs @ { self, nixpkgs, nix-minecraft, flux, ... }: let - inherit (lib.my) mapModulesRec mapHosts; + inherit (lib.my) readNixosModules mapHosts; system = "x86_64-linux"; @@ -81,7 +81,7 @@ packages."${system}" = lib.my.mapModules ./packages (p: pkgs.callPackage p { inherit inputs; }); - nixosModules = mapModulesRec ./modules import; + nixosModules = readNixosModules ./modules import; nixosConfigurations = mapHosts ./hosts {}; }; } diff --git a/lib/modules.nix b/lib/modules.nix index 8240c6a..9568bb3 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -1,9 +1,10 @@ { lib, self, ... }: let - inherit (builtins) attrValues readDir pathExists concatLists; + inherit (builtins) attrValues readDir pathExists concatLists replaceStrings listToAttrs; inherit (lib.attrsets) mapAttrsToList filterAttrs nameValuePair; - inherit (lib.strings) hasPrefix hasSuffix removeSuffix; + inherit (lib.strings) hasPrefix hasSuffix removeSuffix removePrefix; inherit (lib.trivial) id; + inherit (lib) flatten; inherit (self.attrs) mapFilterAttrs; in rec { @@ -33,4 +34,14 @@ in rec paths = files ++ concatLists (map (d: mapModulesRec' d id) dirs); in map fn paths; + + readNixosModules = dir: fn: filterAttrs (name: value: value != null && !(hasPrefix "_" name)) (listToAttrs (flatten (readDirRecursive fn dir ""))); + + readDirRecursive = fn: root: dir: mapAttrsToList (name: type: + if type == "directory" + then readDirRecursive fn root "${dir}/${name}" + else if type == "regular" && hasSuffix ".nix" name + then nameValuePair "${replaceStrings ["/"] ["_"] (removePrefix "/" dir)}_${removeSuffix ".nix" name}" (fn "${root}/${dir}/${name}") + else nameValuePair "" null + ) (readDir "${root}/${dir}"); } diff --git a/packages/studio.nix b/packages/studio.nix index 62d035f..4836175 100644 --- a/packages/studio.nix +++ b/packages/studio.nix @@ -8,7 +8,7 @@ in mkWindowsAppNoCC rec { inherit wine; pname = "studio"; - version = "2.25.4_1"; + version = "2.25.4"; src = fetchurl { url = "https://studio.download.bricklink.info/Studio2.0+EarlyAccess/Archive/2.25.4_1/Studio+2.0+EarlyAccess.exe";