Skip to content

In pure mode, set builtins.nixVersion to a constant - #5971

Open
edolstra wants to merge 1 commit into
NixOS:masterfrom
edolstra:nix-version
Open

edolstra wants to merge 1 commit into
NixOS:masterfrom
edolstra:nix-version

Conversation

@edolstra

@edolstra edolstra commented Jan 24, 2022 •

Copy link
Copy Markdown
Member

This prevents issues like
NixOS/nixpkgs#156527. Eventually we should do
this in impure mode as well.

Issue #5970.

Depends on #8330

This prevents issues like
NixOS/nixpkgs#156527. Eventually we should do
this in impure mode as well. Issue NixOS#5970.
@thufschmitt

Copy link
Copy Markdown
Member

I’m not sure it’s a good idea. Granted it’s a source of impurity, but so is builtins ? whatever. And it can be useful in some cases (nix-community/poetry2nix@5c06704 which is linked from the related issue is indeed a good example)

@edolstra

Copy link
Copy Markdown
Member Author

Yes, but expressions like builtins ? whatever are unlikely to end up embedded in strings like in NixOS/nixpkgs#156527.

@edolstra edolstra added this to the nix-2.7 milestone Jan 25, 2022
@roberth

roberth commented Jan 25, 2022

Copy link
Copy Markdown
Member

Adding a nixVersionAtLeast function seems like a good compromise. It produces a boolean, so it's unlikely to end up in a build like that.

@thufschmitt

Copy link
Copy Markdown
Member

Adding a nixVersionAtLeast function seems like a good compromise. It produces a boolean, so it's unlikely to end up in a build like that.

Yes, that sounds like a fairly good one

(and maybe just deprecating builtins.nixVersion for the time being to avoid breaking stuff too badly)

@edolstra edolstra modified the milestones: nix-2.7, nix-2.8 Mar 3, 2022
@edolstra edolstra modified the milestones: nix-2.8, nix-2.9 Apr 14, 2022
@edolstra edolstra modified the milestones: nix-2.9, nix-2.10 May 30, 2022
@edolstra edolstra modified the milestones: nix-2.10, nix-2.11 Jul 11, 2022
@edolstra edolstra modified the milestones: nix-2.11, nix-2.12 Aug 25, 2022
@edolstra edolstra modified the milestones: nix-2.12, nix-2.13 Dec 6, 2022
@edolstra edolstra modified the milestones: nix-2.13, nix-2.14 Jan 17, 2023
@edolstra edolstra modified the milestones: nix-2.14, nix-2.15 Feb 28, 2023
@fricklerhandwerk fricklerhandwerk added the language The Nix expression language; parser, interpreter, primops, evaluation, etc label Mar 3, 2023
@roberth

roberth commented May 23, 2023

Copy link
Copy Markdown
Member

Let's not forget about builtins.langVersion.

@roberth

roberth commented May 23, 2023

Copy link
Copy Markdown
Member

Adding a nixVersionAtLeast function seems like a good compromise.

This does make error messages less informative. Another solution is to poison the string context, similar to what we could do for secret strings, but slightly different allowed usages. String context poisoning has its own issue now:

@edolstra edolstra modified the milestones: nix-2.15, nix-2.16, nix-2.17 May 26, 2023
@fricklerhandwerk

Copy link
Copy Markdown
Contributor

Discussed in the Nix team meeting 2023-06-05:

  • @roberth proposes to add a comparison function instead and encourage its use, so version strings won't end up in builds
    • should deprecate nixVersion eventually of course
    • could be impureNixVersionAtLeast to signal
  • @edolstra: could ask what's the use case of knowing the version. usually to determine if a primop is available. but that's what ? is used
    • @roberth: in case we happen to release a buggy builtin, it my
  • @fricklerhandwerk: should the constant be something yelling "don't use"?
    • @edolstra: could stop incrementing it at 2.16
  • @Ericson2314: what speaks against removing it in pure eval?
  • conclusion: merge Automatically document builtin constants #8330 first so we can document nixVersion to be discouraged, pin output 2.16

@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-06-05-nix-team-meeting-minutes-60/28933/1

@dpulls

dpulls Bot commented Jun 27, 2023

Copy link
Copy Markdown

🎉 All dependencies have been resolved !

@edolstra edolstra modified the milestones: nix-2.17, nix-2.18 Jul 24, 2023
@edolstra edolstra modified the milestones: nix-2.18, nix-2.19 Sep 20, 2023
@edolstra edolstra modified the milestones: nix-2.19, nix-2.20 Nov 20, 2023
@edolstra edolstra modified the milestones: nix-2.20, nix-2.21 Mar 4, 2024
@edolstra edolstra modified the milestones: nix-2.21, nix-2.22 Mar 11, 2024
@edolstra edolstra modified the milestones: nix-2.22, nix-2.23 Apr 23, 2024
@edolstra edolstra removed this from the nix-2.23 milestone Jun 12, 2024
@roberth

roberth commented Mar 10, 2025 •

Copy link
Copy Markdown
Member

Proposing something similar for a feature detection function: https://git.lix.systems/lix-project/lix/issues/607#issuecomment-9297

(referring to my earlier comment)

@roberth roberth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See earlier comments

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

language The Nix expression language; parser, interpreter, primops, evaluation, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants