flake: eval scheme data

This commit is contained in:
raf 2024-05-11 04:30:52 +03:00
parent e4dc9f586e
commit edc9911f48
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
2 changed files with 20 additions and 25 deletions

View file

@ -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"
}
}
},

View file

@ -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;
};
};
};
}