The option `programs.kitty' does not exist

Hi, I’m new to Nix, but absolutely love it. I encountered some issues, but I was able to solve them on my own. However I have no idea what to do with this one.

When trying to run sudo nixos-rebuild switch --flake . I get error:

error: cached failure of attribute 'nixosConfigurations.workstation.config'

From what I found here, I added -option eval-cache false and this time got error:

error: The option `programs.kitty' does not exist. Definition values:
       - In `/nix/store/laf90p1k2d051vgizijkwhvvdg5izfxk-source/modules/kitty.nix':

And I’m rather sure that it does exist.

What interesting, both errors only appeared after I moved this part

#Kitty config
  programs.kitty = {
  	enable = true;
  	theme = "Tokyo Night";
  	font.name = "JetBrainsMono Nerd Font";
  	settings = {
  		confirm_os_window_close = -0;
  		copy_on_select = true;
  		clipboard_control = "write-clipboard read-clipboard write-primary read-primary";
  	};
  };

from home.nix to its own module and imported it in configuration.nix. If I move it back the way it was before, everything works fine.


My configuration:

├── dotfiles
│  ├── other_configs
│  │  ├── Dark-Reader-Settings.json
│  │  └── my-ublock-backup_V5.txt
│  ├── spotify-player
│  │  ├── spotify-player.toml
│  │  └── theme.toml
│  └── starship.toml
├── modules
│  ├── drives.nix
│  ├── fish.nix
│  ├── kitty.nix
│  ├── nfs.nix
│  └── samba.nix
├──  nixos
│  └──  smb-secrets
├──  configuration.nix
├──  flake.lock
├──  flake.nix
├──  hardware-configuration.nix
└──  home.nix

flake.nix:

{
  description = "NixOS configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    musnix.url  = "github:musnix/musnix";
    nix-flatpak.url = "github:gmodena/nix-flatpak";
  };

  outputs = inputs@{ nixpkgs, home-manager, ... }: {
    nixosConfigurations = {
      workstation = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          inputs.musnix.nixosModules.musnix
          inputs.nix-flatpak.nixosModules.nix-flatpak
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.netlex = import ./home.nix;

            # Optionally, use home-manager.extraSpecialArgs to pass
            # arguments to home.nix
          }
        ];
        specialArgs = { inherit inputs; };
      };
    };
  };
}

home.nix:

{ config, pkgs, ... }:

{
  # Basics
  home.username = "netlex";
  home.homeDirectory = "/home/netlex";

  home.stateVersion = "23.11"; # Don't touch if not needed.

  # The home.packages option allows you to install Nix packages into your
  # environment.
  home.packages = [

  ];
  # Home Manager can also manage your environment variables through
  # 'home.sessionVariables'. If you don't want to manage your shell through Home
  # Manager then you have to manually source 'hm-session-vars.sh' located at
  # either
  #
  #  ~/.nix-profile/etc/profile.d/hm-session-vars.sh
  #
  # or
  #
  #  ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
  #
  # or
  #
  #  /etc/profiles/per-user/netlex/etc/profile.d/hm-session-vars.sh
  #
  home.sessionVariables = {
     EDITOR = "micro";
     TERM = "kitty";
  };

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

  #Starship
  home.file.".config/starship.toml".source = ./dotfiles/starship.toml;

  #Btop
  programs.btop = {
  	enable = true;
  	settings = {
  		color_theme = "TTY";
  		theme_background = false;
  		truecolor = true;
  		force_tty = false;
  		vim_keys = true;
  		rounded_corners = true;
  		graph_symbol = "braille";
  		update_ms = 1000;
  		proc_sorting = "cpu direct";
  	};
  };
  #Yazi
  programs.yazi = {
  	enable = true;
  	enableFishIntegration = true;
  };
  #Micro
  programs.micro = {
    enable = true;
    settings = {
    	colorscheme = "simple";
    	autosu = true;
    	mkparents = true;
    	scrollbar = true;
    	savecursor = true;
    	clipboard = "terminal";
    	};
    };
  #Git
  programs.git = {
  	enable = true;
  	userName = "netlex";
  	userEmail = "mail@gmail.com";
  };
  #MPV
  programs.mpv = {
    enable = true;
    profiles = {
      SDR = {
        profile = "gpu-hq";
        vo = "gpu-next";
        target-colorspace-hint = true;
        gpu-api = "vulkan";
        #gpu-context = "waylandvk"; # for now wayland need to be disabled, just nvidia things
        scale = "ewa_lanczossharp";
        cscale= "ewa_lanczossharp";
        tscale = "oversample";
        video-sync = "display-resample";
        interpolation = true;
        audio-channels = "stereo"; 
      };
      HDR = {
        profile = "gpu-hq";
        vo = "gpu-next";
        target-colorspace-hint = true;
        gpu-api = "vulkan";
        gpu-context = "waylandvk";
        video-output-levels = "limited";
        scale = "ewa_lanczossharp";
        cscale= "ewa_lanczossharp";
        tscale = "oversample";
        video-sync = "display-resample";
        interpolation = true;
        gamma = 8;
        brightness = 1;
      };
    };
    defaultProfiles = [ "SDR" ];
    bindings = { 
      "Ctrl+1" =  "apply-profile SDR";
      "Ctrl+2" =  "apply-profile HDR";
    };
  };
  # Spotify-player
  home.file.".config/spotify-player/app.toml".source = ./dotfiles/spotify-player/spotify-player.toml;
  home.file.".config/spotify-player/theme.toml".source = ./dotfiles/spotify-player/theme.toml;
}

kitty.nix:

{config, pkgs, ...}:

{
  #Kitty config
  programs.kitty = {
  	enable = true;
  	theme = "Tokyo Night";
  	font.name = "JetBrainsMono Nerd Font";
  	settings = {
  		confirm_os_window_close = -0;
  		copy_on_select = true;
  		clipboard_control = "write-clipboard read-clipboard write-primary read-primary";
  	};
  };
}

beginning of configuration.nix:

{ config, pkgs, ... }:

{
  imports =
    [ # Import nix modules.
      ./hardware-configuration.nix
      ./modules/samba.nix
      ./modules/drives.nix
      ./modules/nfs.nix
      ./modules/fish.nix
      ./modules/kitty.nix
    ];
...
}

nix-shell -p nix-info --run "nix-info -m" output:

 - system: `"x86_64-linux"`
 - host os: `Linux 6.7.3-zen1, NixOS, 24.05 (Uakari), 24.05.20240205.faf912b`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

I think you mistook the Home Manager option for a NixOS option which doesn’t exist.

To fix that, move the imports = [./kitty.nix]; to your home.nix file.

Oh, I should’ve noticed it on my own, but it definitely worked. Thanks!

In such case, can you mix options form NixOS and home-manager in one module?

Mix as in “having them in the same file” does work. However, they will reside in different scopes. It looks something like this:

# configuration.nix
{ pkgs, config, ... }: {
  # NixOS scope

  # a NixOS option
  hardware.opengl.enable = true;

  # Home Manager scope
  home-manager.users.netlex = {
    programs.kitty.enable = true;
  };
}

Though I would say it’s better to separate the scopes into different files, like you’re already doing by importing home.nix.

I see, once again thanks for information.