Further lib handling

This commit is contained in:
Kat Inskip 2023-07-30 10:05:15 -07:00
parent 11dd6aabd5
commit 5b8a624f97
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
2 changed files with 63 additions and 61 deletions

View file

@ -5,71 +5,71 @@
std, std,
... ...
}: let }: let
inherit (lib.option) mkOption;
inherit (lib.types) attrsOf str enum; inherit (lib.types) attrsOf str enum;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (std) string set tuple list; inherit (std) string set tuple list;
cfg = config.base16; cfg = config.base16;
in in {
with lib; { options.base16 = {
options.base16 = { palette = mkOption {
palette = mkOption { type = attrsOf str;
};
sass = {
variables = mkOption {
type = attrsOf str; type = attrsOf str;
default =
cfg.palette
// {
term_font = "Iosevka";
font = "Iosevka";
font_size = "12px";
};
}; };
sass = { css_style = mkOption {
variables = mkOption { type = enum ["nested" "compressed" "compact" "expanded"];
type = attrsOf str; default = "expanded";
default =
cfg.palette
// {
term_font = "Iosevka";
font = "Iosevka";
font_size = "12px";
};
};
css_style = mkOption {
type = enum ["nested" "compressed" "compact" "expanded"];
default = "expanded";
};
}; };
}; };
config = mkIf (cfg.schemes != {}) { };
base16 = { config = mkIf (cfg.schemes != {}) {
palette = set.fromList (k: v: base16 = {
tuple.toPair (tuple.tuple2 ( palette = set.fromList (k: v:
k tuple.toPair (tuple.tuple2 (
"#${v.hex}" k
)) "#${v.hex}"
(set.filter (n: _: string.hasPrefix "base" n) ))
cfg.defaultScheme)); (set.filter (n: _: string.hasPrefix "base" n)
}; cfg.defaultScheme));
};
lib.kittywitch.sassTemplate = { lib.kittywitch.sassTemplate = {
name, name,
src, src,
}: let }: let
variables = pkgs.writeText "base-variables.sass" '' variables = pkgs.writeText "base-variables.sass" ''
${(string.concatSep "\n" (mapToValues (var: con: "\$${var}: ${con}") cfg.sass.variables))} ${(string.concatSep "\n" (mapToValues (var: con: "\$${var}: ${con}") cfg.sass.variables))}
''; '';
source = source =
pkgs.callPackage pkgs.callPackage
({ ({
sass, sass,
stdenv, stdenv,
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
inherit name src variables; inherit name src variables;
nativeBuildInputs = list.singleton pkgs.sass; nativeBuildInputs = list.singleton pkgs.sass;
phases = ["buildPhase"]; phases = ["buildPhase"];
buildPhase = '' buildPhase = ''
cat $variables $src > src-mut.sass cat $variables $src > src-mut.sass
sass src-mut.sass $out --sourcemap=none --trace --style=${cfg.sass.css_style} sass src-mut.sass $out --sourcemap=none --trace --style=${cfg.sass.css_style}
''; '';
}) })
{}; {};
in { in {
inherit source; inherit source;
text = builtins.readFile source; text = builtins.readFile source;
};
_module.args = {inherit (config.lib) kittywitch;};
}; };
} _module.args = {inherit (config.lib) kittywitch;};
};
}

View file

@ -5,7 +5,9 @@ _: let
tree, tree,
pkgs, pkgs,
... ...
}: { }: let
inherit (lib.modules) mkDefault;
in {
imports = with tree.nixos.hardware; imports = with tree.nixos.hardware;
[ [
common-wifi-bt common-wifi-bt
@ -44,8 +46,8 @@ _: let
boot.kernelModules = ["kvm-amd"]; boot.kernelModules = ["kvm-amd"];
boot.extraModulePackages = []; boot.extraModulePackages = [];
boot.supportedFilesystems = ["ntfs"]; boot.supportedFilesystems = ["ntfs"];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.amd.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware;
fileSystems = { fileSystems = {
"/" = { "/" = {