From edc9911f48b20be17501850f5b953a3393e3be43 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 11 May 2024 04:30:52 +0300 Subject: [PATCH] flake: eval scheme data --- flake.lock | 19 +------------------ flake.nix | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/flake.lock b/flake.lock index acf998a..674a925 100644 --- a/flake.lock +++ b/flake.lock @@ -49,24 +49,7 @@ "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs", - "schemes": "schemes" - } - }, - "schemes": { - "flake": false, - "locked": { - "lastModified": 1713388094, - "narHash": "sha256-wcotm0Ek2ISn8iJBzEujJQdcPLKWrPAOZ/dS/DLKafw=", - "owner": "tinted-theming", - "repo": "schemes", - "rev": "abcf2a055ae69f1bf047463332f83db3125aa8a5", - "type": "github" - }, - "original": { - "owner": "tinted-theming", - "repo": "schemes", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 82f28c8..039e533 100644 --- a/flake.nix +++ b/flake.nix @@ -1,24 +1,36 @@ { - description = "Description for the project"; + description = "Base16/Base24 schemes for Nix"; inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - schemes = { - url = "github:tinted-theming/schemes"; - flake = false; - }; }; outputs = inputs @ {flake-parts, ...}: flake-parts.lib.mkFlake {inherit inputs;} { systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"]; perSystem = {pkgs, ...}: { - # Example if we could make it a list: - # builtins.mapAttrs (_: p: builtins.fromJSON (builtins.readFile p)) (import ./list.nix) packages = { convert-scheme = pkgs.callPackage ./packages/convert-scheme/package.nix {}; }; }; + + 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); + in { + schemeData = { + base16 = evalSchemeData ./json/base16; + base24 = evalSchemeData ./json/base24; + }; + }; }; }