我正在尝试在 WSL 中运行的 NixOS 中设置主管理器。但是,我的导入似乎无法正常工作。我不确定我遗漏了什么。Google 和 ChatGPT 在这里毫无用处。
我的 /etc/nixos/configuration.nix
{ config, lib, pkgs, ... }:
let
home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/master.tar.gz";
in
{
imports = [
# include NixOS-WSL modules
<nixos-wsl/modules>
<home-manager/nixos>
];
wsl.enable = true;
wsl.defaultUser = "nixos";
# 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).
environment.systemPackages = with pkgs; [
vim
oh-my-zsh
zsh
zsh-completions
zsh-powerlevel10k
zsh-syntax-highlighting
zsh-history-substring-search
# other packages
];
system.stateVersion = "24.05"; # Did you read the comment?
users.users.nixos.isNormalUser = true;
home-manager.users.nixos = { pkgs, ... }: {
home.stateVersion = "24.05";
home.username = "nixos";
users.defaultUserShell = pkgs.zsh;
programs.zsh = {
enable = true;
oh-my-zsh = {
enable = true;
theme = "avit"; # Set the desired theme here
plugins = [ "git" "vim" "sudo" "z"];
};
};
};
}
我收到的错误是:
$ sudo nixos-rebuild switch
building Nix...
building the system configuration...
error:
… while calling the 'head' builtin
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:1575:11:
1574| || pred here (elemAt values 1) (head values) then
1575| head values
| ^
1576| else
… while evaluating the attribute 'value'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:809:9:
808| in warnDeprecation opt //
809| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
810| inherit (res.defsFinal') highestPrio;
(stack trace truncated; use '--show-trace' to show the full trace)
error: The option `home-manager.users.nixos.users' does not exist. Definition values:
- In `/etc/nixos/configuration.nix':
{
defaultUserShell = <derivation zsh-5.9>;
我错过了什么?