treewide: use mkTarget (batch 3) (#1371)
Link: https://github.com/nix-community/stylix/pull/1371 Reviewed-by: pancho horrillo <pancho@pancho.name> Reviewed-by: Matt Sturgeon <matt@sturgeon.me.uk> Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
parent
ced2af0622
commit
aa5e3c0333
6 changed files with 270 additions and 249 deletions
|
|
@ -1,83 +1,89 @@
|
||||||
{
|
{ mkTarget, pkgs, ... }:
|
||||||
pkgs,
|
mkTarget {
|
||||||
config,
|
name = "emacs";
|
||||||
lib,
|
humanName = "Emacs";
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (config.stylix) fonts;
|
|
||||||
emacsOpacity = builtins.toString (
|
|
||||||
builtins.ceil (config.stylix.opacity.applications * 100)
|
|
||||||
);
|
|
||||||
emacsSize = builtins.toString (fonts.sizes.terminal * 1.0);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.stylix.targets.emacs.enable =
|
|
||||||
config.lib.stylix.mkEnableTarget "Emacs" true;
|
|
||||||
|
|
||||||
config = lib.mkIf (config.stylix.enable && config.stylix.targets.emacs.enable) {
|
configElements = [
|
||||||
programs.emacs = {
|
(
|
||||||
extraPackages = epkgs: [
|
{ opacity }:
|
||||||
(epkgs.trivialBuild (
|
{
|
||||||
with config.lib.stylix.colors.withHashtag;
|
programs.emacs.extraConfig = ''
|
||||||
{
|
(add-to-list 'default-frame-alist '(alpha-background . ${
|
||||||
pname = "base16-stylix-theme";
|
toString (builtins.ceil (opacity.applications * 100))
|
||||||
version = "0.1.0";
|
}))
|
||||||
src = pkgs.writeText "base16-stylix-theme.el" ''
|
'';
|
||||||
(require 'base16-theme)
|
}
|
||||||
|
)
|
||||||
|
(
|
||||||
|
{ fonts }:
|
||||||
|
{
|
||||||
|
programs.emacs.extraConfig = ''
|
||||||
|
(set-face-attribute 'default nil :font (font-spec :family "${fonts.monospace.name}" :size ${
|
||||||
|
toString (fonts.sizes.terminal * 1.0)
|
||||||
|
}))
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
||||||
|
(
|
||||||
|
{ colors }:
|
||||||
|
{
|
||||||
|
programs.emacs = {
|
||||||
|
extraConfig = ''
|
||||||
|
(require 'base16-stylix-theme)
|
||||||
|
(setq base16-theme-256-color-source 'colors)
|
||||||
|
(load-theme 'base16-stylix t)
|
||||||
|
'';
|
||||||
|
|
||||||
(defvar base16-stylix-theme-colors
|
extraPackages = epkgs: [
|
||||||
'(:base00 "${base00}"
|
(epkgs.trivialBuild (
|
||||||
:base01 "${base01}"
|
with colors.withHashtag;
|
||||||
:base02 "${base02}"
|
{
|
||||||
:base03 "${base03}"
|
pname = "base16-stylix-theme";
|
||||||
:base04 "${base04}"
|
version = "0.1.0";
|
||||||
:base05 "${base05}"
|
src = pkgs.writeText "base16-stylix-theme.el" ''
|
||||||
:base06 "${base06}"
|
(require 'base16-theme)
|
||||||
:base07 "${base07}"
|
|
||||||
:base08 "${base08}"
|
|
||||||
:base09 "${base09}"
|
|
||||||
:base0A "${base0A}"
|
|
||||||
:base0B "${base0B}"
|
|
||||||
:base0C "${base0C}"
|
|
||||||
:base0D "${base0D}"
|
|
||||||
:base0E "${base0E}"
|
|
||||||
:base0F "${base0F}")
|
|
||||||
"All colors for Base16 stylix are defined here.")
|
|
||||||
|
|
||||||
;; Define the theme
|
(defvar base16-stylix-theme-colors
|
||||||
(deftheme base16-stylix)
|
'(:base00 "${base00}"
|
||||||
|
:base01 "${base01}"
|
||||||
|
:base02 "${base02}"
|
||||||
|
:base03 "${base03}"
|
||||||
|
:base04 "${base04}"
|
||||||
|
:base05 "${base05}"
|
||||||
|
:base06 "${base06}"
|
||||||
|
:base07 "${base07}"
|
||||||
|
:base08 "${base08}"
|
||||||
|
:base09 "${base09}"
|
||||||
|
:base0A "${base0A}"
|
||||||
|
:base0B "${base0B}"
|
||||||
|
:base0C "${base0C}"
|
||||||
|
:base0D "${base0D}"
|
||||||
|
:base0E "${base0E}"
|
||||||
|
:base0F "${base0F}")
|
||||||
|
"All colors for Base16 stylix are defined here.")
|
||||||
|
|
||||||
;; Add all the faces to the theme
|
;; Define the theme
|
||||||
(base16-theme-define 'base16-stylix base16-stylix-theme-colors)
|
(deftheme base16-stylix)
|
||||||
|
|
||||||
;; Mark the theme as provided
|
;; Add all the faces to the theme
|
||||||
(provide-theme 'base16-stylix)
|
(base16-theme-define 'base16-stylix base16-stylix-theme-colors)
|
||||||
|
|
||||||
;; Add path to theme to theme-path
|
;; Mark the theme as provided
|
||||||
(add-to-list 'custom-theme-load-path
|
(provide-theme 'base16-stylix)
|
||||||
(file-name-directory
|
|
||||||
(file-truename load-file-name)))
|
|
||||||
|
|
||||||
(provide 'base16-stylix-theme)
|
;; Add path to theme to theme-path
|
||||||
'';
|
(add-to-list 'custom-theme-load-path
|
||||||
packageRequires = [ epkgs.base16-theme ];
|
(file-name-directory
|
||||||
}
|
(file-truename load-file-name)))
|
||||||
))
|
|
||||||
];
|
|
||||||
|
|
||||||
extraConfig = ''
|
(provide 'base16-stylix-theme)
|
||||||
;; ---- Generated by stylix ----
|
'';
|
||||||
(require 'base16-stylix-theme)
|
packageRequires = [ epkgs.base16-theme ];
|
||||||
(setq base16-theme-256-color-source 'colors)
|
}
|
||||||
(load-theme 'base16-stylix t)
|
))
|
||||||
;; Set font
|
];
|
||||||
(set-face-attribute 'default nil :font (font-spec :family "${fonts.monospace.name}" :size ${emacsSize}))
|
};
|
||||||
;; -----------------------------
|
}
|
||||||
;; set opacity
|
)
|
||||||
(add-to-list 'default-frame-alist '(alpha-background . ${emacsOpacity}))
|
];
|
||||||
;; -----------------------------
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
{ config, lib, ... }:
|
{ mkTarget, ... }:
|
||||||
|
mkTarget {
|
||||||
|
name = "eog";
|
||||||
|
humanName = "Eye of GNOME Image Viewer";
|
||||||
|
|
||||||
{
|
configElements =
|
||||||
options.stylix.targets.eog.enable =
|
{ colors }:
|
||||||
config.lib.stylix.mkEnableTarget "Eye of GNOME Image Viewer" true;
|
{
|
||||||
|
dconf.settings."org/gnome/eog/view" = {
|
||||||
config = lib.mkIf (config.stylix.enable && config.stylix.targets.eog.enable) {
|
# transparency = "background"; # Disables the grey and white check pattern.
|
||||||
dconf.settings."org/gnome/eog/view" = {
|
background-color = "#${colors.base00}";
|
||||||
# transparency = "background"; # Disables the grey and white check pattern.
|
};
|
||||||
background-color = "#${config.lib.stylix.colors.base00}";
|
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,22 @@
|
||||||
{
|
{
|
||||||
|
mkTarget,
|
||||||
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
config,
|
||||||
lib,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
mkTarget {
|
||||||
cfg = config.stylix.targets.feh;
|
name = "feh";
|
||||||
in
|
humanName = "the desktop background using Feh";
|
||||||
{
|
autoEnable =
|
||||||
options.stylix.targets.feh = {
|
with config.services.xserver.windowManager;
|
||||||
enable = config.lib.stylix.mkEnableTarget "the desktop background using Feh" (
|
xmonad.enable || i3.enable;
|
||||||
config.stylix.image != null
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
config.services.xserver.displayManager.sessionCommands =
|
configElements =
|
||||||
lib.mkIf
|
{ image, imageScalingMode }:
|
||||||
(
|
{
|
||||||
config.stylix.enable
|
services.xserver.displayManager.sessionCommands =
|
||||||
&& cfg.enable
|
|
||||||
&& (with config.services.xserver.windowManager; xmonad.enable || i3.enable)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
let
|
let
|
||||||
inherit (config.stylix) imageScalingMode;
|
|
||||||
bg-arg =
|
bg-arg =
|
||||||
if imageScalingMode == "fill" then
|
if imageScalingMode == "fill" then
|
||||||
"--bg-fill"
|
"--bg-fill"
|
||||||
|
|
@ -37,6 +30,6 @@ in
|
||||||
else
|
else
|
||||||
"--bg-max";
|
"--bg-max";
|
||||||
in
|
in
|
||||||
"${lib.getExe pkgs.feh} --no-fehbg ${bg-arg} ${config.stylix.image}"
|
"${lib.getExe pkgs.feh} --no-fehbg ${bg-arg} ${image}";
|
||||||
);
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,69 +1,70 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
mkTarget,
|
||||||
config,
|
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
mkTarget {
|
||||||
|
name = "vim";
|
||||||
|
humanName = "Vim";
|
||||||
|
|
||||||
let
|
configElements = [
|
||||||
themeFile = config.lib.stylix.colors {
|
(
|
||||||
templateRepo = config.stylix.inputs.base16-vim;
|
{ fonts }:
|
||||||
target = "base16";
|
{
|
||||||
};
|
programs.vim.extraConfig = ''
|
||||||
|
set guifont=${
|
||||||
|
lib.escape [ " " ] fonts.monospace.name
|
||||||
|
}:h${toString fonts.sizes.terminal}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
||||||
|
(
|
||||||
|
{ colors, inputs }:
|
||||||
|
{
|
||||||
|
programs.vim = {
|
||||||
|
plugins = [
|
||||||
|
(pkgs.vimUtils.buildVimPlugin {
|
||||||
|
name = "stylix";
|
||||||
|
pname = "stylix";
|
||||||
|
|
||||||
themePlugin = pkgs.vimUtils.buildVimPlugin {
|
src = colors {
|
||||||
name = "stylix";
|
templateRepo = inputs.base16-vim;
|
||||||
pname = "stylix";
|
target = "base16";
|
||||||
|
};
|
||||||
|
dontUnpack = true;
|
||||||
|
|
||||||
src = themeFile;
|
buildPhase = ''
|
||||||
dontUnpack = true;
|
install -D $src $out/colors/base16-stylix.vim
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
];
|
||||||
|
extraConfig = with colors.withHashtag; ''
|
||||||
|
set termguicolors
|
||||||
|
colorscheme base16-stylix
|
||||||
|
unlet g:colors_name
|
||||||
|
|
||||||
buildPhase = ''
|
let g:stylix_colors = {
|
||||||
install -D $src $out/colors/base16-stylix.vim
|
\ 'base00': '${base00}',
|
||||||
'';
|
\ 'base01': '${base01}',
|
||||||
};
|
\ 'base02': '${base02}',
|
||||||
|
\ 'base03': '${base03}',
|
||||||
vimOptions =
|
\ 'base04': '${base04}',
|
||||||
let
|
\ 'base05': '${base05}',
|
||||||
inherit (config.stylix) fonts;
|
\ 'base06': '${base06}',
|
||||||
in
|
\ 'base07': '${base07}',
|
||||||
{
|
\ 'base08': '${base08}',
|
||||||
plugins = [ themePlugin ];
|
\ 'base09': '${base09}',
|
||||||
extraConfig = with config.lib.stylix.colors.withHashtag; ''
|
\ 'base0A': '${base0A}',
|
||||||
set termguicolors
|
\ 'base0B': '${base0B}',
|
||||||
colorscheme base16-stylix
|
\ 'base0C': '${base0C}',
|
||||||
unlet g:colors_name
|
\ 'base0D': '${base0D}',
|
||||||
|
\ 'base0E': '${base0E}',
|
||||||
let g:stylix_colors = {
|
\ 'base0F': '${base0F}',
|
||||||
\ 'base00': '${base00}',
|
\ }
|
||||||
\ 'base01': '${base01}',
|
'';
|
||||||
\ 'base02': '${base02}',
|
};
|
||||||
\ 'base03': '${base03}',
|
}
|
||||||
\ 'base04': '${base04}',
|
)
|
||||||
\ 'base05': '${base05}',
|
];
|
||||||
\ 'base06': '${base06}',
|
|
||||||
\ 'base07': '${base07}',
|
|
||||||
\ 'base08': '${base08}',
|
|
||||||
\ 'base09': '${base09}',
|
|
||||||
\ 'base0A': '${base0A}',
|
|
||||||
\ 'base0B': '${base0B}',
|
|
||||||
\ 'base0C': '${base0C}',
|
|
||||||
\ 'base0D': '${base0D}',
|
|
||||||
\ 'base0E': '${base0E}',
|
|
||||||
\ 'base0F': '${base0F}',
|
|
||||||
\ }
|
|
||||||
|
|
||||||
set guifont=${
|
|
||||||
lib.escape [ " " ] fonts.monospace.name
|
|
||||||
}:h${toString fonts.sizes.terminal}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.stylix.targets.vim.enable = config.lib.stylix.mkEnableTarget "Vim" true;
|
|
||||||
|
|
||||||
config = lib.mkIf (config.stylix.enable && config.stylix.targets.vim.enable) {
|
|
||||||
programs.vim = vimOptions;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,66 +1,86 @@
|
||||||
{
|
{
|
||||||
|
mkTarget,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
mkTarget {
|
||||||
cfg = config.stylix.targets.wayfire;
|
name = "wayfire";
|
||||||
in
|
humanName = "wayfire";
|
||||||
|
|
||||||
{
|
extraOptions.useWallpaper = config.lib.stylix.mkEnableWallpaper "wayfire" true;
|
||||||
options.stylix.targets.wayfire = {
|
|
||||||
enable = config.lib.stylix.mkEnableTarget "wayfire" true;
|
|
||||||
useWallpaper = config.lib.stylix.mkEnableWallpaper "wayfire" true;
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf (config.stylix.enable && cfg.enable) (
|
configElements = [
|
||||||
let
|
(
|
||||||
inherit (config.lib.stylix) colors;
|
{ fonts }:
|
||||||
rgba = rgb: a: "\\#${rgb}${a}";
|
{
|
||||||
rgb = (lib.flip rgba) "ff";
|
wayland.windowManager.wayfire.settings.decoration.font =
|
||||||
|
"${fonts.monospace.name} ${toString fonts.sizes.desktop}";
|
||||||
wayfireConfig = config.wayland.windowManager.wayfire;
|
}
|
||||||
|
)
|
||||||
wayfireBackground = pkgs.runCommand "wayfire-background.png" { } ''
|
(
|
||||||
${lib.getExe' pkgs.imagemagick "convert"} ${config.stylix.image} $out
|
{
|
||||||
'';
|
cfg,
|
||||||
in
|
image,
|
||||||
{
|
imageScalingMode,
|
||||||
wayland.windowManager.wayfire.settings = lib.mkIf wayfireConfig.enable {
|
}:
|
||||||
cube = {
|
let
|
||||||
background = rgb colors.base00;
|
wayfireBackground = pkgs.runCommand "wayfire-background.png" { } ''
|
||||||
cubemap_image = lib.mkIf cfg.useWallpaper (toString wayfireBackground);
|
${lib.getExe' pkgs.imagemagick "convert"} ${image} $out
|
||||||
skydome_texture = lib.mkIf cfg.useWallpaper (toString wayfireBackground);
|
'';
|
||||||
};
|
in
|
||||||
|
{
|
||||||
expo.background = rgb colors.base00;
|
wayland.windowManager.wayfire.wf-shell.settings = {
|
||||||
vswitch.background = rgb colors.base00;
|
background.image = lib.mkIf cfg.useWallpaper (toString wayfireBackground);
|
||||||
vswipe.background = rgb colors.base00;
|
cube = {
|
||||||
core.background_color = rgb colors.base00;
|
cubemap_image = lib.mkIf cfg.useWallpaper (toString wayfireBackground);
|
||||||
|
skydome_texture = lib.mkIf cfg.useWallpaper (toString wayfireBackground);
|
||||||
decoration = {
|
|
||||||
font = "${config.stylix.fonts.monospace.name} ${toString config.stylix.fonts.sizes.desktop}";
|
|
||||||
active_color = rgb colors.base0D;
|
|
||||||
inactive_color = rgb colors.base03;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
wayland.windowManager.wayfire.wf-shell.settings =
|
|
||||||
lib.mkIf wayfireConfig.wf-shell.enable
|
|
||||||
{
|
|
||||||
background.image = lib.mkIf cfg.useWallpaper (toString wayfireBackground);
|
|
||||||
background.fill_mode =
|
|
||||||
if config.stylix.imageScalingMode == "stretch" then
|
|
||||||
"stretch"
|
|
||||||
else if config.stylix.imageScalingMode == "fit" then
|
|
||||||
"preserve_aspect"
|
|
||||||
else
|
|
||||||
"fill_and_crop";
|
|
||||||
|
|
||||||
panel.background_color = rgb colors.base01;
|
|
||||||
panel.menu_icon = "${pkgs.nixos-icons}/share/icons/hicolor/256x256/apps/nix-snowflake.png";
|
|
||||||
};
|
};
|
||||||
}
|
background.fill_mode =
|
||||||
);
|
if imageScalingMode == "stretch" then
|
||||||
|
"stretch"
|
||||||
|
else if imageScalingMode == "fit" then
|
||||||
|
"preserve_aspect"
|
||||||
|
else
|
||||||
|
"fill_and_crop";
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
(lib.mkIf config.stylix.targets.nixos-icons.enable {
|
||||||
|
wayland.windowManager.wayfire.wf-shell.settings.panel.menu_icon =
|
||||||
|
"${pkgs.nixos-icons}/share/icons/hicolor/256x256/apps/nix-snowflake.png";
|
||||||
|
})
|
||||||
|
(
|
||||||
|
{ colors }:
|
||||||
|
let
|
||||||
|
rgba = rgb: a: "\\#${rgb}${a}";
|
||||||
|
rgb = (lib.flip rgba) "ff";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
wayland.windowManager.wayfire = {
|
||||||
|
settings = {
|
||||||
|
cube = {
|
||||||
|
background = rgb colors.base00;
|
||||||
|
};
|
||||||
|
|
||||||
|
expo.background = rgb colors.base00;
|
||||||
|
vswitch.background = rgb colors.base00;
|
||||||
|
vswipe.background = rgb colors.base00;
|
||||||
|
core.background_color = rgb colors.base00;
|
||||||
|
|
||||||
|
decoration = {
|
||||||
|
active_color = rgb colors.base0D;
|
||||||
|
inactive_color = rgb colors.base03;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
wf-shell.settings = {
|
||||||
|
panel.background_color = rgb colors.base01;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,35 @@
|
||||||
{ config, lib, ... }:
|
{ mkTarget, lib, ... }:
|
||||||
let
|
mkTarget {
|
||||||
cfg = config.stylix.targets.wayprompt;
|
name = "wayprompt";
|
||||||
|
humanName = "Wayprompt";
|
||||||
|
|
||||||
opacity = lib.toHexString (builtins.ceil (config.stylix.opacity.popups * 255));
|
configElements =
|
||||||
in
|
{ colors, opacity }:
|
||||||
{
|
let
|
||||||
options.stylix.targets.wayprompt.enable =
|
opacity' = lib.toHexString (builtins.ceil (opacity.popups * 255));
|
||||||
config.lib.stylix.mkEnableTarget "Wayprompt" true;
|
in
|
||||||
|
{
|
||||||
|
programs.wayprompt.settings.colours = with colors; {
|
||||||
|
background = "${base00-hex}${opacity'}";
|
||||||
|
border = base0D;
|
||||||
|
text = base05;
|
||||||
|
error-text = base08;
|
||||||
|
|
||||||
config = lib.mkIf (config.stylix.enable && cfg.enable) {
|
pin-background = base01;
|
||||||
programs.wayprompt.settings.colours = with config.lib.stylix.colors; {
|
pin-border = base05;
|
||||||
background = "${base00-hex}${opacity}";
|
pin-square = base05;
|
||||||
border = base0D;
|
|
||||||
text = base05;
|
|
||||||
error-text = base08;
|
|
||||||
|
|
||||||
pin-background = base01;
|
ok-button = green;
|
||||||
pin-border = base05;
|
ok-button-border = green;
|
||||||
pin-square = base05;
|
ok-button-text = base00;
|
||||||
|
|
||||||
ok-button = green;
|
not-ok-button = yellow;
|
||||||
ok-button-border = green;
|
not-ok-button-border = yellow;
|
||||||
ok-button-text = base00;
|
not-ok-button-text = base00;
|
||||||
|
|
||||||
not-ok-button = yellow;
|
cancel-button = red;
|
||||||
not-ok-button-border = yellow;
|
cancel-button-border = red;
|
||||||
not-ok-button-text = base00;
|
cancel-button-text = base00;
|
||||||
|
};
|
||||||
cancel-button = red;
|
|
||||||
cancel-button-border = red;
|
|
||||||
cancel-button-text = base00;
|
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue