2020-12-21 15:45:32 +00:00
|
|
|
# Stylix
|
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
Stylix is a NixOS module which applies the same color scheme, font and
|
|
|
|
wallpaper to a wide range of applications and desktop environments.
|
|
|
|
In some cases, theming can be activated as early as the bootloader!
|
2022-05-01 18:15:21 +00:00
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
It also exports utilities for you to apply the theming to custom parts of your
|
|
|
|
configuration.
|
2022-05-01 18:15:21 +00:00
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
Stylix is built using [base16.nix](https://github.com/SenchoPens/base16.nix#readme),
|
|
|
|
a library which handles the generation of config files from templates provided by
|
|
|
|
the [base16](https://github.com/chriskempson/base16#readme) project.
|
2020-12-21 15:45:32 +00:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
You can install Stylix using [Flakes](https://nixos.wiki/wiki/Flakes),
|
|
|
|
for example:
|
2020-12-21 15:45:32 +00:00
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2021-12-17 17:11:19 +00:00
|
|
|
home-manager = {
|
|
|
|
url = "github:nix-community/home-manager";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2020-12-21 15:45:32 +00:00
|
|
|
stylix.url = "github:danth/stylix";
|
|
|
|
};
|
|
|
|
|
2021-12-17 17:11:19 +00:00
|
|
|
outputs = { self, nixpkgs, home-manager, stylix }: {
|
2020-12-21 15:45:32 +00:00
|
|
|
nixosConfigurations."<hostname>" = nixpkgs.lib.nixosSystem {
|
|
|
|
system = "x86_64-linux";
|
2021-12-17 17:11:19 +00:00
|
|
|
modules = [
|
|
|
|
home-manager.nixosModules.home-manager
|
|
|
|
stylix.nixosModules.stylix
|
|
|
|
];
|
2020-12-21 15:45:32 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-12-17 17:11:19 +00:00
|
|
|
Stylix relies on [Home Manager](https://github.com/nix-community/home-manager)
|
2022-07-26 14:39:06 +00:00
|
|
|
for a lot of its work, so that needs to be imported too.
|
|
|
|
|
|
|
|
## Wallpaper
|
2021-12-17 17:11:19 +00:00
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
To get started, you need to set a wallpaper image.
|
2020-12-21 15:45:32 +00:00
|
|
|
|
|
|
|
```nix
|
2022-07-26 14:39:06 +00:00
|
|
|
stylix.image = ./wallpaper.png;
|
|
|
|
```
|
2020-12-21 15:45:32 +00:00
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
The option accepts derivations as well as paths, so you can fetch a wallpaper
|
|
|
|
directly from the internet:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
stylix.image = pkgs.fetchurl {
|
|
|
|
url = "https://www.pixelstalk.net/wp-content/uploads/2016/05/Epic-Anime-Awesome-Wallpapers.jpg";
|
|
|
|
sha256 = "enQo3wqhgf0FEPHj2coOCvo7DuZv+x5rL/WIo4qPI50=";
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
|
|
|
The wallpaper is the only option which is required!
|
|
|
|
|
|
|
|
## Color scheme
|
|
|
|
|
|
|
|
### Automatic color schemes
|
|
|
|
|
2022-09-27 08:33:08 +00:00
|
|
|
If you only set a wallpaper, Stylix will use a
|
2022-07-26 14:39:06 +00:00
|
|
|
[genetic algorithm](https://en.wikipedia.org/wiki/Genetic_algorithm)
|
2022-09-27 08:33:08 +00:00
|
|
|
to choose a color scheme based on it. The quality of these automatically
|
|
|
|
generated schemes can vary, but more colorful images tend to have better
|
|
|
|
results.
|
2020-12-21 15:45:32 +00:00
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
You can force a light or dark theme using the polarity option:
|
2022-06-30 17:17:44 +00:00
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
```nix
|
|
|
|
stylix.polarity = "dark";
|
|
|
|
```
|
|
|
|
|
2022-10-30 13:34:30 +00:00
|
|
|
The generated scheme can be viewed in a web browser at
|
|
|
|
`file:///etc/stylix/palette.html`.
|
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
### Mixed color schemes
|
|
|
|
|
2022-09-27 08:33:08 +00:00
|
|
|
You can override part of the scheme by hand, perhaps to select background
|
|
|
|
and text colors manually while keeping the generated accent colors:
|
2022-07-26 14:39:06 +00:00
|
|
|
|
|
|
|
```nix
|
|
|
|
stylix.palette = {
|
|
|
|
base00 = "000000";
|
|
|
|
# ...
|
|
|
|
base07 = "ffffff";
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
|
|
|
The `baseXX` names correspond to
|
|
|
|
[this table](https://github.com/chriskempson/base16/blob/main/styling.md#styling-guidelines).
|
|
|
|
|
|
|
|
### Manual color schemes
|
|
|
|
|
2023-01-11 23:47:29 +00:00
|
|
|
Alternatively, you can choose a pre-made colorscheme from
|
|
|
|
[the Tinted Theming repository](https://github.com/tinted-theming/base16-schemes).
|
|
|
|
Either add the repository to your Flake inputs, or fetch it as follows:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
let base16-schemes = pkgs.fetchFromGitHub {
|
|
|
|
owner = "tinted-theming";
|
|
|
|
repo = "base16-schemes";
|
|
|
|
rev = "...";
|
|
|
|
sha256 = "...";
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
|
|
|
Then you can choose which file you would like to use:
|
2022-07-26 14:39:06 +00:00
|
|
|
|
|
|
|
```nix
|
|
|
|
stylix.base16Scheme = "${base16-schemes}/gruvbox-dark-hard.yaml";
|
|
|
|
```
|
|
|
|
|
2022-09-27 08:33:08 +00:00
|
|
|
If you want to do anything more complex - such as running your own program to
|
|
|
|
generate the colour scheme - `base16Scheme` can accept any argument which
|
|
|
|
[`mkSchemeAttrs`](https://github.com/SenchoPens/base16.nix/blob/main/DOCUMENTATION.md#mkschemeattrs)
|
|
|
|
supports.
|
2022-07-26 14:39:06 +00:00
|
|
|
|
|
|
|
## Fonts
|
|
|
|
|
|
|
|
The default combination of fonts is:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
stylix.fonts = {
|
|
|
|
serif = {
|
|
|
|
package = pkgs.dejavu_fonts;
|
|
|
|
name = "DejaVu Serif";
|
2022-07-22 16:42:34 +00:00
|
|
|
};
|
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
sansSerif = {
|
|
|
|
package = pkgs.dejavu_fonts;
|
|
|
|
name = "DejaVu Sans";
|
|
|
|
};
|
2022-07-22 16:42:34 +00:00
|
|
|
|
2022-07-26 14:39:06 +00:00
|
|
|
monospace = {
|
|
|
|
package = pkgs.dejavu_fonts;
|
|
|
|
name = "DejaVu Sans Mono";
|
2020-12-21 15:45:32 +00:00
|
|
|
};
|
2022-07-26 14:39:06 +00:00
|
|
|
|
|
|
|
emoji = {
|
|
|
|
package = pkgs.noto-fonts-emoji;
|
|
|
|
name = "Noto Color Emoji";
|
|
|
|
};
|
|
|
|
};
|
2020-12-21 15:45:32 +00:00
|
|
|
```
|
2022-07-25 19:38:43 +00:00
|
|
|
|
2022-12-19 19:41:06 +00:00
|
|
|
These can be changed as you like.
|
2022-07-25 19:38:43 +00:00
|
|
|
|
2022-12-19 19:41:06 +00:00
|
|
|
To make things more uniform, you can replace the serif font with sans-serif:
|
2022-07-25 19:38:43 +00:00
|
|
|
|
2022-12-19 19:41:06 +00:00
|
|
|
```nix
|
|
|
|
stylix.fonts.serif = config.stylix.fonts.sansSerif;
|
2022-07-26 14:39:06 +00:00
|
|
|
```
|
2022-07-25 19:38:43 +00:00
|
|
|
|
2022-12-19 19:41:06 +00:00
|
|
|
Or even use monospace for everything:
|
2022-07-26 14:39:06 +00:00
|
|
|
|
2022-12-19 19:41:06 +00:00
|
|
|
```nix
|
|
|
|
stylix.fonts = {
|
|
|
|
serif = config.stylix.fonts.monospace;
|
|
|
|
sansSerif = config.stylix.fonts.monospace;
|
|
|
|
emoji = config.stylix.fonts.monospace;
|
|
|
|
};
|
|
|
|
```
|
2022-07-26 14:39:06 +00:00
|
|
|
|
|
|
|
## Turning targets on and off
|
|
|
|
|
|
|
|
In Stylix terms, a target is anything which can have colors, fonts or a
|
|
|
|
wallpaper applied to it. Each module in this repository should correspond to a
|
|
|
|
target of the same name.
|
|
|
|
|
|
|
|
Each target has an option like `stylix.targets.«target».enable` to turn its
|
|
|
|
styling on or off. Normally, it's turned on automatically when the target is
|
|
|
|
installed. You can set `stylix.autoEnable = false` to opt out of this
|
|
|
|
behaviour, in which case you'll need to manually enable each target you want to
|
|
|
|
be styled.
|