No description
Find a file
Daniel Thwaites 9185529e3d
Set GNOME desktop background
This works according to a comment on Reddit - I haven't tested it myself.
2022-08-13 10:15:54 +01:00
.github/workflows Don't run docs workflow for pull requests 👷 2022-08-10 22:19:00 +01:00
docs Update Coricamu ⬆️ 2022-07-31 14:35:18 +01:00
modules Set GNOME desktop background 2022-08-13 10:15:54 +01:00
palette-generator Log fitness values 🔊 2022-07-16 00:30:00 +01:00
stylix Simplify documentation of the default value for enable options 📝 2022-08-12 19:14:31 +01:00
flake.lock Update Coricamu ⬆️ 2022-08-04 23:09:35 +01:00
flake.nix Set GNOME desktop background 2022-08-13 10:15:54 +01:00
LICENSE Add MIT license 2020-12-21 13:58:20 +00:00
README.md Add Cachix details to README 📝 2022-07-27 12:47:35 +01:00

Stylix

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!

It also exports utilities for you to apply the theming to custom parts of your configuration.

Stylix is built using base16.nix, a library which handles the generation of config files from templates provided by the base16 project.

Installation

You can install Stylix using Flakes, for example:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    stylix.url = "github:danth/stylix";
  };

  outputs = { self, nixpkgs, home-manager, stylix }: {
    nixosConfigurations."<hostname>" = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        home-manager.nixosModules.home-manager
        stylix.nixosModules.stylix
      ];
    };
  };
}

Stylix relies on Home Manager for a lot of its work, so that needs to be imported too.

Binary cache

Stylix includes a Haskell program which generates color palettes. To avoid compiling this from source, add the following settings:

nix.settings = {
  substituters = "https://danth.cachix.org";
  trusted-public-keys = "danth.cachix.org-1:wpodfSL7suXRc/rJDZZUptMa1t4MJ795hemRN0q84vI=";
};

Wallpaper

To get started, you need to set a wallpaper image.

stylix.image = ./wallpaper.png;

The option accepts derivations as well as paths, so you can fetch a wallpaper directly from the internet:

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

If you only set a wallpaper, Stylix will use a homemade genetic algorithm to choose a color scheme based on it. The quality of the generated palettes can vary - but more colorful images tend to have better results.

You can force a light or dark theme using the polarity option:

stylix.polarity = "dark";

Mixed color schemes

You can override part of the scheme by hand, perhaps to select your background and text colors manually while keeping the genetic accent colors:

stylix.palette = {
  base00 = "000000";
  # ...
  base07 = "ffffff";
};

The baseXX names correspond to this table.

Manual color schemes

Alternatively, you can use a pre-made colorscheme from the base16 repository:

stylix.base16Scheme = "${base16-schemes}/gruvbox-dark-hard.yaml";

If you want anything more complex - like running an external palette generator program - base16Scheme can accept any argument to mkSchemeAttrs.

Fonts

The default combination of fonts is:

stylix.fonts = {
  serif = {
    package = pkgs.dejavu_fonts;
    name = "DejaVu Serif";
  };

  sansSerif = {
    package = pkgs.dejavu_fonts;
    name = "DejaVu Sans";
  };

  monospace = {
    package = pkgs.dejavu_fonts;
    name = "DejaVu Sans Mono";
  };

  emoji = {
    package = pkgs.noto-fonts-emoji;
    name = "Noto Color Emoji";
  };
};

You might like to set serif = sansSerif for a more uniform look:

stylix.fonts = rec {
  serif = sansSerif;

  sansSerif = {
    package = pkgs.dejavu_fonts;
    name = "DejaVu Sans";
  };
};

Or even use your favorite monospace font for all of them!

All that really matters is that monospace is actually monospace, as using a non-monospace font there will probably break your terminal.

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.