Nix-darwin lacks option "programs.zsh.enableAutosuggestions"

Newbie trying to set up zsh on nix-darwin.

# ~/.nixpkgs/darwin-configuration.nix

{ config, lib, pkgs, ... }:
{
  environment.systemPackages = [ pkgs.zsh-autosuggestions ];
  services.nix-daemon.enable = true;
  programs.zsh.enable = true;
  # programs.zsh.enableAutosuggestions = true;
  # programs.zsh.autosuggestions.enable = true;
  system.stateVersion = 4;
}

The option programs.zsh.autosuggestions.enable is in the official doc, and programs.zsh.enableAutosuggestions should also work.

But neither works on my Monetery:

$ darwin-rebuild switch
building the system configuration...
error: The option `programs.zsh.autosuggestions' does not exist. Definition values:
       - In `/Users/me/.nixpkgs/darwin-configuration.nix':
           {
             enable = true;
           }
(use '--show-trace' to show detailed location information)

$ darwin-option programs.zsh
enable
enableBashCompletion
enableCompletion
enableFzfCompletion
enableFzfGit
enableFzfHistory
enableSyntaxHighlighting
interactiveShellInit
loginShellInit
promptInit
shellInit
variables

Any help is appreciated.

Those links are all about nixos options, not nix-darwin options.

I’m confused. The package pkgs.zsh-autosuggestions provides the option programs.zsh.autosuggesetions.enable, and nix-darwin successfully installed pkgs.zsh-autosuggestions with darwin-rebuild switch, therefore nix-darwin should be configurable with programs.zsh.autosuggesetions.enable, shouldn’t it?

Packages do not provide options. Ever. Modules provide options, and they are specific to the system they correspond to (nixos, home-manager, nix-darwin, etc). Modules also generally install the related packages, rather than the other way around.

So how do you enable autosuggestion for zsh on mac? I just tired zsh.autosuggestion.enable = true; but seems not enough?

I don’t use nix-darwin, so I’m not sure, but I wouldn’t be surprised if it didn’t provide that configuration ability. I believe home-manager does, however, and you can use that on mac.

1 Like

hi @champignoom :wave:
I’m using the nixpkgs-unstable branch and home-manager master branch and this option is present there.

I’ve setup both my boxes in that way and doesn’t complain, got both aarm64-darwin and x86_64-darwin.

Here’s how I’ve set my inputs nix-config/flake.nix at 03faf5d7f52f0c157d14ab580a418cd99901a9dd · dminca/nix-config · GitHub

and this is the flag enabled within home-manager nix-config/zshrc.nix at 03faf5d7f52f0c157d14ab580a418cd99901a9dd · dminca/nix-config · GitHub

This builds perfectly fine. Maybe you’ve confused the zsh settings from man configuration.nix with the ones from man home-configuration.nix, happened to me quite often. Btw, make sure you check those manpages to validate whether or not some options are available to avoid hitting these errors.

FWIW I’ve also attempted to pin my nixpkgs input to nixos-23.11 but that was a catastrophe and I also started getting the error you’ve faced about autosuggestions missing from zsh. But I’m not an experienced Nix user to dig further into the problem, been using it for 2 months already and I’m still learning. However Nix is quite fail-proof in this regards, if you break something in an attempt you can just revert back any time.

Hope this helps you as well @gilescope