functional update

This commit is contained in:
Dmitriy Kholkin 2020-08-09 21:30:32 +04:00
parent 792cc98d99
commit 6980dd922b
Signed by: AtaraxiaDev
GPG Key ID: FD266B810DF48DF2
5 changed files with 82 additions and 165 deletions

View File

@ -1,84 +1,68 @@
# Base16 themes for home manager
This is a fork of [atpotts/base16-nix](https://github.com/atpotts/base16-nix)
This is a fork of [lukebfox/base16-nix](https://github.com/lukebfox/base16-nix)
Differences:
- Exports the home manager module as a flake output.
- Restricts scope to official base16-themes.
- Prefers the colors-only mustache template if supported, as usually I prefer to
do my own customisation.
## Usage
- Returns support for obtaining color values from the color scheme
- Removed unused files
## Usage
import this flake in your 'flake.nix':
```nix
inputs.base16.url = 'github:lukebfox/base16-nix';
inputs.base16.url = 'github:alukardbf/base16-nix';
```
then, in any home-manager configuration:
```nix
home.user.${user} = {config,pkgs,lib}:{
home.user.${user} = { config, pkgs, lib }: {
imports = [ base16.hmModule ];
}
```
```nix
{pkgs, lib, config, ...}:
{ pkgs, lib, config, ...}:
{
imports = [ ./base16.nix ];
config = {
# Choose your themee
# Choose your theme
themes.base16 = {
enable = true;
scheme = "solarized";
variant = "solarized-dark";
# Add extra variables for inclusion in custom templates
extraParams = {
fontname = mkDefault "Inconsolata LGC for Powerline";
headerfontname = mkDefault "Cabin";
bodysize = mkDefault "10";
headersize = mkDefault "12";
xdpi= mkDefault ''
Xft.hintstyle: hintfull
'';
};
fontName = mkDefault "Roboto";
fontSize = mkDefault "12";
};
};
# 1. Use pre-provided templates
###############################
programs.bash.initExtra = ''
source ${config.lib.base16.base16template "shell"}
source ${config.base16.templateFile "shell"}
'';
home.file.".vim/colors/mycolorscheme.vim".source =
config.lib.base16.base16template "vim";
config.base16.templateFile "vim";
# 2. Use your own templates
###########################
home.file.".Xresources".source = config.lib.base16.template {
src = ./examples/Xresources;
};
home.file.".xmonad/xmobarrc".source = config.lib.base16.template {
src = ./examples/xmobarrc;
};
# 3. Template strings directly into other home-manager configuration
# 2. Template strings directly into other home-manager configuration
####################################################################
services.dunst = {
enable = true;
settings = with config.lib.base16.theme;
settings = with config.base16.theme;
{
global = {
geometry = "600x1-800+-3";
font = "${headerfontname} ${headersize}";
icon_path =
config.services.dunst.settings.global.icon_folders;
alignment = "right";
font = "${fontName} ${fontSize}";
frame_width = 0;
separator_height = 0;
sort = true;
@ -98,30 +82,37 @@ home.user.${user} = {config,pkgs,lib}:{
};
};
};
};
}
```
## Reloading
Changing themes involves switching the theme definitoin and typing
Changing themes involves switching the theme definition and typing
`home-manager switch`. There is no attempt in general to force programs to
reload, and not all are able to reload their configs, although I have found
that reloading xmonad and occasionally restarting applications has been
enough.
You are unlikely to achieve a complet switch without logging out and logging back
You are unlikely to achieve a complete switch without logging out and logging back
in again.
## Todo
Provide better support for custom schemes (currently this assumes you'll
want to use something in the base16 repositories, but there is no reason
for this).
Provide better support for custom schemes (currently it
is assumed that you'll use something in base16
repositories, but there is no reason to).
## Updating Sources
`cd` into the directory in which the templates.yaml and schemes.yaml are
located, and run update_sources.sh
If you're using nix flakes:
- Fork this repository
- `cd` into repository dir
- Enter `nix develop` and then run `update-base16`
- Commit and push new files
If you're **not** using nix flakes:
- `cd` into repository dir
- Run `update_sources.sh`

View File

@ -18,12 +18,12 @@ let
# if one exists, as I generally prefer to do my own customisations.
# Returns the nix store path of the file.
mkTemplate = name:
let
templateDir = "${pkgs.fetchgit (templates."${name}")}/templates";
let
templateDir = "${pkgs.fetchgit (templates."${name}")}/templates";
in
if pathExists (templateDir + "/colors.mustache")
then templateDir + "/colors.mustache"
else templateDir + "/default.mustache";
if pathExists (templateDir + "/colors.mustache")
then templateDir + "/colors.mustache"
else templateDir + "/default.mustache";
# The theme yaml files only supply 16 hex values, but the templates take
# a transformation of this data such as rgb. The hacky python script pre-
@ -32,13 +32,13 @@ let
python = pkgs.python.withPackages (ps: [ ps.pyyaml ]);
preprocess = src:
pkgs.stdenv.mkDerivation {
name = "placeholder-change-me";
name = "yaml";
inherit src;
builder = pkgs.writeText "builder.sh" ''
slug_all=$(${pkgs.coreutils}/bin/basename $src)
slug=''${slug_all%.*}
${python}/bin/python ${./base16writer.py} $slug < $src > $out
'';
slug_all=$(${pkgs.coreutils}/bin/basename $src)
slug=''${slug_all%.*}
${python}/bin/python ${./base16writer.py} $slug < $src > $out
'';
allowSubstitutes = false; # will never be in cache
};
@ -54,24 +54,28 @@ let
allowSubstitutes = false; # will never be in cache
};
schemeJSON = scheme: variant:
importJSON (preprocess (mkTheme scheme variant));
in
{
options = {
themes.base16.enable = mkEnableOption "Base 16 Color Schemes";
themes.base16.scheme = mkOption {
type=types.str;
default="tomorrow";
type = types.str;
default = "solarized";
};
themes.base16.variant = mkOption {
type=types.str;
default="tomorrow";
type = types.str;
default = "solarized-dark";
};
themes.base16.tone = mkOption {
type=types.str;
default="light";
themes.base16.extraParams = mkOption {
type = types.attrsOf types.str;
default = {};
};
};
config = {
lib.base16.base16template = mustache cfg.scheme cfg.variant;
lib.base16.theme = schemeJSON cfg.scheme cfg.variant // cfg.extraParams;
lib.base16.templateFile = mustache cfg.scheme cfg.variant;
};
}

View File

@ -1,50 +0,0 @@
{{xdpi}}
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
Xft.font: xft:{{headerfontname}}:size={{headersize}},xft:Symbola:size={{headersize}}
#define All_font xft:{{fontname}}:size={{bodysize}},xft:Symbola:size={{bodysize}}
URxvt.font: All_font
URxvt.scrollBar: false
URxvt.transparent: false
URxvt.borderLess: false
URxvt.saveLines: 2000
*color0: #{{base00}}
*color1: #{{base08}}
*color2: #{{base0B}}
*color3: #{{base0A}}
*color4: #{{base0D}}
*color5: #{{base0E}}
*color6: #{{base0C}}
*color7: #{{base05}}
*color8: #{{base03}}
*color9: #{{base08}}
*color10: #{{base0B}}
*color11: #{{base0A}}
*color12: #{{base0D}}
*color13: #{{base0E}}
*color14: #{{base0C}}
*color15: #{{base07}}
*color16: #{{base09}}
*color17: #{{base0F}}
*color18: #{{base01}}
*color19: #{{base02}}
*color20: #{{base04}}
*color21: #{{base06}}
*foreground: #{{base05}}
*background: #{{base00}}
*fadeColor: #{{base07}}
*cursorColor: #{{base01}}
*pointerColorBackground: #{{base01}}
*pointerColorForeground: #{{base06}}
dzen2.font : All_font
dzen2.foreground: S_base3
dzen2.background: S_base01

View File

@ -1,28 +0,0 @@
Config
{ font = "xft:{{headerfontname}}:size={{headersize}},Meslo LG L DZ:size={{headersize}}"
, bgColor = "#{{base01}}"
, fgColor = "#{{base03}}"
, position = Top L 100
, commands = [ Run Cpu ["-t","<total>⚙","-L","30","-H","70","--low","#{{base05}}","--normal","#{{base0A}}","--high","#cb4b16"] 10
, Run Memory ["-t","<usedratio>Ξ"] 10
, Run Battery ["-t","<left><acstatus> <timeleft>",
"-L","30",
"-H","80",
"--low","#{{base08}},#{{base00}}",
"--normal","#{{base0A}},#{{base00}}",
"--high","#{{base05}},#{{base00}}",
"--",
"-O","↑",
"-o","↓",
"-i","~"
] 100
, Run Date "%a %b %_d %Y %H:%M" "date" 100
, Run StdinReader
]
, sepChar = "%"
, alignSep = "}{"
, template = "%StdinReader% }{ <action=`urxvt -e top`> %cpu% %memory% </action><fc=#{{base02}},#{{base00}}> %battery% </fc> <fc=#{{base02}}>%date%</fc> %EGLC% "
, persistent = True
, lowerOnStart = True
, hideOnStart = False
}

View File

@ -1,24 +1,24 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash curl nix-prefetch-git gnused jq
# Run from within the directory which needs the templates.json/schemes.json
# Not very safe - should be cleaner & could be more parallel
# should always be permitted to run to completion
generate_sources () {
out=$1
curl "https://raw.githubusercontent.com/chriskempson/base16-${out}-source/master/list.yaml"\
| sed -nE "s~^([-_[:alnum:]]+): *(.*)~\1 \2~p"\
| while read name src; do
echo "{\"key\":\"$name\",\"value\":"
nix-prefetch-git $src
echo "}"
done\
| jq -s ".|del(.[].value.date)|from_entries"\
> $out.json
}
generate_sources templates &
generate_sources schemes &
wait
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash curl nix-prefetch-git gnused jq
# Run from within the directory which needs the templates.json/schemes.json
# Not very safe - should be cleaner & could be more parallel
# should always be permitted to run to completion
generate_sources () {
out=$1
curl "https://raw.githubusercontent.com/chriskempson/base16-${out}-source/master/list.yaml"\
| sed -nE "s~^([-_[:alnum:]]+): *(.*)~\1 \2~p"\
| while read name src; do
echo "{\"key\":\"$name\",\"value\":"
nix-prefetch-git $src
echo "}"
done\
| jq -s ".|del(.[].value.date)|from_entries"\
> $out.json
}
generate_sources templates &
generate_sources schemes &
wait