base16-nix/README.md

173 lines
4.2 KiB
Markdown
Raw Permalink Normal View History

2019-02-17 10:29:11 +00:00
# Base16 themes for home manager
2020-08-09 21:30:32 +04:00
This is a fork of [lukebfox/base16-nix](https://github.com/lukebfox/base16-nix)
2019-02-17 10:29:11 +00:00
2020-07-20 20:41:02 +01:00
Differences:
2019-02-17 10:29:11 +00:00
2020-08-09 21:30:32 +04:00
- Returns support for obtaining color values from the color scheme
2020-08-10 00:51:23 +04:00
- Added possibility to select a template type (`'default'`, `'color'`, etc)
2020-08-10 18:58:49 +04:00
- Added possibility to use custom schemes by importing local files or remote repository
2020-08-09 21:30:32 +04:00
- Removed unused files
## Usage
2020-07-20 20:41:02 +01:00
import this flake in your 'flake.nix':
2020-08-09 21:30:32 +04:00
2020-07-20 20:41:02 +01:00
```nix
2021-09-27 22:35:31 +03:00
inputs.base16.url = "github:alukardbf/base16-nix";
2020-07-20 20:41:02 +01:00
```
2020-08-09 21:30:32 +04:00
2020-07-20 20:41:02 +01:00
then, in any home-manager configuration:
2020-08-09 21:30:32 +04:00
2020-07-20 20:41:02 +01:00
```nix
2020-08-09 21:30:32 +04:00
home.user.${user} = { config, pkgs, lib }: {
2020-07-20 20:41:02 +01:00
imports = [ base16.hmModule ];
2021-09-27 22:35:31 +03:00
};
2020-07-20 20:41:02 +01:00
```
2019-02-17 10:29:11 +00:00
```nix
2020-08-09 21:30:32 +04:00
{ pkgs, lib, config, ...}:
2019-02-17 10:29:11 +00:00
{
2019-02-17 10:32:56 +00:00
config = {
2019-02-17 10:29:11 +00:00
2020-08-09 21:30:32 +04:00
# Choose your theme
2019-02-17 10:29:11 +00:00
themes.base16 = {
enable = true;
scheme = "solarized";
variant = "solarized-dark";
2020-08-10 00:51:23 +04:00
defaultTemplateType = "default";
2019-02-17 10:29:11 +00:00
# Add extra variables for inclusion in custom templates
extraParams = {
2020-08-10 00:51:23 +04:00
fontName = "Roboto Mono";
fontSize = "12";
2020-08-09 21:30:32 +04:00
};
2019-02-17 10:29:11 +00:00
};
# 1. Use pre-provided templates
###############################
programs.bash.initExtra = ''
2021-09-27 22:35:31 +03:00
source ${config.lib.base16.templateFile { name = "shell"; }}
2019-02-17 10:29:11 +00:00
'';
2020-08-10 00:51:23 +04:00
programs.rofi = {
enable = true;
2021-09-27 22:35:31 +03:00
theme = "${config.lib.base16.templateFile { name = "rofi"; type = "colors"; }}";
2020-08-10 00:51:23 +04:00
};
2019-02-17 10:29:11 +00:00
2020-08-09 21:30:32 +04:00
# 2. Template strings directly into other home-manager configuration
2019-02-17 10:29:11 +00:00
####################################################################
services.dunst = {
enable = true;
2020-08-10 00:51:23 +04:00
settings = with config.lib.base16.theme;
2019-02-17 10:29:11 +00:00
{
global = {
geometry = "600x1-800+-3";
icon_path =
config.services.dunst.settings.global.icon_folders;
alignment = "right";
2020-08-09 21:30:32 +04:00
font = "${fontName} ${fontSize}";
2019-02-17 10:29:11 +00:00
frame_width = 0;
separator_height = 0;
sort = true;
};
urgency_low = {
background = "#${base01-hex}";
foreground = "#${base03-hex}";
};
urgency_normal = {
background = "#${base01-hex}";
foreground = "#${base05-hex}";
};
urgency_critical = {
msg_urgency = "CRITICAL";
background = "#${base01-hex}";
foreground = "#${base08-hex}";
};
};
};
};
}
```
2020-08-10 18:58:49 +04:00
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;
2021-09-27 22:35:31 +03:00
};
2020-08-10 18:58:49 +04:00
};
};
}
```
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";
2021-09-27 22:35:31 +03:00
};
2020-08-10 18:58:49 +04:00
};
# The template will be generated from the local scheme
programs.rofi = {
enable = true;
2021-09-27 22:35:31 +03:00
theme = "${config.lib.base16.templateFile { name = "rofi"; }}";
2020-08-10 18:58:49 +04:00
};
};
}
```
2019-02-17 10:29:11 +00:00
## Reloading
2020-08-09 21:30:32 +04:00
Changing themes involves switching the theme definition and typing
2019-02-17 10:29:11 +00:00
`home-manager switch`. There is no attempt in general to force programs to
2021-09-27 22:35:31 +03:00
reload, and not all are able to reload their configs, although occasionally restarting applications has been enough.
2019-02-17 10:29:11 +00:00
2020-08-09 21:30:32 +04:00
You are unlikely to achieve a complete switch without logging out and logging back
2019-02-17 10:29:11 +00:00
in again.
2021-09-27 22:35:31 +03:00
Also, if you use home-manager as a module in the system configuration, the switch should be done with the command `nixos-rebuild switch`.
2019-02-17 10:29:11 +00:00
## Updating Sources
2020-08-09 21:30:32 +04:00
If you're using nix flakes:
- Fork this repository
- `cd` into repository dir
2021-09-27 22:35:31 +03:00
- Enter `nix develop` and then run `update-base16` OR
- Enter `nix run .`
2020-08-09 21:30:32 +04:00
- Commit and push new files
If you're **not** using nix flakes:
- `cd` into repository dir
- Run `update_sources.sh`
2020-08-10 18:58:49 +04:00
## Todo
Improve the source code.