{"id":20850417,"url":"https://github.com/noteed/multiple-ghc-versions","last_synced_at":"2025-06-21T09:36:25.925Z","repository":{"id":226641654,"uuid":"769256152","full_name":"noteed/multiple-ghc-versions","owner":"noteed","description":"Learning to use multiple GHC versions with a Nix-based Haskell project.","archived":false,"fork":false,"pushed_at":"2024-03-08T20:19:29.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T12:33:10.593Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noteed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-08T17:02:22.000Z","updated_at":"2024-03-08T17:02:44.000Z","dependencies_parsed_at":"2025-03-12T12:39:15.868Z","dependency_job_id":null,"html_url":"https://github.com/noteed/multiple-ghc-versions","commit_stats":null,"previous_names":["noteed/multiple-ghc-versions"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/noteed/multiple-ghc-versions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fmultiple-ghc-versions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fmultiple-ghc-versions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fmultiple-ghc-versions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fmultiple-ghc-versions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noteed","download_url":"https://codeload.github.com/noteed/multiple-ghc-versions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noteed%2Fmultiple-ghc-versions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261101055,"owners_count":23109853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T03:09:21.575Z","updated_at":"2025-06-21T09:36:20.908Z","avatar_url":"https://github.com/noteed.png","language":"Nix","readme":"# Experimenting with multiple GHC versions under Nix\n\nNote: having a look at the Git history from this repository may help.\n\n# Trying horizon-haskell.\n\nI want to try to use horizon-haskell to provide different GHC versions and\nrelated packages. It is using flakes, but it is possible to use\n`builtins.getFlake` in a project that doens't have a `flake.nix` file.\n\nI have a working use case in Ream.\n\nIn this directory, I experiment with two dummy Haskell projects, A and B, with\nB depending on A. The way I setup my Haskell projects is derived from how it\nwas done in Curiosity. It is done in a `nix/` directory providing\n`contents.nix`, `overlay.nix`, and `overlays.nix`. The second depends on the\nfirst, and the third depends on the second. Finally, `default.nix` import a\n`nixpkgs` using the third as an overlay.\n\nWhen creating a project that depends on another one (e.g. Curiosity depends on\nCommence), the `overlays.nix` from the dependencies are explicitely imported in\na single list in `overlays.nix`.\n\nI think that in the case of horizon-haskell, I should expose the overriding\nfunction (usually called `overrides` in `contents.nix` (instead of in\n`overlay.nix`), so that I can use that instead of `overlays.nix`.\n\nTo check that this works as intended, I create two projects in this directory,\nA and B, using the existing approach, then I'll modify them as described above.\n\nSo it works. With the previous overlay approach, all the dependencies overlays\nare listed in `overlays.nix`. For horizon-platform, all the overriding\nfunctions are listed in `overlay.nix` instead.\n\n# Multiple GHC versions\n\nIndependently from horizon-haskell, this shows how to build project A and B\nwith a different GHC version than the default one (the default is ghc928):\n\n```\n$ cd a  # or b\n$ nix-build -A binaries --no-out-link --argstr compiler ghc942\n$ nix-build -A binaries --no-out-link --argstr compiler ghc962\n```\n\nBuilding with ghc962 doesn't work. (I think template-haskell 2.20 is selected,\nbut language-haskell-extract need `\u003c2.16`.)\n\nNote: with this change (the `compiler` argument), in `overlay.nix`, we no\nlonger define `haskellPackages` in term of `haskellPackages`, but in term of\n`haskell.packages.\"${compiler}\"`, and we have to pass all the \"overrides\",\ninstead of being able to build on top of `old.overrides` with only our current\n`contents.overrides`.\n\n# Multiple Nixpkgs versions\n\nSimilarly to having multiple GHC versions, it might be useful to be able to\nbuild a package against multiple Nixpkgs versions.\n\nTo do that, we introduce a `pkgssrc` argument to the `default.nix` file, that\nmust be provided by `sources.json`. Such an alternative Nixpkgs can be added\nfor instance with:\n\n```\n$ niv add NixOS/nixpkgs -n nixos-23.10 -b nixos-23.11\n```\n\nGiven multiple Nixpkgs in `sources.json`, we can select the one we want with:\n\n```\n$ nix-build -A binaries --no-out-link --argstr pkgssrc nixos-23.11\n```\n\n# Combinations\n\nThe different versions of both GHC and Nixpkgs can be combined. To list and\nbuild easily those combinations, a `release.nix` file is provided.\n\n# Resources\n\nThis repository uses Nix and Haskell without flakes, and has multiple GHC\nversions: https://github.com/awakesecurity/proto3-suite.\n\nI've seen repository that don't use Nix use this kind of things:\nhttps://github.com/haskell-actions/. Servant is one example.\n\n# TODO\n\nI'm wondering how, if necessary, I should work on\nhttps://github.com/jhickner/smtp-mail or  https://github.com/tibbe/template.\nThey were repositories that are not present in horizon-platform.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoteed%2Fmultiple-ghc-versions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoteed%2Fmultiple-ghc-versions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoteed%2Fmultiple-ghc-versions/lists"}