Skip to content

Instantly share code, notes, and snippets.

@thufschmitt
Last active March 30, 2023 13:52
Show Gist options
  • Save thufschmitt/6d46dce214fb95322ba74b897fc53398 to your computer and use it in GitHub Desktop.
Save thufschmitt/6d46dce214fb95322ba74b897fc53398 to your computer and use it in GitHub Desktop.
Weird side effects in Nix
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/a7cc81913bb3cd1ef05ed0ece048b773e1839e51";
outputs = { self, nixpkgs }: {
testPathExists =
let hello = nixpkgs.legacyPackages.x86_64-linux.hello; in
builtins.pathExists hello;
testPathExists2 =
# Output of `nix eval --inputs-from . nixpkgs\#hello.outPath`
let hello = /nix/store/hrqijlzk6b56ij6g86vdh2b8mkv1i469-hello-2.12.1; in
builtins.pathExists hello;
testPathExists3 = self.testPathExists && self.testPathExists2;
testPathExists4 = self.testPathExists2 && self.testPathExists;
};
}
$ nix build .#hello
$ nix eval .\#testPathExists
true
$ nix eval .\#testPathExists2
false
$ nix eval .\#testPathExists3
true
$ nix eval .\#testPathExists4
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment