我的configuration.nix看起来像这样:
{ 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";
};
};
};
}
当我尝试 ssh 进入本地主机时,它无法连接,并systemctl status sshd
说它已经死了。当我跑步时systemctl start sshd
,一切正常。
我应该怎么做才能让 nixos 在启动时启动 sshd?
答案1
我在这里找到了答案:
https://github.com/NixOS/nixpkgs/issues/26776#issuecomment-310555407
它对我有用:
systemd.services.sshd.wantedBy = lib.mkOverride 40 [ "multi-user.target" ];