Non-existent GTK option in home-manager module in nixOS configuration flake

(apologies for a possibly incoherent title)
I’ve set up flakes and home-manager separately, and recently I tried to add home-manager into my flake as described in the documentation. Here are the relevant portions of my configuration:

# flake.nix
    description = "broken flake.";

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

    outputs = inputs@{ nixpkgs, home-manager, ... }: 
        system = "x86_64-linux";

        pkgs = import nixpkgs {
            inherit system;
            config = { allowUnfree = true; };

        lib = nixpkgs.lib;

    in {
        nixosConfigurations = {
            zxen-nix = lib.nixosSystem {
                inherit system; # same thing as system = "x86_64-linux";
                modules= [
                        home-manager.useGlobalPkgs = true;
                        home-manager.useUserPackages = true;
                        home-manager.users.azlanr = import ./home/home.nix;

And my home.nix was working perfectly fine when I ran home-manager switch without adding it as a flake module. But using sudo nixos-rebuild switch --flake .# in the flake directory with the flake.nix given above results in:

error: The option `home-manager.users.azlanr.programs.gtk' does not exist. Definition values:
       - In `/nix/store/5i6bi3yx11vjkm63vmkms3gs22nvi78r-source/flake.nix':
             cursorTheme = {
               name = "capitaine-cursors";
               package = <derivation capitaine-cursors-4>;
               size = 32;
(use '--show-trace' to show detailed location information)

Update I added the line home.stateVersion = "22.11"; in ./home/home.nix and commented out the gtk lines, and it works now. But when I uncomment the gtk lines, it stops working again to give the same error.

Can you post your home.nix file too please. i think somewhere in there you probably have a line like programs.gtk = ... but I think it should instead be gtk = ....

Look at this file home-manager/gtk.nix at ec06f419af79207b33d797064dfb3fc9dbe1df4a · nix-community/home-manager · GitHub . It defines the options for home-manager.

I think it’s common for modules to have something like

    cfg = config.Some.Config.Option;
in { ... }

and then in your config you’d set something like Some.Config.Option.enable = true; (you drop the config. prefix).

Take a look at this bit home-manager/gtk.nix at ec06f419af79207b33d797064dfb3fc9dbe1df4a · nix-community/home-manager · GitHub , particularly the lilne that says cfg = config.gtk;. Following the logic from above you should define something like gtk.enable instead of programs.gtk.enable.

1 Like