Skip to content

haskell.{compiler,packages}.microhs: init at 0.15.4.0#460845

Merged
sternenseemann merged 5 commits into
NixOS:masterfrom
AlexandreTunstall:hfs-upstream-mhspkgs
Apr 9, 2026
Merged

haskell.{compiler,packages}.microhs: init at 0.15.4.0#460845
sternenseemann merged 5 commits into
NixOS:masterfrom
AlexandreTunstall:hfs-upstream-mhspkgs

Conversation

@AlexandreTunstall

Copy link
Copy Markdown
Contributor

This change adds microhs-based packagesets to the haskell.packages package sets.
For example, haskell.packages.microhs.mtl is a working microhs-compiled mtl package.

The microhs compilers added here replace the recently added microhs package.
Unlike the previous version, all new versions are built entirely from source by using Hugs to interpret the microhs source code.
cpphs was also booted from source in a similar way.

The goal is to allow Nixpkgs users to more easily experiment with using microhs, and perhaps one day boot GHC from source.
Note, however, that nix-shell (and related derivations) is completely untested.

A few patches were needed to make microhs and microcabal behave properly inside the Nix store, all of which I will seek to upstream.
The patch to make microhs Hugs-compatible is more of a hack, and I expect keeping microhs Hugs-compatible to be too troublesome to be worth upstreaming.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 6.topic: haskell General-purpose, statically typed, purely functional programming language 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` labels Nov 12, 2025
@dmjio dmjio mentioned this pull request Nov 12, 2025
15 tasks
@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Nov 12, 2025
@AlexandreTunstall AlexandreTunstall changed the title haskell.{compiler,packages}.microhs: init at 0.14.21.0 haskell.{compiler,packages}.microhs: init at 0.14.25.0 Nov 19, 2025
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. and removed 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. labels Nov 19, 2025

@steeleduncan steeleduncan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could I ask what the reasoning for all the revision-versioned microhs packages is?

I know it is done with GHC, but that is an outlier for nixpkgs. With e.g. gcc, clang, go, etc there are only packages for the major versions with (deliberately) backwards incompatible changes

@steeleduncan steeleduncan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a fix to another commit in this PR it should be merged with that commit (ie the initial haskell.{compiler,packages}.microhs-*: init commit)

@AlexandreTunstall

AlexandreTunstall commented Nov 19, 2025

Copy link
Copy Markdown
Contributor Author

Since 0.14.17.0, array isn't included in microhs' base package. Many packages still work without it.

Would that count as "a fix to another commit"? I'm not sure.

@AlexandreTunstall

Copy link
Copy Markdown
Contributor Author

Could I ask what the reasoning for all the revision-versioned microhs packages is?

For now, it is solely about making the versions available. There is no particular reason.

If you think that only having the latest version would be better, that is doable, but it will require bumping the boot compiler, and therefore also the Hugs compatibility patch, more frequently.

Perhaps we should check with upstream what the versioning policy is, if any?

@steeleduncan

Copy link
Copy Markdown
Contributor

Looking at the MicroHs repo, there are 15 tags/versions in the last 3 months. Keeping up with a version a week would be a significant maintenance burden, and eventually that number of extra derivations would noticeably affect evaluation and rebuild times.

When old versions of programming languages are supported in Nixpkgs, they tend to get removed when there is no further support (e.g. node.js < 20 is gone now). There doesn't seem to be any intention of support for the old MicroHs versions, so I think having just the latest version would be appropriate here.

Perhaps we should check with upstream what the versioning policy is, if any?

It would make sense. I don't think a programming language with weekly breaking changes could ever be useful, but it would be useful to know if the intentions is for an occasional major version upgrade with breaking changes

@steeleduncan

Copy link
Copy Markdown
Contributor

Would that count as "a fix to another commit"? I'm not sure.

Possibly I am misunderstanding, but the oldest version of the compiler supported by this PR is 0.14.17.0, so if 97260bc3483744eab990c3be4d736333d2915303 is needed to fix every version from 0.14.17.0 onwards, I would have thought it should be part of the initial commit

@AlexandreTunstall

Copy link
Copy Markdown
Contributor Author

There is 0.14.15.0, which will fail with the fix. But that only matters if I don't update the Hugs patch to 0.14.25.0 as I look into dropping the older versions.

@Atemu Atemu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no specific need for other versions, I see no reason to keep them.

I propose we strive for the least amount of mhs compilers possible to complete bootstrap to the newest one.
Ideally, this would be 1 but that's unrealistic.

I could see a chain like this though:

  1. hugs-compatible mhs ran/built via hugs
  2. mhs that can build latest
  3. latest mhs


inherit (microhs-src) src;

patches = [ patches/hugs.patch ];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a vendored patch rather than just fetching the upstream hugs branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upstream hugs branch is not kept up-to-date.

We might be able to use the ancient version if we patch out all the newer primitives, but I expect that it would only get less compatible over time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

If you're going to do that work anyway though.. why not just do it upstream?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch mostly replaces uses of ViewPatterns with isJust. It's not pretty code, but I could ask upstream.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch looks okay to maintain since it's not that deep. I wouldn't expect the ViewPatterns stuff to be merged because it is ugly code often enough.

We could try to upstream some of this though, e.g. what about adding a HUGS cpp definition which handles all the removal e.g. of the NFData stuff, seqs and interactive mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. what about adding a HUGS cpp definition which handles all the removal

I'd prefer to avoid CPP because it would complicate the bootstrap (mhs doesn't require CPP).
That said, I will see what I can do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes except for the ViewPatterns fixes, without CPP: augustss/MicroHs#429.

Comment thread pkgs/development/compilers/microhs/boot.nix Outdated
Comment thread pkgs/development/compilers/microhs/boot.nix Outdated
Comment thread pkgs/development/compilers/microhs/common.nix Outdated
Comment thread pkgs/development/compilers/microhs/common.nix Outdated
@sternenseemann

Copy link
Copy Markdown
Member

I get the following when building hscolour which I thought would be a nice test case for a non trivial executable?

Running phase: setupCompilerEnvironmentPhase
@nix { "action": "setPhase", "phase": "setupCompilerEnvironmentPhase" }
Building with /nix/store/fzbf3vx5aj58msg6g4caav35hv3gi3r7-microhs-0.15.3.0-wrapped
ln: failed to create symbolic link '/nix/store/24xydijijbw9f9bv2qdsscn03yabs8lz-hscolour-1.25/lib/mcabal/mhs-0.15.3.0/packages/containers-0.8.pkg': File exists

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Apr 8, 2026
@AlexandreTunstall

Copy link
Copy Markdown
Contributor Author

I've noticed while going through your comments that the current version is a breaking change (microhs moved to haskell.compiler.microhs).
Since ghc is re-exported at the top-level, I'll add microhs back as an alias to haskell.compiler.microhs.

@sternenseemann

sternenseemann commented Apr 8, 2026

Copy link
Copy Markdown
Member

I already did that in eeb3e9b, though we may want to make it an actual alias that can be deprecated later?

@AlexandreTunstall AlexandreTunstall changed the title haskell.{compiler,packages}.microhs: init at 0.15.3.0 haskell.{compiler,packages}.microhs: init at 0.15.4.0 Apr 8, 2026
@nixpkgs-ci nixpkgs-ci Bot added 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation and removed 8.has: package (new) This PR adds a new package 2.status: merge conflict This PR has merge conflicts with the target branch labels Apr 8, 2026
AlexandreTunstall and others added 3 commits April 9, 2026 22:33
The package set is built entirely from source using the stdenv and Hugs.

This also replaces the recently added microhs package, which was built
from pre-generated compiler output.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
AlexandreTunstall and others added 2 commits April 9, 2026 22:39
Test the GHC boot packages that are known to work with MicroHs and mark
those that don't work as broken.
Packages that have an empty hydraPlatforms won't be tested on Hydra
otherwise, even if explicitly requested.
@sternenseemann
sternenseemann added this pull request to the merge queue Apr 9, 2026
Merged via the queue into NixOS:master with commit bc9ff3c Apr 9, 2026
6 of 8 checks passed
sternenseemann added a commit to sternenseemann/nixpkgs that referenced this pull request Apr 11, 2026
This makes isNativeBignumGhc purely textual again after NixOS#460845.
Could improve performance in the right conditions, but most importantly
solves eval issues with aliases allowed (due to the throw-ing ghc
attributes) without resorting to tryEval.
alexfmpe pushed a commit to alexfmpe/nixpkgs that referenced this pull request Apr 11, 2026
This makes isNativeBignumGhc purely textual again after NixOS#460845.
Could improve performance in the right conditions, but most importantly
solves eval issues with aliases allowed (due to the throw-ing ghc
attributes) without resorting to tryEval.
halfwhey pushed a commit to halfwhey/nixpkgs that referenced this pull request Apr 12, 2026
This makes isNativeBignumGhc purely textual again after NixOS#460845.
Could improve performance in the right conditions, but most importantly
solves eval issues with aliases allowed (due to the throw-ing ghc
attributes) without resorting to tryEval.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: haskell General-purpose, statically typed, purely functional programming language 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Development

Successfully merging this pull request may close these issues.

5 participants