Not only Zsh, but Bash v5 also comes with the bash variables such as EPOCHREALTIME. The thing is, assignments to those variables makes no sense AFAIK. However, the results of the nix print-dev-env command shows assignment to those variables.
I’m 99% sure these are set for reproducibility purposes. Without them, two builds may use different timestamps for things, which would mean that the outputs aren’t the same bit-for-bit. nix print dev-env will show them because it’s part of the env.
Mildly surprised at this though. It may be a fallback for when certain namespaces aren’t available?
Looking at the manual entry, setting them only does something useful if they’re unset first. If that doesn’t happen I’d send a PR making these actually meaningful.
Is there any reason you want to disable this behavior? You could sed it out of the output before evaling it.
Looking at the manual entry, setting them only does something useful if they’re unset first.
You’re right. It looks like if you unset first, then you can assign to them. So if someone use the variable this way in their environment, this behavior might be necessary for reproducibility.
Is there any reason you want to disable this behavior?
Actually it turns out one of the shell script library I use does readonly EPOCHREALTIME at the startup of the bash interactive shell. Thus, when I do nix develop, I get a warning like bash: EPOCHREALTIME: readonly variable. It’s just a warning, so I can simply ignore that, but it bothers me a bit.
So I’m actually having trouble with nix develop and I can’t simply sed it out since I’m not literary sourcing nix print-dev-env in this case.
Do you know how to do this for nix develop? (Maybe I can use --ignore-environment and --keep flags for that but it seems a lot of work to specify everything I want to keep and I’d like to know if there is an easier way.)
Is this part of your personal bashrc or of the dev environment itself? If the former, do you really need that check? Can you just patch it out downstream? If the latter, you should be able to either patch it out as well, or source it after those vars have been set.
Making nix develop behave differently is a bit tricky, I think, and possibly not recommended, even for something as small as this.
It’s part of my personal bashrc and the library called ble.sh which replaces bash’s GNU Readline and provides better auto-completion and syntax highlighting for bash.
From what I’ve seen of the library code, I guess the readonly check isn’t really necessary. So I’m gonna try to patch them.