mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
Further lib handling
This commit is contained in:
parent
11dd6aabd5
commit
5b8a624f97
2 changed files with 63 additions and 61 deletions
|
|
@ -5,71 +5,71 @@
|
|||
std,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.option) mkOption;
|
||||
inherit (lib.types) attrsOf str enum;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (std) string set tuple list;
|
||||
cfg = config.base16;
|
||||
in
|
||||
with lib; {
|
||||
options.base16 = {
|
||||
palette = mkOption {
|
||||
in {
|
||||
options.base16 = {
|
||||
palette = mkOption {
|
||||
type = attrsOf str;
|
||||
};
|
||||
sass = {
|
||||
variables = mkOption {
|
||||
type = attrsOf str;
|
||||
default =
|
||||
cfg.palette
|
||||
// {
|
||||
term_font = "Iosevka";
|
||||
font = "Iosevka";
|
||||
font_size = "12px";
|
||||
};
|
||||
};
|
||||
sass = {
|
||||
variables = mkOption {
|
||||
type = attrsOf str;
|
||||
default =
|
||||
cfg.palette
|
||||
// {
|
||||
term_font = "Iosevka";
|
||||
font = "Iosevka";
|
||||
font_size = "12px";
|
||||
};
|
||||
};
|
||||
css_style = mkOption {
|
||||
type = enum ["nested" "compressed" "compact" "expanded"];
|
||||
default = "expanded";
|
||||
};
|
||||
css_style = mkOption {
|
||||
type = enum ["nested" "compressed" "compact" "expanded"];
|
||||
default = "expanded";
|
||||
};
|
||||
};
|
||||
config = mkIf (cfg.schemes != {}) {
|
||||
base16 = {
|
||||
palette = set.fromList (k: v:
|
||||
tuple.toPair (tuple.tuple2 (
|
||||
k
|
||||
"#${v.hex}"
|
||||
))
|
||||
(set.filter (n: _: string.hasPrefix "base" n)
|
||||
cfg.defaultScheme));
|
||||
};
|
||||
};
|
||||
config = mkIf (cfg.schemes != {}) {
|
||||
base16 = {
|
||||
palette = set.fromList (k: v:
|
||||
tuple.toPair (tuple.tuple2 (
|
||||
k
|
||||
"#${v.hex}"
|
||||
))
|
||||
(set.filter (n: _: string.hasPrefix "base" n)
|
||||
cfg.defaultScheme));
|
||||
};
|
||||
|
||||
lib.kittywitch.sassTemplate = {
|
||||
name,
|
||||
src,
|
||||
}: let
|
||||
variables = pkgs.writeText "base-variables.sass" ''
|
||||
${(string.concatSep "\n" (mapToValues (var: con: "\$${var}: ${con}") cfg.sass.variables))}
|
||||
'';
|
||||
source =
|
||||
pkgs.callPackage
|
||||
({
|
||||
sass,
|
||||
stdenv,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
inherit name src variables;
|
||||
nativeBuildInputs = list.singleton pkgs.sass;
|
||||
phases = ["buildPhase"];
|
||||
buildPhase = ''
|
||||
cat $variables $src > src-mut.sass
|
||||
sass src-mut.sass $out --sourcemap=none --trace --style=${cfg.sass.css_style}
|
||||
'';
|
||||
})
|
||||
{};
|
||||
in {
|
||||
inherit source;
|
||||
text = builtins.readFile source;
|
||||
};
|
||||
_module.args = {inherit (config.lib) kittywitch;};
|
||||
lib.kittywitch.sassTemplate = {
|
||||
name,
|
||||
src,
|
||||
}: let
|
||||
variables = pkgs.writeText "base-variables.sass" ''
|
||||
${(string.concatSep "\n" (mapToValues (var: con: "\$${var}: ${con}") cfg.sass.variables))}
|
||||
'';
|
||||
source =
|
||||
pkgs.callPackage
|
||||
({
|
||||
sass,
|
||||
stdenv,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
inherit name src variables;
|
||||
nativeBuildInputs = list.singleton pkgs.sass;
|
||||
phases = ["buildPhase"];
|
||||
buildPhase = ''
|
||||
cat $variables $src > src-mut.sass
|
||||
sass src-mut.sass $out --sourcemap=none --trace --style=${cfg.sass.css_style}
|
||||
'';
|
||||
})
|
||||
{};
|
||||
in {
|
||||
inherit source;
|
||||
text = builtins.readFile source;
|
||||
};
|
||||
}
|
||||
_module.args = {inherit (config.lib) kittywitch;};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue