diff --git a/flake.nix b/flake.nix index 039e533..ca4c6f7 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = inputs @ {flake-parts, ...}: + outputs = inputs @ {flake-parts, self, ...}: flake-parts.lib.mkFlake {inherit inputs;} { systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"]; perSystem = {pkgs, ...}: { @@ -17,19 +17,20 @@ flake = let inherit (inputs.nixpkgs) lib; - evalSchemeData = x: - (lib.mapAttrs' ( - n: v: - lib.optionalAttrs (v == "regular" && lib.hasSuffix ".json" n) { - name = lib.removeSuffix ".json" n; - value = x + n; - } - )) - (builtins.readDir x); + evalSchemeData = lib.flip lib.pipe [ + builtins.unsafeDiscardStringContext + lib.filesystem.listFilesRecursive + (builtins.filter (lib.hasSuffix ".json")) + (map (n: { + name = lib.removePrefix ((dirOf n) + "/") (lib.removeSuffix ".json" n); + value = lib.importJSON n; + })) + lib.listToAttrs + ]; in { schemeData = { - base16 = evalSchemeData ./json/base16; - base24 = evalSchemeData ./json/base24; + base16 = evalSchemeData "${self}/json/base16"; + base24 = evalSchemeData "${self}/json/base24"; }; }; };