select template type
This commit is contained in:
parent
6980dd922b
commit
7039e397b2
16
README.md
16
README.md
@ -5,6 +5,7 @@ This is a fork of [lukebfox/base16-nix](https://github.com/lukebfox/base16-nix)
|
||||
Differences:
|
||||
|
||||
- Returns support for obtaining color values from the color scheme
|
||||
- Added possibility to select a template type (`'default'`, `'color'`, etc)
|
||||
- Removed unused files
|
||||
|
||||
## Usage
|
||||
@ -34,10 +35,11 @@ home.user.${user} = { config, pkgs, lib }: {
|
||||
enable = true;
|
||||
scheme = "solarized";
|
||||
variant = "solarized-dark";
|
||||
defaultTemplateType = "default";
|
||||
# Add extra variables for inclusion in custom templates
|
||||
extraParams = {
|
||||
fontName = mkDefault "Roboto";
|
||||
fontSize = mkDefault "12";
|
||||
fontName = "Roboto Mono";
|
||||
fontSize = "12";
|
||||
};
|
||||
};
|
||||
|
||||
@ -45,17 +47,19 @@ home.user.${user} = { config, pkgs, lib }: {
|
||||
###############################
|
||||
|
||||
programs.bash.initExtra = ''
|
||||
source ${config.base16.templateFile "shell"}
|
||||
source ${config.lib.base16.templateFile { name = "shell"; };}
|
||||
'';
|
||||
home.file.".vim/colors/mycolorscheme.vim".source =
|
||||
config.base16.templateFile "vim";
|
||||
programs.rofi = {
|
||||
enable = true;
|
||||
theme = "${config.lib.base16.templateFile { name = "rofi"; type = "color"; };}";
|
||||
};
|
||||
|
||||
# 2. Template strings directly into other home-manager configuration
|
||||
####################################################################
|
||||
|
||||
services.dunst = {
|
||||
enable = true;
|
||||
settings = with config.base16.theme;
|
||||
settings = with config.lib.base16.theme;
|
||||
{
|
||||
global = {
|
||||
geometry = "600x1-800+-3";
|
||||
|
21
base16.nix
21
base16.nix
@ -14,15 +14,14 @@ let
|
||||
mkTheme = scheme: variant:
|
||||
"${pkgs.fetchgit (schemes."${scheme}")}/${variant}.yaml";
|
||||
|
||||
# Source file for a given base16 template. Use the colors-only template
|
||||
# if one exists, as I generally prefer to do my own customisations.
|
||||
# Source file for a given base16 template.
|
||||
# Returns the nix store path of the file.
|
||||
mkTemplate = name:
|
||||
mkTemplate = name: type:
|
||||
let
|
||||
templateDir = "${pkgs.fetchgit (templates."${name}")}/templates";
|
||||
in
|
||||
if pathExists (templateDir + "/colors.mustache")
|
||||
then templateDir + "/colors.mustache"
|
||||
if pathExists (templateDir + "/${type}.mustache")
|
||||
then templateDir + "/${type}.mustache"
|
||||
else templateDir + "/default.mustache";
|
||||
|
||||
# The theme yaml files only supply 16 hex values, but the templates take
|
||||
@ -44,11 +43,11 @@ let
|
||||
|
||||
# Mustache engine. Applies any theme to any template, providing they are
|
||||
# included in the local json source files.
|
||||
mustache = scheme: variant: name:
|
||||
mustache = scheme: variant: name: type:
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "${name}-base16-${variant}";
|
||||
data = preprocess (mkTheme scheme variant);
|
||||
src = mkTemplate name;
|
||||
src = mkTemplate name type;
|
||||
phases = [ "buildPhase" ];
|
||||
buildPhase ="${pkgs.mustache-go}/bin/mustache $data $src > $out";
|
||||
allowSubstitutes = false; # will never be in cache
|
||||
@ -73,9 +72,15 @@ in
|
||||
type = types.attrsOf types.str;
|
||||
default = {};
|
||||
};
|
||||
themes.base16.defaultTemplateType = mkOption {
|
||||
type = types.str;
|
||||
default = "default";
|
||||
example = "colors";
|
||||
};
|
||||
};
|
||||
config = {
|
||||
lib.base16.theme = schemeJSON cfg.scheme cfg.variant // cfg.extraParams;
|
||||
lib.base16.templateFile = mustache cfg.scheme cfg.variant;
|
||||
lib.base16.templateFile = { name, type ? cfg.defaultTemplateType, ... }:
|
||||
mustache cfg.scheme cfg.variant name type;
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user