Need help setting up Stylix

(completely edited to add more details)

I’ve done lots of looking up and reading the documentation multiple times but it seems to be missing something. The theme isn’t applied to programs.

I installed Stylix looking at the installation page, and the home manager module, both as flakes. It says "Installing Home Manager as a NixOS module is highly recommended" and “When Stylix is installed and enabled in a NixOS configuration, it will automatically set up its Home Manager modules if it detects that Home Manager is available”.

Looking at the configuration page, This is in my configuration.nix:

  stylix = {
    base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
    autoEnable = true;
    enable = true;
  };

programs = {
    neovim.enable = true;
    fish.enable = true;
    yazi.enable = true;
}

I have pkgs.base16-schemes installed but the theme is not applied to any of the programs. Even when I try having them installed via home-manager instead (in configuration.nix):

  home-manager.users.myUsername =
    { config, ... }:
    {
      home = {
        stateVersion = "25.11";
        packages = [
          pkgs.neovim
          pkgs.fish
          pkgs.yazi
        ];
      };
    };

My flake.nix:

    {
      inputs = {
        home-manager = {
          url = "github:nix-community/home-manager";
          inputs.nixpkgs.follows = "nixpkgs";
        };
        stylix = {
          url = "github:danth/stylix";
          inputs.nixpkgs.follows = "nixpkgs";
        };
        nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
      };
    
      outputs =
        { self, nixpkgs, ... }@inputs:
        {
          nixosConfigurations.NixOS-MBP = nixpkgs.lib.nixosSystem {
            specialArgs.flake-inputs = inputs;
            modules = [
              {
                home-manager.useGlobalPkgs = true;
                home-manager.useUserPackages = true;
              }
              inputs.home-manager.nixosModules.home-manager
              inputs.stylix.nixosModules.stylix
              ./configuration.nix
              ./hardware-configuration.nix
            ];
          };
        };
    }

Should already be working, what’s the issue? See the very next paragraph:

When Stylix is installed and enabled in a NixOS configuration, it will automatically set up its Home Manager modules if it detects that Home Manager is available

I just edited the post.

  • When I just have inputs.stylix.nixosModules.stylix, the colorscheme isn’t applied to kitty or neovim.
  • When I comment out inputs.stylix.nixosModules.stylix and just do inputs.stylix.homeModules.stylix I get error: The option dconf does not exist.
  • When I add both I get this error (I don’t have gnome installed):
error: The option `stylix.targets.gnome.enable' in `/nix/store/r0pfy9hccrvw2g1k46a3n34ijs34787p-source/modules/gnome/hm.nix' is already declared in `/nix/store/r0pfy9hccrvw2g1k46a3n34ijs34787p-source/modules/gnome/nixos.nix'.

Did you install kitty/neovim using home manager programs? Like programs.kitty.enable = true;

not in home manager config but right in my configuration.nix programs.kitty.enable = true;.

You need to install them with the home-manager config for stylix to realize they’re installed automatically.

If you don’t, you can force enable them: Configuration - Stylix

YMMV, sometimes stylix must edit the single configuration file of the program in question (I imagine this applies to kitty), so there is no real way to do this without using home-manager to configure it in general.

I don’t like this either; This, and some other limitations of stylix, means that I’ve just gone back to doing it by hand everywhere again.

1 Like

How do I force enable it?

By setting
stylix.targets.«target».enable = true

But that’s the first line of code in the link @TLATER provided so I suspect you already know that.

What if I have stylix.autoEnable = true;?

That won’t help (and is the default setting), because as I said, stylix needs you to inspect the home-manager module’s enable option to even know you’re using a specific application.

You need to explicitly add what @eblechschmidt suggests, and even then it may or may not be good enough depending on the application. If you want to use home-manager to configure themes, you’ll have to actually use home-manager to configure your applications.

I edited my post.

When I try these in configuration.nix:

  home-manager.users.myUsername =
    { config, ... }:
    {
      home = {
        stateVersion = "25.11";
        packages = [
          pkgs.neovim
          pkgs.fish
          pkgs.yazi
        ];
      };
    };

  stylix = {
    base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
    autoEnable = true;
    enable = false;
    targets.neovim.enable = true;
  };

I get error: The option stylix.targets.neovim does not exist, even though the other stylix options above it work.

This only exists in home manager and not in NixOS. Move it to your hm config above.

I looked at the home manager stylix documentation.

When I try that I get error: The option home-manager.users.myUsername.home.stylix does not exist.

  home-manager.users.myUsername =
    { config, ... }:
    {
      home = {
        stateVersion = "25.11";
        packages = [
          pkgs.kitty
          pkgs.neovim
          pkgs.fish
          pkgs.bat
          pkgs.yazi
          pkgs.neovide
        ];
        stylix = {
          base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
          autoEnable = true;
          enable = true;
          targets.neovim.enable = true;
        };
      };
    };

Also trying this I get The option home-manager.users.myUsername.stylix’ does not exist`

  home-manager.sharedModules = [
    {
      stylix.autoEnable = true;
    }
  ];

Right, let’s untangle your modules. Firstly move all NixOS configuration into configuration.nix:

# configuration.nix
{ pkgs, flake-inputs, ... }: {
  imports = [
    ./hardware-configuration.nix

    flake-inputs.home-manager.nixosModules.home-manager
    flake-inputs.stylix.nixosModules.stylix
  ];

  stylix = {
    base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
    autoEnable = true;
    enable = true;
  };

  programs = {
    neovim.enable = true;
    fish.enable = true;
    yazi.enable = true;
  };

  home-manager = {
    useGlobalPkgs = true;
    useUserPackages = true;
    # See next snippet
    users.myUsername = import ./home.nix;
  };

  # Any other config here
}

Then move your home-manager configuration into home.nix:

# home.nix
{ pkgs, ... }: {
  home = {
    # Remember not to touch this, no
    # it's not for updating, no it should
    # not be changed when updating
    stateVersion = "25.11";

    packages = [
      pkgs.kitty
      pkgs.neovim
      pkgs.fish
      pkgs.bat
      pkgs.yazi
      pkgs.neovide
    ];
  };

  stylix.targets.neovim.enable = true;

  # Any other config here
}

Then your flake.nix:

# somewhere in flake.nix
nixosConfigurations.NixOS-MBP = nixpkgs.lib.nixosSystem {
  specialArgs.flake-inputs = inputs;
  modules = [
    ./configuration.nix
  ];
}

This should prevent further confusion about what goes where. If you still get errors here, we’ll have to look more closely.

1 Like

I applied the changes but I don’t know why the colorscheme doesn’t show up in nvim. I have a feel there’s something I’m overlooking and maybe obvious but don’t know.

Here’s a zip of my .nix files: nix config.zip

I suspect that neovim when enabled on system level will create the config in a different location than Stylix and hence the Stylix config will not be used. Have you tried enabling it in hm?

1 Like

That’s indeed what I mean by:

Forcing it for neovim likely won’t do anything without home-manager’s further intervention, since its config is rather complex and likely involves multiple files that depend on each other. You won’t make headway here without reading the source and understanding how to weave it into how your configuration works.

It might work for other applications, but stylix isn’t magic, you still have to understand what you’re doing.

1 Like

What should I do then? I have a whole neovim configuration, I moved it out ~/.config and rebuilt my flake but it still shows the default colorscheme after reopening it.

Did you enable neovim in your home.nix? Or are you still enabling it in your NixOS configuration.

Like I said, I copied the example TLATER gave above, specifying neovim as a package in home.nix.