grahamc · GitHub

@7c6f434c

grahamc

@7c6f434c

peti

peti approved these changes Apr 28, 2019

@7c6f434c

samueldr

@globin globin changed the title A small RFC on deprecating URL syntax [RFC 0045] A small RFC on deprecating URL syntax

Apr 28, 2019

@globin globin changed the title [RFC 0045] A small RFC on deprecating URL syntax [RFC 0045] Deprecating unquoted URL syntax

Apr 28, 2019

@7c6f434c

Ericson2314

4z3

4z3 approved these changes Apr 29, 2019

Merged

10 tasks

FRidh

Co-Authored-By: 7c6f434c <7c6f434c@mail.ru>
Co-Authored-By: 7c6f434c <7c6f434c@mail.ru>

Merged

This was referenced

Sep 30, 2021

Merged

Merged

Merged

12 tasks

Closed

@ckiee ckiee mentioned this pull request

Mar 1, 2022

Merged

13 tasks

Merged

13 tasks

Ma27 added a commit to Ma27/nix that referenced this pull request

Jun 13, 2022
Basically an attempt to resume fixing NixOS#5543 for a breakage introduced
earlier[1]. Basically, when evaluating an older `nixpkgs` with
`nix-shell` the following error occurs:
    λ ma27 [~] → nix-shell -I nixpkgs=channel:nixos-18.03 -p nix
    error: anonymous function at /nix/store/zakqwc529rb6xcj8pwixjsxscvlx9fbi-source/pkgs/top-level/default.nix:20:1 called with unexpected argument 'inNixShell'
           at /nix/store/zakqwc529rb6xcj8pwixjsxscvlx9fbi-source/pkgs/top-level/impure.nix:82:1:
               81|
               82| import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
                 | ^
               83|   inherit config overlays crossSystem;
This is a problem because one of the main selling points of Nix is that
you can evaluate any old Nix expression and still get the same result
(which also means that it *still evaluates*). In fact we're deprecating,
but not removing a lot of stuff for that reason such as unquoted URLs[2]
or `builtins.toPath`. However this property was essentially thrown away
here.
The change is rather simple: check if `inNixShell` is specified in the
formals of an auto-called function. This means that
    { inNixShell ? false }:
    builtins.trace inNixShell
      (with import <nixpkgs> { }; makeShell { name = "foo"; })
will show `trace: true` while
    args@{ ... }:
    builtins.trace args.inNixShell
      (with import <nixpkgs> { }; makeShell { name = "foo"; })
will throw the following error:
    error: attribute 'inNixShell' missing
This is explicitly needed because the function in
`pkgs/top-level/impure.nix` of e.g. NixOS 18.03 has an ellipsis[3], but
passes the attribute-set on to another lambda with formals that doesn't
have an ellipsis anymore (hence the error from above). This was perhaps
a mistake, but we can't fix it anymore. This also means that there's
AFAICS no proper way to check if the attr-set that's passed to the Nix
code via `EvalState::autoCallFunction` is eventually passed to a lambda
with formals where `inNixShell` is missing.
However, this fix comes with a certain price. Essentially every
`shell.nix` that assumes `inNixShell` to be passed to the formals even
without explicitly specifying it would break with this[4]. However I think
that this is ugly, but preferable:
* Nix 2.3 was declared stable by NixOS up until recently (well, it still
  is as long as 21.11 is alive), so most people might not have even
  noticed that feature.
* We're talking about a way shorter time-span with this change being
  in the wild, so the fallout should be smaller IMHO.
[1] NixOS@ 9d612c3 
[2] NixOS/rfcs#45 (comment)
[3] https://github.com/NixOS/nixpkgs/blob/release-18.03/pkgs/top-level/impure.nix#L75
[4] See e.g. the second expression in this commit-message or the changes
    for `tests/ca/nix-shell.sh`.

@Ma27 Ma27 mentioned this pull request

Jun 13, 2022

Merged

Ma27 added a commit to Ma27/nix that referenced this pull request

Jun 13, 2022
Basically an attempt to resume fixing NixOS#5543 for a breakage introduced
earlier[1]. Basically, when evaluating an older `nixpkgs` with
`nix-shell` the following error occurs:
    λ ma27 [~] → nix-shell -I nixpkgs=channel:nixos-18.03 -p nix
    error: anonymous function at /nix/store/zakqwc529rb6xcj8pwixjsxscvlx9fbi-source/pkgs/top-level/default.nix:20:1 called with unexpected argument 'inNixShell'
           at /nix/store/zakqwc529rb6xcj8pwixjsxscvlx9fbi-source/pkgs/top-level/impure.nix:82:1:
               81|
               82| import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
                 | ^
               83|   inherit config overlays crossSystem;
