-
-
Notifications
You must be signed in to change notification settings - Fork 158
FromCabal.Name: prefix pkg names with _ if they can't be identifiers #672
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
base: master
Are you sure you want to change the base?
Conversation
Seems this currently generates broken expressions since |
85294ab
to
cdaaaed
Compare
Resolved that, but there may be similar issues lurking! |
Love it! |
Is the nixpkgs diff in the PR description from before or after that fix? |
Before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Do we want to do this for 25.11? I think it's basically ready and we could even add aliases for the attributes that would get changed. |
I'd say yes, let's do it. |
While we can quote attribute names, we can't use quoting to use arbitrary strings as function arguments in Nix unfortunately. This means we couldn't previously generate expressions for packages that depend on packages that start with numbers or clash with keywords. To fix this, we simply prefix the offending packages with an underscore. This mirrors an existing Nixpkgs convention (see e.g. pkgs._2bwm). This mapping work for all Hackage packages and is easily reversible by just removing the underscore. We can never introduce ambiguity this way since Cabal doesn't allow underscores in package names. Cabal packages not conforming to Hackage's restrictions won't work yet. For this, we would need to implement some kind of encoding. Resolves #163. Resolves #164.
The package expression for acme-everything is huge since it has to list all packages released to Hackage as of 2018 twice. As this package isn't actually useful and probably doesn't even have a valid install plan, we can remove it to keep the size of hackage-packages.nix in check. In the future, such exclusions should be decided by configurable exclusions as proposed in #667. It may be a prudent idea to use the spam and acme categories of Hackage as a baseline for package exclusions. This partially reverts commit d105bfc.
cdaaaed
to
804298e
Compare
nixpkgs <- readNixpkgPackageMap nixpkgsRepository (Just "{ config = { allowAliases = false; }; }") | ||
preferredVersions <- readPreferredVersions (fromMaybe (hackageRepository </> "preferred-versions") preferredVersionsFile) | ||
let fixup = over (at "hermes") (fmap (set (contains "1.3.4.3") False)) -- TODO: https://github.com/haskell/hackage-server/issues/436 | ||
let fixup = Map.delete "acme-everything" -- TODO(@wolfgangwalther): remove after https://github.com/NixOS/cabal2nix/pull/667 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫡
- In general, one should Identifier and its instances to render and parse Identifiers. quote has been relegated to an Internals section since it is only required by the test suite at the moment. It may be nice to remove it at some point. - needsQuoting deals with arbitrary strings and would normally be used to judge whether a given String should be converted to an Identifier directly or first be subject to some kind of substitution so that it does not need to be quoted (see #672). nixKeywords is an internal definition involved with this which is also used in the test suites.
While we can quote attribute names, we can't use quoting to use arbitrary strings as function arguments in Nix unfortunately. This means we couldn't previously generate expressions for packages that depend on packages that start with numbers or clash with keywords.
To fix this, we simply prefix the offending packages with an underscore. This mirrors an existing Nixpkgs convention (see e.g. pkgs._2bwm). This mapping work for all Hackage packages and is easily reversible by just removing the underscore. We can never introduce ambiguity this way since Cabal doesn't allow underscores in package names.
Cabal packages not conforming to Hackage's restrictions won't work yet. For this, we would need to implement some kind of encoding.
Resolves #163.
Resolves #164.
Nixpkgs diff
Note that I removed the addition of
acme-everything
which accounts for most of the diff so that it fits in the github comment. We should probably putacme-everything
in exclude packages or a similar mechanism.