Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixpkgs-vet should throw error when package attribute name in by-name is prefixed with a number #107

Open
Aleksanaa opened this issue Sep 8, 2024 · 5 comments
Labels
good first issue Good for newcomers

Comments

@Aleksanaa
Copy link
Member

Aleksanaa commented Sep 8, 2024

In NixOS/nixpkgs#333281 the package attribute name is prefixed with 1 but nixpkgs-vet agreed with that. This may cause problems for us later, as nix treats "1a", 1a and _1a differently. I edited the title to rerun the check and confirmed that it still didn't throw an error.

@philiptaron
Copy link
Contributor

I see that this does actually work through both nix build .#1fps and nix-build -A 1fps, though, and also works if the attrset name is stringified.

nix-repl> pkgs."1fps"
«derivation /nix/store/b8d1br1rjq4i1yw8w5l71b5c26cqacrz-1fps-0.1.10.drv»

nix-repl> pkgs.1fps
error: undefined variable 'fps'

       at «string»:1:7:

            1| pkgs.1fps
             |       ^

Is the core reason it should be discouraged that a package like this can't be expressed as a dependency in callPackage argument lists?

nix-repl> { 1fps }: null
error: syntax error, unexpected INT

       at «string»:1:3:

            1| { 1
             |   ^

@Aleksanaa
Copy link
Member Author

Is the core reason it should be discouraged that a package like this can't be expressed as a dependency in callPackage argument lists?

...Yes, in other situations we just need quotes.

@infinisil
Copy link
Member

Oh this would be nice, and should be simple to implement

@infinisil infinisil added the good first issue Good for newcomers label Sep 8, 2024
@infinisil
Copy link
Member

I'll refrain from implementing this, I think this is a great first issue for perhaps a new contributor

@Aleksanaa
Copy link
Member Author

Aleksanaa commented Sep 8, 2024

https://github.com/NixOS/nixpkgs-vet/blob/main/src/structure.rs#L16-L19

The correct regex would be:

shard: ^((_[0-9])|([a-z][a-z0-9_-]?))$
package: ^((_[0-9])|[a-zA-Z])[a-zA-Z0-9_-]*$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants