[SOLVED] The option `services.openssh.settings' does not exist

I get this error after running sudo nixos-rebuild build.

I believe services.openssh.settings exists, after I found it in the available nix options.

What am I doing wrong?

$ nixos-version
22.11.4773.ea4c80b39be4 (Raccoon)
$ nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz
nixos https://channels.nixos.org/nixos-23.11
nixpkgs https://nixos.org/channels/nixos-23.11

My /etc/nixos/configuration.nix:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Nix settings.
  nix = {
    package = pkgs.nixFlakes;
    extraOptions = ''
      experimental-features = nix-command flakes
    '';
  };

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";

  networking.hostName = "izm"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
  networking.interfaces.enp4s0f4u1.wakeOnLan.enable = true;

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Asia/Tokyo";
  # time.timeZone = "Europe/Paris";

  # Select internationalisation properties.
  i18n.defaultLocale = "fr_FR.utf8";

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  services.teamviewer.enable = false;
  services.xserver.wacom.enable = true;

  services.logind.lidSwitchExternalPower = "lock";
  services.ratbagd.enable = true;
  virtualisation.virtualbox.host.enable = false;
  # virtualisation.libvirtd.enable = true;
  # programs.dconf.enable = true;
  # environment.systemPackages = with pkgs; [ virt-manager ];
  # users.users.adam.extraGroups = [ "libvirtd" ];
  virtualisation.docker.enable = false;

  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
    dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
  };

  programs.kdeconnect.enable = true;

  # nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [
  #   "steam"
  #   "steam-original"
  #   "steam-runtime"
  # ];

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
 #  services.xserver.displayManager.session = [{
 #      manage = "window";
 #      name = "xmonad";
 #      start = ''
 #        ${pkgs.runtimeShell} $HOME/.xsession &
 #        waitPID=$!
 #      '';
 #    }];
  # Configure keymap in X11
  services.xserver = {
    layout = "jp";
    xkbVariant = "";
  };

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

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Fonts
  fonts.fonts = with pkgs; [
    fira-code
    fira-code-symbols
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    liberation_ttf
    mplus-outline-fonts.githubRelease
    dina-font
    proggyfonts
  ];
  # Enable sound with pipewire.
  sound.enable = false;
  hardware.pulseaudio.enable = false;
  hardware.sane.enable = true;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  programs.fish.enable = true;
  environment.shells = with pkgs; [ fish ];

  users.users.adam-test = {
    isNormalUser = true;
    extraGroups = [ "libvirtd" "networkmanager" "wheel" "audio" ];
  };
  
  users.users.adam = {
    isNormalUser = true;
    description = "adam";
    extraGroups = [ "libvirtd" "networkmanager" "wheel" "audio" "docker" "vboxusers" ];
    # packages: see ~/.config/nixpkgs/home.nix
    # packages = with pkgs; [
    #   (firefox.override {extraNativeMessagingHosts = [ passff-host ];})
    # ];
    shell = pkgs.fish;
  # https://github.com/passff/passff/issues/419
  # programs.firefox = {
  #   enable = true;
  #   package = with pkgs; firefox.override {
  #     cfg = {
  #       extraNativeMessagingHosts = [passff-host];
  #     };
  #   };
  # };
  # home.file.".mozilla/native-messaging-hosts/passff.json".source = "${pkgs.passff-host}/share/passff-host/passff.json";
  };

  i18n.inputMethod = {
  enabled = "ibus";
  ibus.engines = with pkgs.ibus-engines; [ anthy hangul mozc ];
  };
  
  nixpkgs.config.allowUnfree = true;
  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
  virt-manager 
  vim # Nano is installed by default.
  wget
  openssh
  ntfs3g
  emacs-gtk
  ];

  systemd.services.battery-charge-threshold = {
    description = "Set the battery charge threshold";
    wantedBy = ["multi-user.target"];
    after = ["multi-user.target"];
    startLimitBurst = 0;
    script = ''
    echo 60 > /sys/class/power_supply/BATT/charge_control_end_threshold
    '';
    serviceConfig = {
      Type = "oneshot";
      Restart = "on-failure";
   };
  };
    
  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  programs.gnupg.agent = {
    enable = true;
    pinentryFlavor = "gnome3";
    # enableSSHSupport = true;
  };
 
  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  services.openssh = {
    enable = true;
    # require public key authentication for better security
    settings.PasswordAuthentication = false;
    settings.KbdInteractiveAuthentication = false;
    #settings.PermitRootLogin = "yes";
  };

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "22.05"; # Did you read the comment?

}

Thanks for your help! :slight_smile:

My first tip is that it does not exist yet in the version you’re trying. Your NixOS is 22.11. The .settings style is relatively new generally.

1 Like

Hi @vcunat , thanks for your tip.

My nix channels are up to date, because they are set to 23.11, and I just ran sudo nixos-rebuild switch --upgrade, without the openssh settings to make sure my system is up to date as well.

After this upgrade, the version output by nixos-version stays at 22.11 for some reason.

Should I use the 22.11 options then? But my problem now is how to find the correct way to write this in NixOS 22.11? The search only provides up to version 23.05: NixOS Search

This is wrong. For system you normally use the root’s channels, i.e. you need to use sudo nix-channel ...

2 Likes

Oh, that was the issue! Many thanks! :grinning:

Perhaps it’s my subjective feeling but home-manager users seem especially prone to using too many channels/versions, getting confused around that and suffering from some issues resulting from combining too different versions.