Stylix not applying theme

Hi, I recently made the switch to nixos and I’m having some trouble getting stylix to work. It changes the colour of the text while systemd is initialising on boot, but doesn’t seem to change anything else. I am using home-manger and stylix is installed as a nix module as recommended by vimjoyer. my full config
Here is my flake.nix:

{ description = "The config";

  inputs = {

    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Todo: write my own nvim conig
    #nixvim = {
    #    nixvim = { url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs";
    #};

    stylix.url = "github:danth/stylix";

  };

  outputs = { nixpkgs, nixpkgs-stable, home-manager, stylix, ... }@inputs:

    let
      system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system};
    in {

    nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
      specialArgs = {
        pkgs-stable = import nixpkgs-stable {
          inherit system; config.allowUnfree = true;
        };
         inherit inputs system;
      };
      modules = [
        inputs.stylix.nixosModules.stylix
        ./nixos/configuration.nix
        #inputs.nixvim.nixosModules.nixvim
      ];
    };

    homeConfigurations.janek = home-manager.lib.homeManagerConfiguration {
      inherit pkgs;
      modules = [ ./home-manager/home.nix ];
    };
  };
}

and my stylix.nix:

{ pkgs, inputs, ... }:

{
  stylix.enable = true;

  stylix.base16Scheme = {
    base00 = "282828"; # ----
    base01 = "3c3836"; # ---
    base02 = "504945"; # --
    base03 = "665c54"; # -
    base04 = "bdae93"; # +
    base05 = "d5c4a1"; # ++
    base06 = "ebdbb2"; # +++
    base07 = "fbf1c7"; # ++++
    base08 = "fb4934"; # red
    base09 = "fe8019"; # orange
    base0A = "fabd2f"; # yellow
    base0B = "b8bb26"; # green
    base0C = "8ec07c"; # aqua/cyan
    base0D = "83a598"; # blue
    base0E = "d3869b"; # purple
    base0F = "d65d0e"; # brown
  };
  #stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/tokyo-night-dark.yaml";
  stylix.image = "~/Pictures/pixelart.jpg";
  stylix.polarity = "dark";
}

Any help would be greatly appreciated. Thanks

If stylix has a home-manager module, it must be imported, as well. Here:

I’m having the same issue, and I don’t understand what you mean. What stylix home-manager module do you mean, and where does it need to be imported?

Do you mean to import stylix.homeManagerModules.stylix into my homeConfigurations on top of importing stylix.nixosModules.stylix into my nixConfigurations?

When not using home-manager as a NixOS submodule, you will need to import <input>.homeManagerModules.stylix as well. This needs to be somewhere in your imports; you can inport it in the modules section, but also in an imports in your e.g. configuration.nix. You also need to make sure to enable stylix in your home-manager configuration, not only in your NixOS configuration (this is true also when using it as a submodule)

1 Like

Thank you! This worked perfectly!

For those who run into this conversation in the future: If you do this, make sure that stylix.autoEnable is set to false in either your NixOS configuration or your Home Manager configuration to avoid conflicts.
There are a few programs that can be styled by both the NixOS version of stylix and the Home Manager version, and you need to make only one of them is doing it.