Mic92 / nix-update

Swiss-knife for updating nix packages.
MIT License
504 stars 47 forks source link

Slashes in the name of an attribute result in a parse error, and should be put in quotes #178

Closed thoughtpolice closed 1 year ago

thoughtpolice commented 1 year ago

Consider the following example (which I'm afraid I can't release the code to), where I want to update an attribute under the name psql_15/exts/pg_hashids — traceback and some fluff omitted:

$ nix-update --flake --version=branch psql_15/exts/pg_hashids

...
error: undefined variable 'or'

       at «string»:7:40:

            6|   flake = getFlake "/home/austin/work/nix-postgres";
            7|   pkg = flake.packages.${currentSystem}.psql_15/exts/pg_hashids or flake.psql_15/exts/pg_hashids;
             |                                        ^
            8|   inherit (flake) outPath;
Traceback (most recent call last):
...

The error'ing line itself is pretty clear:

pkg = flake.packages.${currentSystem}.psql_15/exts/pg_hashids or flake.psql_15/exts/pg_hashids;

The name is generated by way of flattenTree from flake-utils so, it isn't exactly a super strange case IMO. I think just enclosing the name in general is enough if there's a slash. Really, we could just do this unconditionally, since there isn't any real difference between x.y and x."y" other than variable interpolation?

The following command works, in contrast, but is obviously strange:

nix-update --flake --version=branch \"psql_15/exts/pg_hashids\"

figsoda commented 1 year ago

could you test if #179 fixes the issue for you?

thoughtpolice commented 1 year ago

Yep, that works. Thanks!