我安装了 nix-darwin 并创建了一个
flake.nix
文件,内容如下。我已将其放入目录 ~/x
并运行以下命令,没有出现任何错误:
$ darwin-rebuild switch --dry-run --flake x/
building the system configuration...
Password:
user defaults...
setting up user launchd services...
setting up /Applications/Nix Apps...
setting up pam...
applying patches...
setting up /etc...
system defaults...
setting up launchd services...
reloading nix-daemon...
waiting for nix-daemon
configuring networking...
setting up /Library/Fonts/Nix Fonts...
setting nvram variables...
但是,如果将目录添加到git,它会给出一个错误,这让我不知道如何修复
$ cp -r x y
$ cd y
$ git init && git add . && git commit -am 'initial'
$ darwin-rebuild switch --dry-run --flake y/
building the system configuration...
these 9 derivations will be built:
/nix/store/6q8gs4030fj613h1rc77qdd2vmsiydn7-options.json.drv
/nix/store/6i4fwbq03hrbsvw9skl60zz8w82z9mzp-options.json.drv
/nix/store/1213z7hj01zs50wsy3yjqsj6lcdvw4p7-darwin-manpages.drv
/nix/store/xdby0n64ijkcmyl1wf9dby5fgvmin03a-darwin-manual-html.drv
/nix/store/7m19k5gppfcbisdzk0rlyhqcq2kqsq88-darwin-help.drv
/nix/store/b35vswyff9pfd2a57y85zc8r326fsdq9-system-path.drv
/nix/store/ss6wmn08c1zp3snng97hs1qb7pl7x9my-system-applications.drv
/nix/store/z5c666bd7d5lrhg879n46hyl7mvp7a0j-darwin-version.json.drv
/nix/store/b1wjlf0rnzj84mv3w1yffqa1rph62jnc-darwin-system-24.05.20240621.201ed88+darwin4.29b3096.drv
don't know how to build these paths:
/nix/store/a2j86yi5rbprnq9wis88pq5n4qyfm0gq-darwin-system-24.05.20240621.201ed88+darwin4.29b3096
error: build of '/nix/store/a2j86yi5rbprnq9wis88pq5n4qyfm0gq-darwin-system-24.05.20240621.201ed88+darwin4.29b3096' failed
我做错了什么?渴望知道这里发生了什么,而不仅仅是如何解决它。
flake.nix
description = "Example Darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin";
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager }:
let
configuration = { pkgs, ... }: {
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = [
pkgs.vim
];
system.stateVersion = 4;
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "x86_64-darwin";
};
in
{
# Build darwin flake using:
# $ darwin-rebuild build --flake .#xx
darwinConfigurations = {
"xx" = nix-darwin.lib.darwinSystem {
modules = [
configuration
home-manager.darwinModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
};
};
# Expose the package set, including overlays, for convenience.
darwinPackages = self.darwinConfigurations."xx".pkgs;
};
要解决,
git add
相关项目。
这是我找到的关于此的片段:
将 nix 命令与 Nix flake 一起使用时,它首先将 flake 复制到 Nix 存储中。 (这就是为什么您看到的文件名位于 Nix 存储中,而不是您预期的位置。)使用本地路径执行此操作时,它会自动确定要使用的提取器。如果该路径似乎位于 Git 存储库中,则使用 Git 提取器。 Git fetcher 仍会完整保留工作目录中的更改(如果有),但会忽略任何“未跟踪”文件。
https://discourse.nixos.org/t/path-nix-store-does-not-exist/55413/4