2

My configuration.nix looks like this:

{ config, pkgs, lib, ... }:
{
  imports = [<nixpkgs/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix>];
  # NixOS wants to enable GRUB by default
  boot.loader.grub.enable = false;

  # if you have a Raspberry Pi 2 or 3, pick this:
  boot.kernelPackages = pkgs.linuxPackages_latest;

  # A bunch of boot parameters needed for optimal runtime on RPi 3b+
  boot.kernelParams = ["cma=256M"];
  boot.loader.raspberryPi.enable = true;
  boot.loader.raspberryPi.version = 3;
  boot.loader.raspberryPi.uboot.enable = true;
  boot.loader.raspberryPi.firmwareConfig = ''
     gpu_mem=0
  '';   
  services.openssh.enable = true;
  services.sshd.enable = true;
  services.openssh.allowSFTP = true;
  users = {
    mutableUsers = false;
    users = {
      root = {
        hashedPassword = "";
      };
      pi = {
        isNormalUser = true;
        uid = 1000;
        extraGroups = ["wheel"];
        shell = pkgs.zsh;
        hashedPassword = "";
        home = "/home/pi";
      };
    };
  };
}

When I try ssh into localhost, it won't connect, and systemctl status sshd says that it's dead. When I run systemctl start sshd, everything works.

What should I do to get nixos to start sshd at boot?

  • 1
    You don't need services.sshd.enable; it's an alias for services.openssh.enable. What does journal -b -u sshd have to say? – Emmanuel Rosa Jul 16 '19 at 6:44
  • @EmmanuelRosa "--- No Entries ---" – nix Jul 16 '19 at 17:54
  • @EmmanuelRosa Also, when I run systemctl list-units |rg "ssh", I get an empty line – nix Jul 16 '19 at 17:55
  • Does systemctl list-units|grep ssh show anything? What's the output of journalctl -b|grep Reached? Also consider posting the contents of /etc/systemd/system/sshd.service – Emmanuel Rosa Jul 17 '19 at 13:46
  • @EmmanuelRosa pastebin.com/NiFQvdfV – nix Jul 17 '19 at 19:23
1

I found the answer here:

https://github.com/NixOS/nixpkgs/issues/26776#issuecomment-310555407

It worked for me:

systemd.services.sshd.wantedBy = lib.mkOverride 40 [ "multi-user.target" ];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.