Error: The option `home' does not exist. Definition values:

Hi guys, was moving my home-manager setup into an nixos module but am having some troubles.
After importing my home.nix file into flake:

    {
      nixosConfigurations = {
        host-1 = nixpkgs.lib.nixosSystem {
            inherit inputs;
          };
          modules = [
            home-manager.nixosModules.home-manager
            {
              home-manager = {
                useGlobalPkgs = true;
                useUserPackages = true;
                extraSpecialArgs.flake-inputs = inputs;
                users = {
                  jeansib = import ./home-manager/jeansib/home.nix;
                };
              };
            }
            ./configuration.nix
          ];
        };
      };
    };

I tried to rebuild system, but got this error:

[root@host-1:~]# nixos-rebuild switch --verbose --show-trace 
$ cat /proc/sys/kernel/hostname
$ nix --extra-experimental-features nix-command flakes build --out-link /tmp/nixos-rebuild.y8QjGQ/nixos-rebuild /etc/nixos#nixosConfigurations."host-1".config.system.build.nixos-rebuild --verbose --show-trace
error:
       … while calling the 'seq' builtin
         at /nix/store/32dh0g41x5w9zkqxqka3rj7h18blqhyh-source/lib/modules.nix:334:18:
          333|         options = checked options;
          334|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          335|         _module = checked (config._module);

       … while calling the 'throw' builtin
         at /nix/store/32dh0g41x5w9zkqxqka3rj7h18blqhyh-source/lib/modules.nix:310:18:
          309|                     ''
          310|             else throw baseMsg
             |                  ^
          311|         else null;

       error: The option `home' does not exist. Definition values:
       - In `/nix/store/mdy2k8kzkwqxd43yv164jlq0kzmljyjh-source/modules/apps/okular.nix':
           {
             packages = {
               _type = "if";
               condition = false;
               content = [
           ...

[root@host-1:~]# 

I have no idea what is this okular.nix module. What does it mean? Can you guys help me out?

Hello
First can you post you home config.
Second can you try this for your flake:

  outputs = inputs@{ your inputs ... }: 
    let
      specialArgs = {inherit inputs;}; //better to define special args here
      system = "x86_64-linux";
      pkgs = import nixpkgs {
	     inherit system;
	     config.allowUnfree = true;
      };
      lib = nixpkgs.lib;
                                                                                   
      
      
    in {
      nixosConfigurations = {
	      nixos = lib.nixosSystem {
          inherit system;
	        modules = [
            ./configuration.nix
            home-manager.nixosModules.home-manager
            {
              home-manager.useGlobalPkgs = true;
              home-manager.useUserPackages = true;
              home-manager.extraSpecialArgs = specialArgs;
              home-manager.users.jeansib.imports = [
                ./home-manager/jeansib/home.nix
              ];
            }

Thank you for your reply. I omitted some lines in my flake, this is full flake.nix file:

{
  description = "Nixos config flake";

  inputs = {
    nixpkgs-unstable = {
      url = "github:nixos/nixpkgs/nixos-unstable";
    };
    nixpkgs-24-11 = {
      url = "github:nixos/nixpkgs/nixos-24.11";
    };
    nix-flatpak = {
      url = "github:gmodena/nix-flatpak/";
    };
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nix-index-db = {
      url = "github:nix-community/nix-index-database";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    plasma-manager = {
      url = "github:nix-community/plasma-manager";
      inputs.nixpkgs.follows = "nixpkgs-unstable";
      inputs.home-manager.follows = "home-manager";
    };
  };

  outputs = {
    self,
    nixpkgs,
    nixpkgs-unstable,
    nixpkgs-24-11,
    nix-flatpak,
    home-manager,
    nix-index-db,
    plasma-manager,
    ... }@inputs:

    let
      system = "x86_64-linux";
      pkgs = "nixpkgs.legacyPackages.${system}";
    in
    {
      nixosConfigurations = {
        host-1 = nixpkgs.lib.nixosSystem {
          specialArgs = {
            pkgs-unstable = import nixpkgs-unstable {
              inherit system;
              config.allowUnfree = true;
            };
            pkgs-24-11 = import nixpkgs-24-11 {
              inherit system;
              config.allowUnfree = true;
            };
            inherit inputs;
          };
          modules = [
            nix-flatpak.nixosModules.nix-flatpak
            home-manager.nixosModules.home-manager
            {
              home-manager = {
                useGlobalPkgs = true;
                useUserPackages = true;
                extraSpecialArgs.flake-inputs = inputs;
                users = {
                  jeansib = import ./home-manager/jeansib/home.nix;
                };
              };
            }
            nix-index-db.nixosModules.nix-index
            plasma-manager.homeManagerModules.plasma-manager
            ./configuration.nix
          ];
        };
      };
    };
}

home.nix is also quite large and in several files. This is my main home.nix file:

{config, pkgs, lib, pkgs-24-11, pkgs-unstable, inputs, ...}:
{
  imports = [
    ./systemd-services.nix
    ./plasma-manager/plasma-manager.nix
    ./hyprland/hyprland.nix
    ./import.nix
  ];

  home = {
    stateVersion = "24.11";
    username = "jeansib";
    homeDirectory = "/home/jeansib";
    packages = [
      pkgs-24-11.musescore
      pkgs-24-11.libreoffice
      pkgs-24-11.teams-for-linux
      pkgs-24-11.lmms
      pkgs-unstable.lynx
      pkgs-unstable.libwebp
      pkgs-unstable.tagainijisho
      pkgs-24-11.protonvpn-gui
      pkgs-unstable.protonmail-desktop
      pkgs-unstable.proton-pass
      pkgs-24-11.frescobaldi
      pkgs-24-11.yt-dlp
      pkgs-24-11.ventoy-full
      pkgs-24-11.mindustry-wayland
    ];
  };

  programs = {
    git = {
      enable = true;
      userName  = "";
      userEmail = "j";
    };
    obs-studio = {
      enable = true;
    };
    emacs = {
      enable = true;
      package = pkgs-24-11.emacs;
    };
  };
}

Can you try this for your flake:

{
  description = "Nixos config flake";

  inputs = {
    nixpkgs-unstable = {
      url = "github:nixos/nixpkgs/nixos-unstable";
    };
    nixpkgs-24-11 = {
      url = "github:nixos/nixpkgs/nixos-24.11";
    };
    nix-flatpak = {
      url = "github:gmodena/nix-flatpak/";
    };
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nix-index-db = {
      url = "github:nix-community/nix-index-database";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    plasma-manager = {
      url = "github:nix-community/plasma-manager";
      inputs.nixpkgs.follows = "nixpkgs-unstable";
      inputs.home-manager.follows = "home-manager";
    };
  };

  outputs = {
    self,
    nixpkgs,
    nixpkgs-unstable,
    nixpkgs-24-11,
    nix-flatpak,
    home-manager,
    nix-index-db,
    plasma-manager,
    ... }@inputs:

    let
      specialArgs = {inherit inputs;};
      system = "x86_64-linux";
      pkgs-unstable = import nixpkgs-unstable {
        inherit system;
        config.allowUnfree = true;
      };
      pkgs-24-11 = import nixpkgs-24-11 {
        inherit system;
        config.allowUnfree = true;
      };
      lib = nixpkgs.lib;

    in
    {
      nixosConfigurations = {
        host-1 = lib.nixosSystem {
          inherit system
          modules = [
            nix-flatpak.nixosModules.nix-flatpak
            home-manager.nixosModules.home-manager
            {
              home-manager = {
                useGlobalPkgs = true;
                useUserPackages = true;
                extraSpecialArgs = specialArgs;
                users = {
                  jeansib = import ./home-manager/jeansib/home.nix;
                };
              };
            }
            nix-index-db.nixosModules.nix-index
            plasma-manager.homeManagerModules.plasma-manager
            ./configuration.nix
          ];
        };
      };
    };
}

The same error shows up.

Ok
Can you change that home-manager follows unstable:

home-manager.inputs.nixpkgs.follows = "nixpkgs-unstable";

Second can you check that you don’t import something that needs home-manager in your normal config. Also can you post your normal config?
Third of all can you run home-manager in standalone without your flake?

  1. Changed to nixpkgs-unstable, but the error persists:
[root@host-1:~]# nixos-rebuild switch --verbose --show-trace 
$ cat /proc/sys/kernel/hostname
$ nix --extra-experimental-features nix-command flakes build --out-link /tmp/nixos-rebuild.10gFLW/nixos-rebuild /etc/nixos#nixosConfigurations."host-1".config.system.build.nixos-rebuild --verbose --show-trace
warning: updating lock file '/etc/nixos/flake.lock':
• Updated input 'home-manager/nixpkgs':
    follows 'nixpkgs'
  → follows 'nixpkgs-unstable'
copying path '/nix/store/2rfas9zi1rivhpk57gmyhvmflsmnlh2m-source' from 'https://nix-community.cachix.org'...
copying path '/nix/store/k4s2cqc3w40bcxy16m7l40fw8z02jn24-source' from 'https://nix-community.cachix.org'...
error:
       … while calling the 'seq' builtin
         at /nix/store/32dh0g41x5w9zkqxqka3rj7h18blqhyh-source/lib/modules.nix:334:18:
          333|         options = checked options;
          334|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          335|         _module = checked (config._module);

       … while calling the 'throw' builtin
         at /nix/store/32dh0g41x5w9zkqxqka3rj7h18blqhyh-source/lib/modules.nix:310:18:
          309|                     ''
          310|             else throw baseMsg
             |                  ^
          311|         else null;

       error: The option `home' does not exist. Definition values:
       - In `/nix/store/mdy2k8kzkwqxd43yv164jlq0kzmljyjh-source/modules/apps/okular.nix':
           {
             packages = {
               _type = "if";
               condition = false;
               content = [
           ...

[root@host-1:~]# 
  1. Normal meaning configuration.nix, or home.nix? Both are quite large and in several files. This is my base configuration.nix:
{ config, pkgs, inputs, ... }:

{
  imports =
    [
      ./import.nix
      ./users.nix
      ./packages.nix
      ./systemd-services.nix
      ./scripts/scripts.nix
    ];

  boot = {
    loader = {
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
    };
    kernel.sysctl."vm.swappiness" = 80;
  };

  networking.networkmanager.enable = true;

  console.keyMap = "pl";

  time.timeZone = "Europe/Warsaw";

  i18n = {
    defaultLocale = "en_GB.UTF-8";
    extraLocaleSettings = {
      LC_ADDRESS = "pl_PL.UTF-8";
      LC_IDENTIFICATION = "pl_PL.UTF-8";
      LC_MEASUREMENT = "pl_PL.UTF-8";
      LC_MONETARY = "pl_PL.UTF-8";
      LC_NAME = "pl_PL.UTF-8";
      LC_NUMERIC = "pl_PL.UTF-8";
      LC_PAPER = "pl_PL.UTF-8";
      LC_TELEPHONE = "pl_PL.UTF-8";
      LC_TIME = "pl_PL.UTF-8";
    };
  };

  xdg.portal = {
    enable = true;
    xdgOpenUsePortal = true;
    extraPortals = [
      pkgs.xdg-desktop-portal-kde
    ];
  };

  services = {
    xserver = {
      enable = true;
      desktopManager = {
        xfce.enable = false;
        gnome.enable = true;
      };
    };
    desktopManager.plasma6.enable = true;
    displayManager = {
      defaultSession = "plasma";
      sddm = {
        enable = true;
        wayland.enable = true;
      };
    };
    pulseaudio.enable = false;
    pipewire = {
      enable = true;
      alsa = {
        enable = true;
        support32Bit = true;
      };
      pulse.enable = true;
      # If you want to use JACK applications, uncomment this
      #jack.enable = true;
    };
    printing = {
      enable = true;
      openFirewall = true;
      drivers = [
        pkgs.samsung-unified-linux-driver
      ];
    };
    clamav = {
      daemon.enable = true;
      updater.enable = true;
    };
    fwupd.enable = true;

    btrfs = {
      autoScrub = {
        enable = true;
        interval = "monthly";
      };
    };

  };

  # Configure console keymap
#  console.keyMap = "pl2";

  # Bluetooth
  hardware = {
    bluetooth = {
      enable = true;
      powerOnBoot = true;
    };
  };
  

  # Enable sound with pipewire.
  security.rtkit.enable = true;

  virtualisation = {
    libvirtd = {
      enable = true;
    };
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;
  
  system.autoUpgrade = {
    enable = true;
    flake = inputs.self.outPath;
    dates = "daily";
  };

  nix = {
    settings = {
      substituters = [
        "https://cache.nixos.org"
        "https://nix-community.cachix.org"
        "https://hyprland.cachix.org"
      ];
      trusted-public-keys = [
        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
        "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
      ];
      experimental-features = [
        "nix-command"
        "flakes"
      ];
      auto-optimise-store = true;
    };
    gc = {
      automatic = true;
      dates = "daily";
      options = "--delete-older-than 14d";
    };
  };

  programs = {
    sway.enable = false;
    hyprland.enable = true;
    miriway.enable = true;
    wayland.miracle-wm.enable = true;

    fish.enable = true;
    zsh.enable = true;
    virt-manager.enable = true;
    kdeconnect.enable = true;
    ssh.askPassword = pkgs.lib.mkForce "${pkgs.kdePackages.ksshaskpass.out}/bin/ksshaskpass";
  };
  networking.firewall.enable = true;
  system.stateVersion = "24.11"; # Did you read the comment?
}
  1. Yes, I didn’t change at all my hom.nix, just imported it into my flake.

This is that okular.nix module:

{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.programs.okular;
  getIndexFromEnum =
    enum: value:
    if value == null then
      null
    else
      lib.lists.findFirstIndex (x: x == value)
        (throw "getIndexFromEnum (okular): Value ${value} isn't present in the enum. This is a bug.")
        enum;
in
with lib.types;
{
  options.programs.okular = {
    enable = lib.mkEnableOption ''
      configuration management for okular.
    '';

    package =
      lib.mkPackageOption pkgs
        [
          "kdePackages"
          "okular"
        ]
        {
          nullable = true;
          example = "pkgs.libsForQt5.okular";
          extraDescription = ''
            Which okular package to install. Use `pkgs.libsForQt5.okular` in Plasma5 and
            `pkgs.kdePackages.okular` in Plasma6. Use `null` if home-manager should not install Okular.
          '';
        };

    # ==================================
    #     GENERAL
    general = {
      smoothScrolling = lib.mkOption {
        description = "Whether to use smooth scrolling.";
        default = null;
        type = nullOr bool;
      };

      showScrollbars = lib.mkOption {
        description = "Whether to show scrollbars in the document viewer.";
        default = null;
        type = nullOr bool;
      };

      openFileInTabs = lib.mkOption {
        description = "Whether to open files in tabs.";
        default = null;
        type = nullOr bool;
      };

      viewContinuous = lib.mkOption {
        description = "Whether to open in continous mode by default.";
        default = null;
        type = nullOr bool;
      };

      viewMode = lib.mkOption {
        description = "The view mode for the pages.";
        default = null;
        type = nullOr (enum [
          "Single"
          "Facing"
          "FacingFirstCentered"
          "Summary"
        ]);
      };

      zoomMode =
        let
          enumVals = [
            "100%"
            "fitWidth"
            "fitPage"
            "autoFit"
          ];
        in
        lib.mkOption {
          description = ''
            Specifies the default zoom mode for file which were never opened before.
            For those files which were opened before the previous zoom mode is applied.
          '';
          default = null;
          type = nullOr (enum enumVals);
          apply = getIndexFromEnum enumVals;
        };

      obeyDrm = lib.mkOption {
        description = ''
          Whether Okular should obey DRM (Digital Rights Management) restrictions.
          DRM limitations are used to make it impossible to perform certain actions with PDF documents, such as copying content to the clipboard.
          Note that in some configurations of Okular, this option is not available.
        '';
        default = null;
        type = nullOr bool;
      };

      mouseMode = lib.mkOption {
        description = ''
          Changes what the mouse does.
          See the [Okular Documentation](https://docs.kde.org/stable5/en/okular/okular/menutools.html) for the full description.

          - `Browse`: Click-and-drag with left mouse button.
          - `Zoom`: Zoom in with left mouse button. Reset zoom with right mouse button.
          - `RectSelect`: Draw area selection with left mouse button. Display options with right mouse button.
          - `TextSelect`: Select text with left mouse button. Display options with right mouse button.
          - `TableSelect`: Similar to text selection but allows for transforming the document into a table.
          - `Magnifier`: Activates the magnifier with left mouse button.
        '';
        default = null;
        type = nullOr (enum [
          "Browse"
          "Zoom"
          "RectSelect"
          "TextSelect"
          "TableSelect"
          "Magnifier"
          "TrimSelect"
        ]);
      };
    };

    # ==================================
    #     ACCESSIBILITY
    accessibility = {
      highlightLinks = lib.mkOption {
        description = "Whether to draw borders around links.";
        default = null;
        type = nullOr bool;
      };

      changeColors = {
        enable = lib.mkEnableOption "" // {
          description = "Whether to change the colors of the documents.";
        };
        mode = lib.mkOption {
          description = "Mode used to change the colors.";
          default = null;
          type = nullOr (enum [
            # Inverts colors, including hue
            "Inverted"
            # Change background color (see option below)
            "Paper"
            # Change light and dark colors (see options below)
            "Recolor"
            # Change to black & white colors (see options below)
            "BlackWhite"
            # Invert lightness but leave hue and saturation
            "InvertLightness"
            # Like InvertLightness, but slightly more contrast
            "InvertLumaSymmetric"
            # Like InvertLightness, but much more contrast
            "InvertLuma"
            # Shift hue of all colors by 120 degrees
            "HueShiftPositive"
            # Shift hue of all colors by 240 degrees
            "HueShiftNegative"
          ]);
        };
        paperColor = lib.mkOption {
          description = "Paper color in RGB. Used for the `Paper` mode.";
          default = null;
          example = "255,255,255";
          type = nullOr str;
        };
        recolorBackground = lib.mkOption {
          description = "New background color in RGB. Used for the `Recolor` mode.";
          default = null;
          example = "0,0,0";
          type = nullOr str;
        };
        recolorForeground = lib.mkOption {
          description = "New foreground color in RGB. Used for the `Recolor` mode.";
          default = null;
          example = "255,255,255";
          type = nullOr str;
        };
        blackWhiteContrast = lib.mkOption {
          description = "New contrast strength. Used for the `BlackWhite` mode.";
          default = null;
          example = 4;
          type = nullOr (ints.between 2 6);
        };
        blackWhiteThreshold = lib.mkOption {
          description = ''
            A threshold for deciding between black and white.
            Higher values lead to brighter grays.
            Used for the `BlackWhite` mode.
          '';
          default = null;
          example = 127;
          type = nullOr (numbers.between 2 253);
        };
      };
    };

    # ==================================
    #     PERFORMANCE
    performance = {
      enableTransparencyEffects = lib.mkOption {
        description = "Whether to enable transparancy effects. This may increase CPU usage.";
        default = null;
        type = nullOr bool;
      };

      memoryUsage = lib.mkOption {
        description = "Memory usage profile for Okular. This may impact the speed performance of Okular, as it determines how many computation results are kept in memory.";
        default = null;
        type = nullOr (enum [
          "Low"
          "Normal"
          "Aggressive"
          "Greedy"
        ]);
      };
    };
  };

  config = {
    home.packages = lib.mkIf (cfg.enable && cfg.package != null) [ cfg.package ];
  };

  # ==================================
  #     WRITING THE OKULARPARTRC
  config.programs.plasma.configFile."okularpartrc" = lib.mkIf cfg.enable (
    let
      gen = cfg.general;
      acc = cfg.accessibility;
      perf = cfg.performance;
      applyIfSet = opt: lib.mkIf (opt != null) opt;
    in
    {
      "PageView" = {
        "SmoothScrolling" = applyIfSet gen.smoothScrolling;
        "ShowScrollBars" = applyIfSet gen.showScrollbars;
        "ViewContinuous" = applyIfSet gen.viewContinuous;
        "ViewMode" = applyIfSet gen.viewMode;
        "MouseMode" = applyIfSet gen.mouseMode;
      };

      "Zoom" = {
        "ZoomMode" = applyIfSet gen.zoomMode;
      };
      "Core General" = {
        "ObeyDRM" = applyIfSet gen.obeyDrm;
      };

      "General" = {
        "ShellOpenFileInTabs" = applyIfSet gen.openFileInTabs;
      };

      "Document" = {
        "ChangeColors" = applyIfSet acc.changeColors.enable;
        "RenderMode" = applyIfSet acc.changeColors.mode;
        "PaperColor" = applyIfSet acc.changeColors.paperColor;
      };

      "Dlg Accessibility" = {
        "HighlightLinks" = applyIfSet acc.highlightLinks;
        "RecolorBackground" = applyIfSet acc.changeColors.recolorBackground;
        "RecolorForeground" = applyIfSet acc.changeColors.recolorForeground;
        "BWContrast" = applyIfSet acc.changeColors.blackWhiteContrast;
        "BWThreshold" = applyIfSet acc.changeColors.blackWhiteThreshold;
      };

      "Core Performance" = {
        "MemoryLevel" = applyIfSet perf.memoryUsage;
      };

      "Dlg Performance" = {
        "EnableCompositing" = applyIfSet perf.enableTransparencyEffects;
      };
    }
  );
}

Okay, I got it. plasma-manager module was badly imported, it should be:

          {
            home-manager = {
              useGlobalPkgs = true;
              useUserPackages = true;
              extraSpecialArgs = { inherit inputs; };
              sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ];
              users = {
                jeansib = import ./home-manager/jeansib/home.nix;
              };
            };
          }
1 Like