basic support for base16 templates

This commit is contained in:
notgne2 2021-03-29 16:25:14 -07:00
parent d78da97be7
commit df75571c56
No known key found for this signature in database
GPG Key ID: BB661E172B42A7F8
6 changed files with 232 additions and 389 deletions

View File

@ -1,5 +1,16 @@
{ {
outputs = { self, nixpkgs }: { inputs = {
base16-rofi = {
url = "git+ssh://git@gitlab.com/0xdec/base16-rofi.git";
flake = false;
};
base16-kitty = {
url = "github:kdrag0n/base16-kitty";
flake = false;
};
};
outputs = { self, nixpkgs, ... }@inputs: {
nixosModules = { nixosModules = {
ezpassthru = import ./modules/ezpassthru.nix; ezpassthru = import ./modules/ezpassthru.nix;
ezpc = import ./modules/ezpc.nix; ezpc = import ./modules/ezpc.nix;
@ -13,7 +24,11 @@
homeManagerModules = { homeManagerModules = {
ezpcusr = import ./home-manager/modules/ezpcusr.nix; ezpcusr = import ./home-manager/modules/ezpcusr.nix;
all = import ./home-manager/modules/default.nix; ezchromium = import ./home-manager/modules/ezchromium.nix;
ezcodium = import ./home-manager/modules/ezcodium.nix;
colors = import ./home-manager/modules/colors.nix inputs;
fonts = import ./home-manager/modules/fonts.nix;
all = import ./home-manager/modules/default.nix inputs;
}; };
# Not really modules? but eh # Not really modules? but eh
@ -22,7 +37,7 @@
nixosModules.common-glooder = import ./users/glooder.nix; nixosModules.common-glooder = import ./users/glooder.nix;
nixosModules.common-chekkie = import ./users/chekkie.nix; nixosModules.common-chekkie = import ./users/chekkie.nix;
homeManagerModules.common = import ./home-manager/common.nix; homeManagerModules.common = import ./home-manager/common.nix inputs;
homeManagerModules.common-notgne2 = import ./home-manager/users/notgne2.nix; homeManagerModules.common-notgne2 = import ./home-manager/users/notgne2.nix;
homeManagerModules.common-notgne2_pc = import ./home-manager/users/notgne2_pc.nix; homeManagerModules.common-notgne2_pc = import ./home-manager/users/notgne2_pc.nix;
homeManagerModules.common-glooder = import ./home-manager/users/glooder.nix; homeManagerModules.common-glooder = import ./home-manager/users/glooder.nix;

View File

@ -1,7 +1,8 @@
inputs:
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
imports = [ ./modules ]; imports = [ (import ./modules inputs) ];
programs.vim = { programs.vim = {
enable = true; enable = true;

View File

@ -1,38 +0,0 @@
name: base16:
''
# Base16 ${name} - kitty color config
# Scheme generated by ezpcusr in Nix
background #${base16."base00"}
foreground #${base16."base05"}
selection_background #${base16."base05"}
selection_foreground #${base16."base00"}
url_color #${base16."base04"}
cursor #${base16."base05"}
active_border_color #${base16."base03"}
inactive_border_color #${base16."base01"}
active_tab_background #${base16."base00"}
active_tab_foreground #${base16."base05"}
inactive_tab_background #${base16."base01"}
inactive_tab_foreground #${base16."base04"}
# normal
color0 #${base16."base00"}
color1 #${base16."base08"}
color2 #${base16."base0B"}
color3 #${base16."base0A"}
color4 #${base16."base0D"}
color5 #${base16."base0E"}
color6 #${base16."base0C"}
color7 #${base16."base05"}
# bright
color8 #${base16."base03"}
color9 #${base16."base09"}
color10 #${base16."base01"}
color11 #${base16."base02"}
color12 #${base16."base04"}
color13 #${base16."base06"}
color14 #${base16."base0F"}
color15 #${base16."base05"}
''

View File

@ -1,150 +0,0 @@
name: base16:
''
/**
* Base16 {{scheme-name}} ROFI Color theme
*
* Authors
* Scheme: {{scheme-author}}
* Template: Jordi Pakey-Rodriguez (https://github.com/0xdec), Andrea Scarpino (https://github.com/ilpianista)
*/
* {
red: #${base16."base08"};
blue: #${base16."base0D"};
lightfg: #${base16."base06"};
lightbg: #${base16."base01"};
foreground: #${base16."base05"};
background: #${base16."base00"};
background-color: #${base16."base00"};
separatorcolor: @foreground;
border-color: @foreground;
selected-normal-foreground: @lightbg;
selected-normal-background: @lightfg;
selected-active-foreground: @background;
selected-active-background: @blue;
selected-urgent-foreground: @background;
selected-urgent-background: @red;
normal-foreground: @foreground;
normal-background: @background;
active-foreground: @blue;
active-background: @background;
urgent-foreground: @red;
urgent-background: @background;
alternate-normal-foreground: @foreground;
alternate-normal-background: @lightbg;
alternate-active-foreground: @blue;
alternate-active-background: @lightbg;
alternate-urgent-foreground: @red;
alternate-urgent-background: @lightbg;
spacing: 2;
}
window {
background-color: @background;
border: 1;
padding: 5;
}
mainbox {
border: 0;
padding: 0;
}
message {
border: 1px dash 0px 0px ;
border-color: @separatorcolor;
padding: 1px ;
}
textbox {
text-color: @foreground;
}
listview {
fixed-height: 0;
border: 2px dash 0px 0px ;
border-color: @separatorcolor;
spacing: 2px ;
scrollbar: true;
padding: 2px 0px 0px ;
}
element {
border: 0;
padding: 1px ;
}
element normal.normal {
background-color: @normal-background;
text-color: @normal-foreground;
}
element normal.urgent {
background-color: @urgent-background;
text-color: @urgent-foreground;
}
element normal.active {
background-color: @active-background;
text-color: @active-foreground;
}
element selected.normal {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
}
element selected.urgent {
background-color: @selected-urgent-background;
text-color: @selected-urgent-foreground;
}
element selected.active {
background-color: @selected-active-background;
text-color: @selected-active-foreground;
}
element alternate.normal {
background-color: @alternate-normal-background;
text-color: @alternate-normal-foreground;
}
element alternate.urgent {
background-color: @alternate-urgent-background;
text-color: @alternate-urgent-foreground;
}
element alternate.active {
background-color: @alternate-active-background;
text-color: @alternate-active-foreground;
}
scrollbar {
width: 4px ;
border: 0;
handle-color: @normal-foreground;
handle-width: 8px ;
padding: 0;
}
sidebar {
border: 2px dash 0px 0px ;
border-color: @separatorcolor;
}
button {
spacing: 0;
text-color: @normal-foreground;
}
button selected {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
}
inputbar {
spacing: 0px;
text-color: @normal-foreground;
padding: 1px ;
children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
}
case-indicator {
spacing: 0;
text-color: @normal-foreground;
}
entry {
spacing: 0;
text-color: @normal-foreground;
}
prompt {
spacing: 0;
text-color: @normal-foreground;
}
textbox-prompt-colon {
expand: false;
str: ":";
margin: 0px 0.3000em 0.0000em 0.0000em ;
text-color: inherit;
}
''

View File

@ -1,3 +1,4 @@
inputs:
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
let let
@ -11,17 +12,48 @@ let
add = l: lib.foldr ({ n, x }: c: (x * (pow 16 n)) + c) 0 (lib.imap0 (n: x: { inherit n x; }) l); add = l: lib.foldr ({ n, x }: c: (x * (pow 16 n)) + c) 0 (lib.imap0 (n: x: { inherit n x; }) l);
calc = s: add (builtins.map fin (builtins.filter (x: builtins.isString x && builtins.stringLength x == 1) (builtins.split "" s))); calc = s: add (builtins.map fin (builtins.filter (x: builtins.isString x && builtins.stringLength x == 1) (builtins.split "" s)));
hexToRgb = c: splitHex = c:
let let
s' = builtins.match "(..)(..)(..)|(.)(.)(.)" c; s' = builtins.match "(..)(..)(..)|(.)(.)(.)" c;
ss = builtins.elemAt s'; ss = builtins.elemAt s';
o = if ss 0 == null then 3 else 0; o = if ss 0 == null then 3 else 0;
in in {
builtins.mapAttrs (_: calc) {
r = ss (0 + o); r = ss (0 + o);
g = ss (1 + o); g = ss (1 + o);
b = ss (2 + o); b = ss (2 + o);
}; };
hexToRgb = c: builtins.mapAttrs (_: calc) (splitHex c);
hexToAlphaCss = c: a: with hexToRgb c; "rgba(${r}, ${g}, ${b}, ${a})";
makeScheme = base16: lib.mapAttrs' (k: v: lib.nameValuePair "${k}-hex" v) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-hex-r" (splitHex v).r) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-hex-g" (splitHex v).g) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-hex-b" (splitHex v).b) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-rgb-r" (hexToRgb v).r) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-rgb-g" (hexToRgb v).g) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-rgb-b" (hexToRgb v).b) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-dec-r" ((hexToRgb v).r / 255.0)) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-dec-g" ((hexToRgb v).g / 255.0)) base16 //
lib.mapAttrs' (k: v: lib.nameValuePair "${k}-dec-b" ((hexToRgb v).b / 255.0)) base16;
mustache = scheme: name: src:
pkgs.stdenv.mkDerivation (
{
name = lib.strings.sanitizeDerivationName name;
inherit src;
data = pkgs.writeText "${name}-data" (builtins.toJSON scheme);
phases = [ "buildPhase" ];
buildPhase = "${pkgs.mustache-go}/bin/mustache $data $src > $out";
}
);
genTheme = repo: mustache (makeScheme cfg.base16 // {
scheme-name = cfg.favColors.name;
scheme-slug = "idk";
scheme-author = "nixos";
}) cfg.favColors.name "${repo}/templates/default.mustache";
in in
{ {
options.colors = { options.colors = {
@ -164,7 +196,7 @@ in
mkIf cfg.enable { mkIf cfg.enable {
# Read only utility attributes # Read only utility attributes
colors.base16 = cfg.favColors.base16; colors.base16 = cfg.favColors.base16;
colors.base16Rgb = builtins.map hexToRgb cfg.favColors.base16; colors.base16Rgb = builtins.mapAttrs hexToRgb cfg.favColors.base16;
# Element # Element
xdg.configFile."Riot/config.json".text = builtins.toJSON elementConfig; xdg.configFile."Riot/config.json".text = builtins.toJSON elementConfig;
@ -248,31 +280,11 @@ in
}; };
# Rofi # Rofi
programs.rofi = { programs.rofi.theme = "${genTheme inputs.base16-rofi}";
theme = (
pkgs.writeText "rofi-base16-config"
(
(import ../data/rofi-base16.nix)
cfg.favColors.name
cfg.favColors.base16
)
).outPath;
};
# Kitty # Kitty
programs.kitty.extraConfig = programs.kitty.extraConfig = ''
let include ${genTheme inputs.base16-kitty}
kittyColors =
pkgs.writeText
"favcolors-kitty-${cfg.favColors.name}.conf"
(
(import ../data/kitty-base16.nix)
cfg.favColors.name
cfg.favColors.base16
);
in
''
include ${kittyColors}
''; '';
# neovim # neovim
@ -343,7 +355,8 @@ in
home.file = lib.mkMerge home.file = lib.mkMerge
[ [
(mkIf config.programs.vscode.enable { (
mkIf config.programs.vscode.enable {
".vscode-oss/extensions/base16-1.0.0/themes/nix-colors.json".text = (import ../data/codium-base16.nix) cfg.favColors.name cfg.favColors.base16; ".vscode-oss/extensions/base16-1.0.0/themes/nix-colors.json".text = (import ../data/codium-base16.nix) cfg.favColors.name cfg.favColors.base16;
".vscode-oss/extensions/base16-1.0.0/package.json".text = builtins.toJSON { ".vscode-oss/extensions/base16-1.0.0/package.json".text = builtins.toJSON {
name = "nix colors"; name = "nix colors";
@ -364,7 +377,8 @@ in
} }
]; ];
}; };
}) }
)
]; ];
}; };
} }

View File

@ -1,3 +1,4 @@
inputs:
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
@ -9,7 +10,7 @@
./ezpcusr.nix ./ezpcusr.nix
./ezchromium.nix ./ezchromium.nix
./ezcodium.nix ./ezcodium.nix
./colors.nix (import ./colors.nix inputs)
./fonts.nix ./fonts.nix
]; ];
} }