Last active
March 30, 2023 13:52
-
-
Save thufschmitt/6d46dce214fb95322ba74b897fc53398 to your computer and use it in GitHub Desktop.
Weird side effects in Nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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