Skip to content

Update the Nix build #5796

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

Draft
wants to merge 14 commits into
base: trunk
Choose a base branch
from
Draft

Update the Nix build #5796

wants to merge 14 commits into from

Conversation

sellout
Copy link
Contributor

@sellout sellout commented Jul 8, 2025

This brings everything Nix-related up to date.1

  • Cabal 3.10.3.0 → 3.14.2.0
  • GHC 9.6.5 → 9.6.7
  • haskell-language-server 2.8.0.0 → 2.10.0.0
  • hpack 0.35.2 → 0.38.0
  • Ormolu 0.7.2.0 → 0.7.4.0
  • Stack 2.15.5 → 3.5.1

It also shrinks the closure size (mostly by eliminating a number of Nixpkgs inputs), adopts the nix-systems pattern to
allow downstream control over the included systems, and makes a number of other minor changes.

Footnotes

  1. The GHC update also affects all Stack builds and the Cabal, HLS, and Stack updates also affect VS Code users.

sellout added 11 commits July 7, 2025 09:30
On macOS, it requires access to `security`, which is outside the
sandbox, so don’t sandbox it when running on Darwin.

This is made possible by setting `sandbox` to `relaxed` in the flake,
which allows using `__noChroot` to mark derivations as unsandboxed. This
makes things less strict on Linux (where the sandbox is on by default),
but more strict on Darwin (where the sandbox is off by default).
This allows us to install a different version than the one included in
Nixpkgs (although we don’t currently do that). It also makes some
syntactic changes to other tools for consistency.
This reduces the closure size a bit, and puts us on a consistent Nixpkgs
version.

This forces an upgrade of Stack from 2.15.7 to 3.5.1, and
correspondingly an upgrade of hpack from 0.35.2 to 0.38.0.
Updating Nixpkgs resulted in a pile of “GHC 9.6.5 is out of date”
warnings, so this brings us to the end of the 9.6 line.

GHC is managed by the Stack resolver, so we can upgrade to GHC 9.8.4 or
9.10.2 without modifying the flake.
This ensures we’re using the versions in Nixpkgs.

- cabal 3.10.3.0 → 3.14.2.0
- haskell-language-server 2.8.0.0 → 2.10.0.0
This ensures we’re using the version in Nixpkgs. It also reformats
everything.

- ormolu 0.7.2.0 → 0.7.4.0
This workaround required another local workaround. If you had a line
like `LD_LIBRARY_PATH=` in your .envrc, it can be removed now.
It is not triggering a(nother) rebuild of GHC.
Somewhat described at https://github.com/nix-systems/nix-systems

This is useful for Haskell projects, because commands like

```bash
nix flake show --allow-import-from-derivation
```

can often fail, complaining that it can’t find some other architecture
to build on. With nix-systems, you can append
`--override-input systems github:nix-systems/x86_64-linux` to the
command to ensure that x86_64-linux is the only platform in play.

This also adds aarch64-linux to the matrix, since that is one of the
“default” systems in flake-utils.
@ceedubs
Copy link
Contributor

ceedubs commented Jul 8, 2025

From the Nix side this looks reasonable to me, but I vaguely remember there being some discussions in the past about specific Stack versions and what we should be on. I think that the main thing is just to keep people on roughly the same Stack versions? Anyway @aryairani, @mitchellwrosen, and @dolio (whom I don't think cares about the Stack version but probably does GHC) should probably be the ones to weigh in on that.

@sellout
Copy link
Contributor Author

sellout commented Jul 8, 2025

I vaguely remember there being some discussions in the past about specific Stack versions and what we should be on. I think that the main thing is just to keep people on roughly the same Stack versions?

Right. I think nix/versions.nix (which imports .vscode/settings.json) is the current best effort for that. That file could use a bit more documentation, but it’s

  • checked/enforced by the Nix build,
  • enforced(?) by the VS Code Haskell plugin,
  • checked by scripts/check-formatting, and
  • linked from development.markdown for contributors whose tooling doesn’t handle it automatically1.

IMO, places that set versions outside of nix/versions.nix3 are bugs to be fixed. E.g., we could templatize files that mention versions (e.g., GitHub workflows, .vscode/settings.json, check-formatting), and regenerate them during some part of the build.

That said, I’m happy to get pushback on the specific versions (some are easier to convince Nix to change than others) and on the overall method for keeping versions in sync.

Footnotes

  1. And even the automatic stuff is not as great as it could be – e.g., VS Code lets you specify the HLS version, but not the version of Ormolu that HLS will use; and it lets you specify the Stack version, but not the version of hpack2 that Stack will use.

  2. At least with hpack, if we stay on a fairly recent version, we prevent accidental reversion, but we’re not so lucky with Ormolu.

  3. This could also become like versions.yaml or something, if we ever use it for generating files, to avoid requiring Nix for that process.

@ceedubs
Copy link
Contributor

ceedubs commented Jul 8, 2025

This derivation builds fine for me, but when I try to stack build in the resulting shell I get a bunch of errors like:

       /home/unison/code/unison/codebase2/util-serialization/U/Util/Serialization.hs:58:21: error: [GHC-83865]                                                                                                      
           • Couldn't match expected type ‘bytestring-0.11.5.4:Data.ByteString.Internal.Type.ByteString’                                                                                                            
                         with actual type ‘ByteString’                                                                                                                                                              
             NB: ‘bytestring-0.11.5.4:Data.ByteString.Internal.Type.ByteString’                                                                                                                                     
                   is defined in ‘Data.ByteString.Internal.Type’                                                                                                                                                    
                       in package ‘bytestring-0.11.5.4’                                                                                                                                                             
                 ‘ByteString’                                                                                                                                                                                       
                   is defined in ‘Data.ByteString.Internal.Type’                                                                                                                                                    
                       in package ‘bytestring-0.11.5.4’                                                                                                                                                             
           • In the second argument of ‘runGetS’, namely ‘bytes’                                                                                                                                                    
             In the expression: runGetS getA bytes                                                                                                                                                                  
             In the expression:                                                                                                                                                                                     
               case runGetS getA bytes of                                                                 
                 Left _ -> Nothing                                                                                                                                                                                  
                 Right a -> Just a                                                                                                                                                                                  
          |                                                                                                                                                                                                         
       58 |   case runGetS getA bytes of Left _ -> Nothing; Right a -> Just a                                                                                                                                       
          |                     ^^^^^

No amount of deleting stack files seems to help with this.

sellout added 2 commits July 8, 2025 23:44
We had conditionally enabled it on Linux, but it just made the builds
inconsistent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants