diff --git a/flake.lock b/flake.lock index 8c8f0d3..31efe10 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1712791164, - "narHash": "sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw=", + "lastModified": 1713537308, + "narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1042fd8b148a9105f3c0aca3a6177fd1d9360ba5", + "rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index f2dd219..4512e64 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ config._module.args = { inherit inputs; inherit pkgs system; - inherit (pkgs) lib stdenv; + inherit (pkgs) lib stdenv stdenvNoCC; }; # Local user nix env diff --git a/nix/default.nix b/nix/default.nix index 2e3a72b..65f799a 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -3,5 +3,6 @@ imports = [ ./cgnix ./mcdev.nix + ./userstyles.nix ]; } diff --git a/nix/userstyles.nix b/nix/userstyles.nix new file mode 100644 index 0000000..81c2f88 --- /dev/null +++ b/nix/userstyles.nix @@ -0,0 +1,38 @@ +# Module that provides an output for a stylus import file with catppuccin themes. +{ pkgs, stdenvNoCC, ... }: +let + flavor = "mocha"; + accent-color = "red"; +in +{ + packages.userstyles = stdenvNoCC.mkDerivation { + name = "userstyles.json"; + src = pkgs.fetchurl { + url = "https://github.com/catppuccin/userstyles/releases/download/all-userstyles-export/import.json"; + hash = "sha256-eYU9Y95au9mI3muS4+1QJt31W7s2zVmurdKbQ1dU+pk="; + }; + + dontUnpack = true; + + # TODO: use better language + realBuilder = "${pkgs.deno}/bin/deno"; + args = [ + "run" + "-A" + (pkgs.writeText "build.js" '' + const json = await import(Deno.env.get("src"), { with: { type: "json" } }); + const processed = json.default.map(theme => { + if (theme.usercssData?.vars?.accentColor?.default) + theme.usercssData.vars.accentColor.default = "${accent-color}"; + + if (theme.usercssData?.vars?.darkFlavor?.default) + theme.usercssData.vars.darkFlavor.default = "${flavor}"; + + return theme; + }); + + Deno.writeTextFileSync(Deno.env.get("out"), JSON.stringify(processed)); + '') + ]; + }; +}