我的
flake.nix
在/etc/nixos
目录:
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in {
nixosConfigurations = rec {
default = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs system; };
modules = [ ./configuration.nix home-manager.nixosModules.home-manager ];
};
nixos = default;
};
};
}
当我运行它时(第一次安装家庭管理器),我收到以下日志:
warning: creating lock file '/etc/nixos/flake.lock'
building the system configuration...
trace: warning: monkpatch profile: You are using
Home Manager version 24.05 and
Nixpkgs version 23.11.
Using mismatched versions is likely to cause errors and unexpected
behavior. It is therefore highly recommended to use a release of Home
Manager that corresponds with your chosen release of Nixpkgs.
If you insist then you can disable this warning by adding
home.enableNixpkgsReleaseCheck = false;
to your configuration.
如果我将
nixos-23.11
(第5行)中的nixos-unstable
替换为nixpkgs.url
(第5行),那么错误就会消失。但是如果我想使用nixos-23.11
怎么办?我该怎么办?
home-manager
git 存储库恰好有一个 release-23.11
分支,与 nixos-23.11
的 nixpkgs
分支相对应。你的 flake.nix
的第 5 行甚至提供了如何指定 git 分支的线索:
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
换句话说,分支的片状“URL”语法只是添加另一个
/
,然后添加分支名称。将 flake.nix
的第 7 行修改为
url = "github:nix-community/home-manager/release-23.11";
你应该可以走了!