我正在尝试这样做教程.
我在 /etc/nixos/configuration.nix 中添加了这些行
services.nginx.enable = true;
services.nginx.virtualHosts."test.local.cetacean.club" = {
root = "/srv/http/test.local.cetacean.club";
};
我做了这些命令
sudo mkdir -p /srv/http/test.local.cetacean.club
sudo chown nixos:nginx /srv/http/test.local.cetacean.club
我已经像这样定义了这些文件 /etc/nixos/flake.nix
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }: {
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
# add things here
];
};
};
}
以下命令有效。这意味着我的文件没问题 sudo nix 薄片检查 /etc/nixos
但是这个命令不起作用
sudo nixos-rebuild switch
我不明白这个问题。此命令在定义 /etc/nixos/flake.nix 之前起作用。我不明白为什么这会阻止重建 /etc/nixos/configuration.nix.
现在是错误信息
>× systemd-sysctl.service - Apply Kernel Variables
Loaded: loaded (/etc/systemd/system/systemd-sysctl.service; enabled; preset: enabled)
Drop-In: /nix/store/9mnkvlaxvwlp3iw50mf2p91rm3simizr-system-units/systemd-sysctl.service.d
└─overrides.conf
Active: failed (Result: exit-code) since Sun 2022-12-25 08:26:30 UTC; 64ms ago
Duration: 29min 7.255s
Docs: man:systemd-sysctl.service(8)
man:sysctl.d(5)
Process: 10842 ExecStart=/nix/store/9rjdvhq7hnzwwhib8na2gmllsrh671xg-systemd-252.1/lib/systemd/systemd-sysctl (code=exited, status=243/CREDENTIALS)
Main PID: 10842 (code=exited, status=243/CREDENTIALS)
IP: 0B in, 0B out
>Dec 25 08:26:30 nixos systemd[1]: Starting Apply Kernel Variables...
Dec 25 08:26:30 nixos systemd[10842]: systemd-sysctl.service: Failed to set up credentials: Protocol error
Dec 25 08:26:30 nixos systemd[10842]: systemd-sysctl.service: Failed at step CREDENTIALS spawning /nix/store/9rjdvhq7hnzwwhib8na2gmllsrh671xg-systemd-252.1/lib/systemd/systemd-sysctl: Protocol error
Dec 25 08:26:30 nixos systemd[1]: systemd-sysctl.service: Main process exited, code=exited, status=243/CREDENTIALS
Dec 25 08:26:30 nixos systemd[1]: systemd-sysctl.service: Failed with result 'exit-code'.
Dec 25 08:26:30 nixos systemd[1]: Failed to start Apply Kernel Variables.
× systemd-tmpfiles-setup-dev.service - Create Static Device Nodes in /dev
Loaded: loaded (/etc/systemd/system/systemd-tmpfiles-setup-dev.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-12-25 08:26:30 UTC; 68ms ago
Duration: 29min 7.256s
Docs: man:tmpfiles.d(5)
man:systemd-tmpfiles(8)
Process: 10844 ExecStart=systemd-tmpfiles --prefix=/dev --create --boot (code=exited, status=243/CREDENTIALS)
Main PID: 10844 (code=exited, status=243/CREDENTIALS)
IP: 0B in, 0B out
>Dec 25 08:26:30 nixos systemd[1]: Starting Create Static Device Nodes in /dev...
Dec 25 08:26:30 nixos systemd[10844]: systemd-tmpfiles-setup-dev.service: Failed to set up credentials: Protocol error
Dec 25 08:26:30 nixos systemd[10844]: systemd-tmpfiles-setup-dev.service: Failed at step CREDENTIALS spawning systemd-tmpfiles: Protocol error
Dec 25 08:26:30 nixos systemd[1]: systemd-tmpfiles-setup-dev.service: Main process exited, code=exited, status=243/CREDENTIALS
Dec 25 08:26:30 nixos systemd[1]: systemd-tmpfiles-setup-dev.service: Failed with result 'exit-code'.
Dec 25 08:26:30 nixos systemd[1]: Failed to start Create Static Device Nodes in /dev.
warning: error(s) occurred while switching to the new configuration