From a130807b834fb1f2afdbe2be1da67769b81592d4 Mon Sep 17 00:00:00 2001 From: kat Date: Fri, 29 Jul 2022 10:04:20 -0700 Subject: [PATCH] modules(home/base16-gtk): init --- home/base16.nix | 33 +++++- home/gtk.nix | 4 +- modules/home/base16-gtk.nix | 207 ++++++++++++++++++++++++++++++++++++ outputs.nix | 8 +- overlays/local/default.nix | 4 + overlays/local/oomox.nix | 64 +++++++++++ tf | 2 +- 7 files changed, 315 insertions(+), 7 deletions(-) create mode 100644 modules/home/base16-gtk.nix create mode 100644 overlays/local/oomox.nix diff --git a/home/base16.nix b/home/base16.nix index 7661f14d..b24af8f5 100644 --- a/home/base16.nix +++ b/home/base16.nix @@ -4,14 +4,43 @@ kw.theme.enable = true; base16 = { + vim.enable = false; + gtk = { + settings.default = { + icon_style = "numix"; + theme_style = "materia"; + }; + }; + vim.template = data: let + drv = pkgs.base16-templates.vim.withTemplateData data; + in drv.overrideAttrs (old: { + src = pkgs.fetchFromGitHub { + repo = "base16-vim"; + owner = "fnune"; + rev = "52e4ce93a6234d112bc88e1ad25458904ffafe61"; + sha256 = "10y8z0ycmdjk47dpxf6r2pc85k0y19a29aww99vgnxp31wrkc17h"; + }; + patches = old.patches or [ ] ++ [ + (pkgs.fetchurl { + # base16background=none + url = "https://github.com/arcnmx/base16-vim/commit/fe16eaaa1de83b649e6867c61494276c1f35c3c3.patch"; + sha256 = "1c0n7mf6161mvxn5xlabhyxzha0m1c41csa6i43ng8zybbspipld"; + }) + (pkgs.fetchurl { + # fix unreadable error highlights under cursor + url = "https://github.com/arcnmx/base16-vim/commit/807e442d95c57740dd3610c9f9c07c9aae8e0995.patch"; + sha256 = "1l3qmk15v8d389363adkmfg8cpxppyhlk215yq3rdcasvw7r8bla"; + }) + ]; + }); shell.enable = true; schemes = lib.mkMerge [ { light = "atelier.atelier-cave-light"; dark = "atelier.atelier-cave"; - } (lib.mkIf (true == false) { + } { dark.ansi.palette.background.alpha = "ee00"; light.ansi.palette.background.alpha = "d000"; - }) ]; + } ]; defaultSchemeName = "dark"; }; } diff --git a/home/gtk.nix b/home/gtk.nix index b3bccb21..69462552 100644 --- a/home/gtk.nix +++ b/home/gtk.nix @@ -1,8 +1,10 @@ { config, lib, pkgs, ... }: { + home.packages = with pkgs; [ lxappearance ]; + base16.gtk.enable = true; gtk = { - enable = true; + enable = false; iconTheme = { name = "Papirus-Dark"; package = pkgs.papirus-icon-theme; diff --git a/modules/home/base16-gtk.nix b/modules/home/base16-gtk.nix new file mode 100644 index 00000000..a6da75cc --- /dev/null +++ b/modules/home/base16-gtk.nix @@ -0,0 +1,207 @@ +{ config, pkgs, lib, ... }: let +inherit (lib.types) bool enum str int submodule oneOf attrsOf package; +inherit (lib.options) mkEnableOption mkOption; +inherit (lib.strings) optionalString concatStringsSep toUpper hasInfix; +inherit (lib.attrsets) mapAttrsToList mapAttrs; +inherit (pkgs.stdenv) mkDerivation; +inherit (lib.modules) mkIf mkDefault; +cfg = config.base16.gtk.settings; +bcfg = config.base16.gtk; +in { + options = { + base16.gtk = { + enable = mkEnableOption "Enable GTK theme generation"; + packages = mkOption { + type = attrsOf package; + }; + settings = mkOption { + type = attrsOf (submodule { + freeformType = attrsOf (oneOf [bool str int]); + options = { + name = mkOption { + description = "Name of the theme"; + type = str; + default = ''"${config.base16.defaultSchemeName}"''; + }; + theme_style = mkOption { + description = "What GTK theme do we use as the base for generating the resulting base16 GTK theme"; + type = enum ["materia" "oomox"]; + default = "oomox"; + }; + roundness = mkOption { + description = "GTK theme roundness"; + type = int; + default = 2; + }; + spacing = mkOption { + description = "GTK theme spacing"; + type = int; + default = 3; + }; + outline_width = mkOption { + description = "GTK outline width"; + type = int; + default = 1; + }; + button_outline_offset = mkOption { + description = "GTK theme button outline offset"; + type = int; + default = -3; + }; + button_outline_width = mkOption { + description = "GTK theme button outline width"; + type = int; + default = 1; + }; + icon_style = mkOption { + description = "What icon theme do we use as the base for generating the resulting base16 color templated icon theme"; + type = enum ["numix" "archdroid" "gnomecolors" "papirus" "suruplus" "suruplus_aspromauros"]; + default = "archdroid"; + }; + numix_style = mkOption { + description = "If you chose numix for base16.gtk.icons, this chooses the Numix icon theme sub-style"; + type = enum [ 0 1 2 3 4 5 ]; + default = 0; + }; + suruplus_gradient_enabled = mkOption { + description = "If you chose suruplus for base16.gtk.icons, this chooses to enable the gradient on it"; + type = bool; + default = false; + }; + base16_generate_dark = mkOption { + description = "Choose whether to invert the GUI colours"; + type = bool; + default = true; + }; + }; + }); + }; + }; + }; + config = mkIf bcfg.enable (let + oomoxPath = "${pkgs.oomox}/lib/share/oomox/plugins"; + iconPathSelector = icon_style: { + archdroid = "icons_archdroid/archdroid-icon-theme/change_color.sh"; + gnomecolors = "icons_gnomecolors/gnome-colors-icon-theme/change_color.sh"; + }.${icon_style} or "icons_${icon_style}/change_color.sh"; + themePathSelector = theme_style: { + materia = "theme_materia/materia-theme/change_color.sh"; + }.${theme_style} or "theme_${theme_style}/change_color.sh"; + iconsTheme = icon_style: { + numix = "numix_icons"; + suruplus = "icons_suru"; + suruplus_aspromauros = "icons_suruplus_aspromauros"; + archdroid = "archdroid"; + gnomecolors = "gnome_colors"; + papirus = "papirus_icons"; + }.${icon_style}; + configForScheme = schemeName: scheme: let + schemeSettings = cfg.${schemeName} or cfg.default; + keyValues = mapAttrsToList (k: v: let + typeHandler = { + "string" = if hasInfix "base" v then scheme.${v}.hex else v; + "bool" = if v == true then "True" else "False"; + "int" = toString v; + }.${builtins.typeOf v}; + keyHandler = { + "icon_style" = iconsTheme v; + }.${k} or typeHandler; + in "${toUpper k}=${keyHandler}") schemeSettings; + in '' + ${concatStringsSep "\n" keyValues} + ''; + configForSchemes = mapAttrs configForScheme config.base16.schemes; + configFilesForSchemes = mapAttrs (k: v: pkgs.writeText "oomox-config-${k}" v) configForSchemes; + packageForScheme = name: schemeConfigFile: let + schemeConfig = cfg.${name} or cfg.default; + in with pkgs; mkDerivation rec { + inherit name; + src = fetchFromGitHub { + owner = "themix-project"; + repo = "oomox"; + rev = "1.14"; + sha256 = "0zk2q0z0n64kl6my60vkq11gp4mc442jxqcwbi4kl108242izpjv"; + fetchSubmodules = true; + }; + nativeBuildInputs = [ glib libxml2 bc ]; + buildInputs = [ gnome3.gnome-themes-extra gdk-pixbuf librsvg pkgs.sassc pkgs.inkscape pkgs.optipng ]; + propagatedUserEnvPkgs = [ gtk-engine-murrine ]; + installPhase = '' + export HOME=./ + mkdir -p ./.icons + patchShebangs plugins/${iconPathSelector schemeConfig.icon_style} + plugins/${iconPathSelector schemeConfig.icon_style} ${schemeConfigFile} \ + -o $name-${schemeConfig.icon_style} + mkdir -p $out/share/icons/${schemeConfig.icon_style}-$name + mv ./.icons/* $out/share/icons/${schemeConfig.icon_style}-$name + mkdir -p $out/share/themes/${schemeConfig.theme_style}-$name + patchShebangs plugins/theme_${schemeConfig.theme_style} + plugins/${themePathSelector schemeConfig.theme_style} \ + --hidpi False --target $out/share/themes --output $name-${schemeConfig.theme_style} ${schemeConfigFile} + ''; + }; + packagesForSchemes = mapAttrsToList (k: v: packageForScheme k v) configFilesForSchemes; +in { + base16.gtk = { + packages = packagesForSchemes; + settings.default = mapAttrs (_: mkDefault) { + base16_invert_terminal = false; + base16_mild_terminal = false; + terminal_theme_accuracy = 128; + terminal_theme_auto_bgfg = true; + terminal_theme_extend_palette = false; + terminal_theme_mode = "manual"; + unity_default_launcher_style = false; + suruplus_gradient1 = "3623c"; + suruplus_gradient2 = "base0E"; + caret1_fg = "base07"; + caret2_fg = "base07"; + terminal_background = "base00"; + terminal_foreground = "base05"; + terminal_cursor = "base05"; + terminal_color0 = "base01"; + terminal_color1 = "base08"; + terminal_color2 = "base0B"; + terminal_color3 = "base09"; + terminal_color4 = "base0D"; + terminal_color5 = "base0E"; + terminal_color6 = "base0C"; + terminal_color7 = "base06"; + terminal_color8 = "base02"; + terminal_color9 = "base08"; + terminal_color10 = "base0B"; + terminal_color11 = "base0A"; + terminal_color12 = "base0D"; + terminal_color13 = "base0E"; + terminal_color14 = "base0C"; + terminal_color15 = "base07"; + bg = "base01"; + fg = "base06"; + hdr_bg = "base00"; + hdr_fg = "base05"; + sel_bg = "base0E"; + sel_fg = "base00"; + accent_bg = "base0E"; + txt_bg = "base02"; + txt_fg = "base07"; + btn_bg = "base00"; + btn_fg = "base05"; + hdr_btn_bg = "base01"; + hdr_btn_fg = "base05"; + wm_border_focus = "base0E"; + wm_border_unfocus = "base00"; + spotify_proto_bg = "base00"; + spotify_proto_fg = "base05"; + spotify_proto_sel = "base0E"; + icons_light_folder = "base0D"; + icons_light = "base0D"; + icons_medium = "base0E"; + icons_dark = "base00"; + icons_symbolic_panel = "base06"; + icons_symbolic_action = "3623c"; + icons_archdroid = "base0E"; + }; + }; + home.packages = packagesForSchemes; + }); +} diff --git a/outputs.nix b/outputs.nix index b540723a..1c76d126 100644 --- a/outputs.nix +++ b/outputs.nix @@ -1,18 +1,20 @@ { inputs, system ? builtins.currentSystem or "x86_64-linux" , ... }: let optionalAttrs = cond: as: if cond then as else { }; - pkgs = import ./overlays { inherit inputs system; }; + bootstrapPkgs = import ./overlays { inherit inputs system; }; inherit (pkgs) lib; - patchedInputs = inputs // { darwin = pkgs.applyPatches { + patchedInputs = inputs // { darwin = bootstrapPkgs.applyPatches { name = "darwin"; src = inputs.darwin; - patches = [ (pkgs.fetchpatch { + patches = [ (bootstrapPkgs.fetchpatch { url = "https://patch-diff.githubusercontent.com/raw/LnL7/nix-darwin/pull/310.patch"; sha256 = "sha256-drnLOhF8JGXx8YY7w1PD2arUZvbqafWPTatQNTHt+QI="; }) ]; }; }; + pkgs = import ./overlays { inherit system; inputs = patchedInputs; }; + mkTree = import ./tree.nix { inherit lib; }; localTree = mkTree { inputs = patchedInputs; diff --git a/overlays/local/default.nix b/overlays/local/default.nix index 07bbdab3..e7848271 100644 --- a/overlays/local/default.nix +++ b/overlays/local/default.nix @@ -10,4 +10,8 @@ final: prev: { waybar-konawall = final.callPackage ./waybar-konawall { }; hedgedoc-cli = final.callPackage ./hedgedoc-cli.nix { }; gensokyoZone = final.callPackage ./gensokyoZone { }; + oomox = final.callPackage ./oomox.nix { }; + wezterm = final.callPackage ./wezterm { + inherit (final.darwin.apple_sdk.frameworks) Cocoa CoreGraphics Foundation; + }; } diff --git a/overlays/local/oomox.nix b/overlays/local/oomox.nix new file mode 100644 index 00000000..438317dc --- /dev/null +++ b/overlays/local/oomox.nix @@ -0,0 +1,64 @@ +{ gnome3 +, stdenv +, gdk-pixbuf +, glib +, libxml2 +, bc +, librsvg +, sassc +, inkscape +, optipng +, python3 +, gtk3 +, gobject-introspection +, gtk-engine-murrine +, fetchFromGitHub +, wrapGAppsHook +, makeWrapper +, runtimeShell +}: +python3.pkgs.buildPythonApplication rec { + format = "other"; + name = "oomox"; + src = fetchFromGitHub { + owner = "themix-project"; + repo = "oomox"; + rev = "1.14"; + sha256 = "0zk2q0z0n64kl6my60vkq11gp4mc442jxqcwbi4kl108242izpjv"; + fetchSubmodules = true; + }; + dontWrapGApps = true; + dontPatchELF = true; + dontFixup = true; + doCheck = false; + strictDeps = false; + buildPhase = '' + true + ''; + nativeBuildInputs = [ makeWrapper wrapGAppsHook libxml2 gobject-introspection glib bc ]; + propagatedBuildInputs = with python3.pkgs; [ + gnome3.gnome-themes-extra gdk-pixbuf librsvg sassc inkscape optipng + gobject-introspection + pygobject3 + python3 + gtk-engine-murrine + pystache + pyyaml + gtk3 + bc + + ]; + propagatedUserEnvPkgs = [ gtk-engine-murrine ]; +installPhase = '' +mkdir $out +gappsWrapperArgsHook +make install DESTDIR=/ PREFIX=$out APPDIR=$out/lib/share/oomox +for prog in $out/bin/*; do +sed -i "s/cd /true /" $prog +wrapProgram $prog "''${gappsWrapperArgs[@]}" --prefix PATH : "${bc}/bin:${python3}/bin" --prefix PYTHONPATH : "$out/lib/share/oomox:$PYTHONPATH" +done +#for script in $(find $out -name "change_color.sh"); do +# cp ${./script.sh} $script +#done +''; +} diff --git a/tf b/tf index 8214f68c..e0480fd5 160000 --- a/tf +++ b/tf @@ -1 +1 @@ -Subproject commit 8214f68ca8490f1c926a6ab7af037d40ac15d24f +Subproject commit e0480fd57f0d85814aec8a16c9a1d637283da4e3