Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 80 additions & 74 deletions modules/emacs/hm.nix
Comment thread
0xda157 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,83 +1,89 @@
{
pkgs,
config,
lib,
...
}:
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;
{ mkTarget, pkgs, ... }:
mkTarget {
name = "emacs";
humanName = "Emacs";

config = lib.mkIf (config.stylix.enable && config.stylix.targets.emacs.enable) {
programs.emacs = {
extraPackages = epkgs: [
(epkgs.trivialBuild (
with config.lib.stylix.colors.withHashtag;
{
pname = "base16-stylix-theme";
version = "0.1.0";
src = pkgs.writeText "base16-stylix-theme.el" ''
(require 'base16-theme)
configElements = [
(
{ opacity }:
{
programs.emacs.extraConfig = ''
(add-to-list 'default-frame-alist '(alpha-background . ${
toString (builtins.ceil (opacity.applications * 100))
}))
'';
}
)
(
{ 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
'(: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.")
extraPackages = epkgs: [
(epkgs.trivialBuild (
with colors.withHashtag;
{
pname = "base16-stylix-theme";
version = "0.1.0";
src = pkgs.writeText "base16-stylix-theme.el" ''
(require 'base16-theme)

;; Define the theme
(deftheme base16-stylix)
(defvar base16-stylix-theme-colors
'(: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
(base16-theme-define 'base16-stylix base16-stylix-theme-colors)
;; Define the theme
(deftheme base16-stylix)

;; Mark the theme as provided
(provide-theme 'base16-stylix)
;; Add all the faces to the theme
(base16-theme-define 'base16-stylix base16-stylix-theme-colors)

;; Add path to theme to theme-path
(add-to-list 'custom-theme-load-path
(file-name-directory
(file-truename load-file-name)))
;; Mark the theme as provided
(provide-theme 'base16-stylix)

(provide 'base16-stylix-theme)
'';
packageRequires = [ epkgs.base16-theme ];
}
))
];
;; Add path to theme to theme-path
(add-to-list 'custom-theme-load-path
(file-name-directory
(file-truename load-file-name)))

extraConfig = ''
;; ---- Generated by stylix ----
(require 'base16-stylix-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}))
;; -----------------------------
'';
};
};
(provide 'base16-stylix-theme)
'';
packageRequires = [ epkgs.base16-theme ];
}
))
];
};
}
)
];
}
21 changes: 11 additions & 10 deletions modules/eog/hm.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{ config, lib, ... }:
{ mkTarget, ... }:
mkTarget {
name = "eog";
humanName = "Eye of GNOME Image Viewer";

{
options.stylix.targets.eog.enable =
config.lib.stylix.mkEnableTarget "Eye of GNOME Image Viewer" true;

config = lib.mkIf (config.stylix.enable && config.stylix.targets.eog.enable) {
dconf.settings."org/gnome/eog/view" = {
# transparency = "background"; # Disables the grey and white check pattern.
background-color = "#${config.lib.stylix.colors.base00}";
configElements =
{ colors }:
{
dconf.settings."org/gnome/eog/view" = {
# transparency = "background"; # Disables the grey and white check pattern.
background-color = "#${colors.base00}";
};
};
};
}
35 changes: 14 additions & 21 deletions modules/feh/nixos.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
{
mkTarget,
lib,
pkgs,
config,
lib,
...
}:
let
cfg = config.stylix.targets.feh;
in
{
options.stylix.targets.feh = {
enable = config.lib.stylix.mkEnableTarget "the desktop background using Feh" (
config.stylix.image != null
);
};
mkTarget {
name = "feh";
humanName = "the desktop background using Feh";
autoEnable =
with config.services.xserver.windowManager;
xmonad.enable || i3.enable;

config.services.xserver.displayManager.sessionCommands =
lib.mkIf
(
config.stylix.enable
&& cfg.enable
&& (with config.services.xserver.windowManager; xmonad.enable || i3.enable)
)
(
configElements =
{ image, imageScalingMode }:
{
services.xserver.displayManager.sessionCommands =
let
inherit (config.stylix) imageScalingMode;
bg-arg =
if imageScalingMode == "fill" then
"--bg-fill"
Expand All @@ -37,6 +30,6 @@ in
else
"--bg-max";
in
"${lib.getExe pkgs.feh} --no-fehbg ${bg-arg} ${config.stylix.image}"
);
"${lib.getExe pkgs.feh} --no-fehbg ${bg-arg} ${image}";
};
}
121 changes: 61 additions & 60 deletions modules/vim/hm.nix
Comment thread
0xda157 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,69 +1,70 @@
{
pkgs,
config,
mkTarget,
lib,
pkgs,
...
}:
mkTarget {
name = "vim";
humanName = "Vim";

let
themeFile = config.lib.stylix.colors {
templateRepo = config.stylix.inputs.base16-vim;
target = "base16";
};

themePlugin = pkgs.vimUtils.buildVimPlugin {
name = "stylix";
pname = "stylix";

src = themeFile;
dontUnpack = true;
configElements = [
(
{ fonts }:
{
programs.vim.extraConfig = ''
set guifont=${
lib.escape [ " " ] fonts.monospace.name
}:h${toString fonts.sizes.terminal}
'';
}
)
(
{ colors, inputs }:
{
programs.vim = {
plugins = [
Comment thread
0xda157 marked this conversation as resolved.
(pkgs.vimUtils.buildVimPlugin {
name = "stylix";
pname = "stylix";

buildPhase = ''
install -D $src $out/colors/base16-stylix.vim
'';
};
src = colors {
templateRepo = inputs.base16-vim;
target = "base16";
};
dontUnpack = true;

vimOptions =
let
inherit (config.stylix) fonts;
in
{
plugins = [ themePlugin ];
extraConfig = with config.lib.stylix.colors.withHashtag; ''
set termguicolors
colorscheme base16-stylix
unlet g:colors_name

let g:stylix_colors = {
\ '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;
buildPhase = ''
install -D $src $out/colors/base16-stylix.vim
'';
})
];
extraConfig = with colors.withHashtag; ''
set termguicolors
colorscheme base16-stylix
unlet g:colors_name

config = lib.mkIf (config.stylix.enable && config.stylix.targets.vim.enable) {
programs.vim = vimOptions;
};
let g:stylix_colors = {
\ '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}',
\ }
'';
};
}
)
];
}
Loading