This is a problem because one of the main selling points of Nix is that
you can evaluate any old Nix expression and still get the same result
(which also means that it *still evaluates*). In fact we're deprecating,
but not removing a lot of stuff for that reason such as unquoted URLs[2]
or `builtins.toPath`. However this property was essentially thrown away
here.
The change is rather simple: check if `inNixShell` is specified in the
formals of an auto-called function. This means that
    { inNixShell ? false }:
    builtins.trace inNixShell
      (with import <nixpkgs> { }; makeShell { name = "foo"; })
will show `trace: true` while
    args@{ ... }:
    builtins.trace args.inNixShell
      (with import <nixpkgs> { }; makeShell { name = "foo"; })
will throw the following error:
    error: attribute 'inNixShell' missing
This is explicitly needed because the function in
`pkgs/top-level/impure.nix` of e.g. NixOS 18.03 has an ellipsis[3], but
passes the attribute-set on to another lambda with formals that doesn't
have an ellipsis anymore (hence the error from above). This was perhaps
a mistake, but we can't fix it anymore. This also means that there's
AFAICS no proper way to check if the attr-set that's passed to the Nix
code via `EvalState::autoCallFunction` is eventually passed to a lambda
with formals where `inNixShell` is missing.
However, this fix comes with a certain price. Essentially every
`shell.nix` that assumes `inNixShell` to be passed to the formals even
without explicitly specifying it would break with this[4]. However I think
that this is ugly, but preferable:
* Nix 2.3 was declared stable by NixOS up until recently (well, it still
  is as long as 21.11 is alive), so most people might not have even
  noticed that feature.
* We're talking about a way shorter time-span with this change being
  in the wild, so the fallout should be smaller IMHO.
[1] NixOS@ 9d612c3 
[2] NixOS/rfcs#45 (comment)
[3] https://github.com/NixOS/nixpkgs/blob/release-18.03/pkgs/top-level/impure.nix#L75
[4] See e.g. the second expression in this commit-message or the changes
    for `tests/ca/nix-shell.sh`.

Merged

Merged

Open

ursi added a commit to ursi/smos that referenced this pull request

Feb 12, 2023

This was referenced

Feb 12, 2023

Open

Merged

NorfairKing pushed a commit to NorfairKing/smos that referenced this pull request

Feb 13, 2023

ajs124 added a commit to helsinki-systems/nixpkgs that referenced this pull request

Feb 20, 2023
otherwise, eval fails when the experimental no-url-literals feature is activated
unquoted urls are discouraged after NixOS/rfcs#45

Merged

12 tasks

Merged

Closed

Merged

KAction pushed a commit to KAction/rfcs that referenced this pull request

Apr 13, 2024
* A small RFC on deprecating URL syntax
* Convert alternatives to a list
* Add a mention of tooling in future work
* A remark from @globin about one more problem with unquoted URLs
* Grammar edit: comparison of URLs, paths and strings.
Co-Authored-By: 7c6f434c <7c6f434c@mail.ru>
* Style edit: possibility of future removal
Co-Authored-By: 7c6f434c <7c6f434c@mail.ru>
* 0045: commit to using the tooling that now exists
* Update rfcs/0045-deprecate-url-syntax.md
Shepherd team
Co-Authored-By: Domen Kožar <domen@enlambda.com>
* Fix shepherd list
* Update based on a discussion
* Explicitly make future removal conditional on editions; restrict the claim about no special support to the Nix language itself

Closed

@Mic92 Mic92 mentioned this pull request

Aug 18, 2024

Merged

yu-re-ka pushed a commit to yu-re-ka/haskell.nix that referenced this pull request

Sep 5, 2024
It has been agreed upon by RFC process that this syntax is not to be used: NixOS/rfcs#45

Merged

hamishmack pushed a commit to input-output-hk/haskell.nix that referenced this pull request

Sep 5, 2024
It has been agreed upon by RFC process that this syntax is not to be used: NixOS/rfcs#45

Merged

3 tasks

Read the original on github.com ↗