custom schemes
This commit is contained in:
parent
7039e397b2
commit
8eaa7ac1cb
62
README.md
62
README.md
@ -6,6 +6,7 @@ Differences:
|
|||||||
|
|
||||||
- Returns support for obtaining color values from the color scheme
|
- Returns support for obtaining color values from the color scheme
|
||||||
- Added possibility to select a template type (`'default'`, `'color'`, etc)
|
- Added possibility to select a template type (`'default'`, `'color'`, etc)
|
||||||
|
- Added possibility to use custom schemes by importing local files or remote repository
|
||||||
- Removed unused files
|
- Removed unused files
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -90,6 +91,57 @@ home.user.${user} = { config, pkgs, lib }: {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also use local schemes:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, lib, config, ...}:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
# Choose your theme
|
||||||
|
themes.base16 = {
|
||||||
|
enable = true;
|
||||||
|
customScheme = {
|
||||||
|
enable = true;
|
||||||
|
path = ./base16-custom-scheme.yaml;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Or use an imported color scheme:
|
||||||
|
|
||||||
|
For example, import scheme repository into yours 'flake.nix'
|
||||||
|
|
||||||
|
```nix
|
||||||
|
inputs.base16-horizon-scheme = {
|
||||||
|
url = github:michael-ball/base16-horizon-scheme;
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, lib, config, inputs, ...}:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
# Choose your theme
|
||||||
|
themes.base16 = {
|
||||||
|
enable = true;
|
||||||
|
customScheme = {
|
||||||
|
enable = true;
|
||||||
|
path = "${inputs.base16-horizon-scheme}/horizon-dark.yaml";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
# The template will be generated from the local scheme
|
||||||
|
programs.rofi = {
|
||||||
|
enable = true;
|
||||||
|
theme = "${config.lib.base16.templateFile { name = "rofi"; };}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Reloading
|
## Reloading
|
||||||
|
|
||||||
Changing themes involves switching the theme definition and typing
|
Changing themes involves switching the theme definition and typing
|
||||||
@ -101,12 +153,6 @@ enough.
|
|||||||
You are unlikely to achieve a complete switch without logging out and logging back
|
You are unlikely to achieve a complete switch without logging out and logging back
|
||||||
in again.
|
in again.
|
||||||
|
|
||||||
## Todo
|
|
||||||
|
|
||||||
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
|
## Updating Sources
|
||||||
|
|
||||||
If you're using nix flakes:
|
If you're using nix flakes:
|
||||||
@ -120,3 +166,7 @@ If you're **not** using nix flakes:
|
|||||||
|
|
||||||
- `cd` into repository dir
|
- `cd` into repository dir
|
||||||
- Run `update_sources.sh`
|
- Run `update_sources.sh`
|
||||||
|
|
||||||
|
## Todo
|
||||||
|
|
||||||
|
Improve the source code.
|
||||||
|
68
base16.nix
68
base16.nix
@ -53,34 +53,64 @@ let
|
|||||||
allowSubstitutes = false; # will never be in cache
|
allowSubstitutes = false; # will never be in cache
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mustacheCustom = schemePath: name: type:
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
name = "${name}-base16-scheme";
|
||||||
|
data = preprocess schemePath;
|
||||||
|
src = mkTemplate name type;
|
||||||
|
phases = [ "buildPhase" ];
|
||||||
|
buildPhase ="${pkgs.mustache-go}/bin/mustache $data $src > $out";
|
||||||
|
allowSubstitutes = false; # will never be in cache
|
||||||
|
};
|
||||||
|
|
||||||
schemeJSON = scheme: variant:
|
schemeJSON = scheme: variant:
|
||||||
importJSON (preprocess (mkTheme scheme variant));
|
importJSON (preprocess (mkTheme scheme variant));
|
||||||
|
|
||||||
|
schemeJSONCustom = schemePath:
|
||||||
|
importJSON (preprocess schemePath);
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = with types; {
|
||||||
themes.base16.enable = mkEnableOption "Base 16 Color Schemes";
|
themes.base16 = {
|
||||||
themes.base16.scheme = mkOption {
|
enable = mkEnableOption "Base 16 Color Schemes";
|
||||||
type = types.str;
|
customScheme = {
|
||||||
default = "solarized";
|
enable = mkEnableOption "Use custom scheme instead of remote repository";
|
||||||
};
|
path = mkOption {
|
||||||
themes.base16.variant = mkOption {
|
type = nullOr path;
|
||||||
type = types.str;
|
default = null;
|
||||||
default = "solarized-dark";
|
};
|
||||||
};
|
};
|
||||||
themes.base16.extraParams = mkOption {
|
scheme = mkOption {
|
||||||
type = types.attrsOf types.str;
|
type = str;
|
||||||
default = {};
|
default = "solarized";
|
||||||
};
|
};
|
||||||
themes.base16.defaultTemplateType = mkOption {
|
variant = mkOption {
|
||||||
type = types.str;
|
type = str;
|
||||||
default = "default";
|
default = "solarized-dark";
|
||||||
example = "colors";
|
};
|
||||||
|
extraParams = mkOption {
|
||||||
|
type = attrsOf str;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
defaultTemplateType = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "default";
|
||||||
|
example = "colors";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
lib.base16.theme = schemeJSON cfg.scheme cfg.variant // cfg.extraParams;
|
lib.base16.theme =
|
||||||
|
if cfg.customScheme.enable then
|
||||||
|
schemeJSONCustom cfg.customScheme.path // cfg.extraParams
|
||||||
|
else
|
||||||
|
schemeJSON cfg.scheme cfg.variant // cfg.extraParams;
|
||||||
|
|
||||||
lib.base16.templateFile = { name, type ? cfg.defaultTemplateType, ... }:
|
lib.base16.templateFile = { name, type ? cfg.defaultTemplateType, ... }:
|
||||||
|
if cfg.customScheme.enable then
|
||||||
|
mustacheCustom cfg.customScheme.path name type
|
||||||
|
else
|
||||||
mustache cfg.scheme cfg.variant name type;
|
mustache cfg.scheme cfg.variant name type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user