Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into andrea/combinations
Browse files Browse the repository at this point in the history
# Conflicts:
#	flake.nix
  • Loading branch information
hamishmack committed Oct 20, 2023
2 parents d3b1b55 + fb0fbe3 commit 117b356
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
type: string
compiler-nix-name:
required: true
description: 'compiler name in nix format. e.g. ghc8107'
description: 'compiler name in nix format. e.g. ghc96'
type: string
minimal:
description: 'without hls, hlint, ...'
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ jobs:
# Currently broken
#- aarch64-linux
compiler-nix-name:
- ghc8107
- ghc928
- ghc962
- ghc810
- ghc92
- ghc96
- ghc98
- ghc99
target-platform:
- ""
- "-static"
Expand All @@ -51,9 +53,9 @@ jobs:
- "-iog"
exclude:
# Just cross compiling javascript with ghc 9.6.2 for now
- compiler-nix-name: ghc8107
- compiler-nix-name: ghc810
target-platform: "-js"
- compiler-nix-name: ghc928
- compiler-nix-name: ghc92
target-platform: "-js"
# Static builds not working for darwin yet
- platform: x86_64-darwin
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/wait-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
type: string
compiler-nix-name:
required: true
description: 'compiler name in nix format. e.g. ghc8107'
description: 'compiler name in nix format. e.g. ghc96'
type: string
minimal:
description: 'without hls, hlint, ...'
Expand Down Expand Up @@ -112,8 +112,8 @@ jobs:
# or the `-static` one (especially since the latter currently requires `-minimal` to work).
# Likely, we consider using `-iog` as the default and do not generate other images.
# Then the user choices left would be between native, `-windows` or `-js` target platforms,
# and the GHC version (currently `ghc8107` and `ghc962`).
if: ${{ contains(fromJSON('["x86_64-linux", "aarch64-linux"]'), inputs.platform) && contains(fromJson('["","-windows","-js"]'), inputs.target-platform) && contains(fromJson('["ghc8107","ghc962"]'), inputs.compiler-nix-name) && !inputs.minimal && inputs.iog }}
# and the GHC version (currently `ghc810` and `ghc96`).
if: ${{ contains(fromJSON('["x86_64-linux", "aarch64-linux"]'), inputs.platform) && contains(fromJson('["","-windows","-js"]'), inputs.target-platform) && contains(fromJson('["ghc810","ghc96"]'), inputs.compiler-nix-name) && !inputs.minimal && inputs.iog }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Once you have `nix` installed you can check that everything is working correctly
Once you have `nix`, (linux, macOS, windows WSL) you can use

```bash
nix develop github:input-output-hk/devx#ghc8107 --no-write-lock-file --refresh
nix develop github:input-output-hk/devx#ghc96 --no-write-lock-file --refresh
```

to obtain a haskell evelopment shell for GHC 8.10.7 including `cabal-install`,
Expand All @@ -23,11 +23,11 @@ and want to switch between Intel (x86_64) and Apple Silicon (aarch64), you can d
this by simply passing the corresponding `--system` argument:

```bash
nix develop github:input-output-hk/devx#ghc8107 --no-write-lock-file --refresh --system x86_64-darwin
nix develop github:input-output-hk/devx#ghc810 --no-write-lock-file --refresh --system x86_64-darwin
```
or
```bash
nix develop github:input-output-hk/devx#ghc8107 --no-write-lock-file --refresh --system aarch64-darwin
nix develop github:input-output-hk/devx#ghc810 --no-write-lock-file --refresh --system aarch64-darwin
```

## `direnv` integration
Expand All @@ -39,7 +39,7 @@ if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi
# https://github.com/input-output-hk/devx Slightly opinionated shared GitHub Action for Cardano-Haskell projects
use flake "github:input-output-hk/devx#ghc8107-iog"
use flake "github:input-output-hk/devx#ghc810-iog"
```

Refer to [`direnv` and `devx`](./docs/direnv.md) guide for more information.
Expand All @@ -49,7 +49,7 @@ Refer to [`direnv` and `devx`](./docs/direnv.md) guide for more information.
To make this developer shell available in VSCode DevContainer or GitHub CodeSpace, simply add a file named `.devcontainer/devcontainer.json` with the following content:
```json
{
"image":"ghcr.io/input-output-hk/devx-devcontainer:ghc8107-iog",
"image":"ghcr.io/input-output-hk/devx-devcontainer:ghc810-iog",
"customizations":{
"vscode":{
"extensions":[
Expand All @@ -66,35 +66,35 @@ This configuration will work immediately in GitHub CodeSpace! For local VSCode D

It's also advise to enable GitHub CodeSpace prebuilds in your repository settings, follow the instructions provided in the [GitHub documentation](https://docs.github.com/en/codespaces/prebuilding-your-codespaces/configuring-prebuilds). This will significantly enhance your development experience by reducing the setup time when opening a new CodeSpace.

List of images available: `ghc8107-iog`, `ghc962-iog`, `ghc8107-js-iog`, `ghc962-js-iog`, `ghc8107-windows-iog`, `ghc962-windows-iog`
List of images available: `ghc810-iog`, `ghc96-iog`, `ghc810-js-iog`, `ghc96-js-iog`, `ghc810-windows-iog`, `ghc96-windows-iog`

## Compilers and Flavours

There are multiple compilers available, and usually the latest for each series
from 8.10 to 9.6 (a slight delay between the official release announcement and
the compiler showing up in the devx shell is expected due to integration work
necessary). The current available ones are: `ghc8107`, `ghc902`, `ghc928`,`ghc945`, and
`ghc962` (these are the same ones as in [haskell.nix](https://github.com/input-output-hk/haskell.nix) and may contain patches for defects in the official releases).
necessary). The current available ones are: `ghc810`, `ghc90`, `ghc92`,`ghc94`, and
`ghc96` (these are the same ones as in [haskell.nix](https://github.com/input-output-hk/haskell.nix) and may contain patches for defects in the official releases).

### Flavours
There are various flavours available as suffixes to the compiler names (e.g. `#ghc8107-minimal-iog`).
There are various flavours available as suffixes to the compiler names (e.g. `#ghc810-minimal-iog`).

| Flavour | Description | Example | Included |
| - | - | - | - |
| empty | General Haskell Dev | `#ghc8107` | `ghc`, `cabal-install`, `hls`, `hlint` |
| `-iog` | IOG Haskell Dev | `#ghc8107` | adds `sodium-vrf`, `blst`, `secp256k1`, `R`, `postgresql` |
| `-minimal` | Only GHC, and Cabal | `#ghc8107-minimal` | drops `hls`, `hlint` |
| `-static` | Building static binaries | `#ghc8107-static` | static haskell cross compiler |
| `-js` | JavaScript Cross Compiler | `#ghc8107-js` | javascript haskell cross compiler |
| `-windows` | Windows Cross Compiler | `#ghc8107-windows` | windows haskell cross compiler |
| empty | General Haskell Dev | `#ghc810` | `ghc`, `cabal-install`, `hls`, `hlint` |
| `-iog` | IOG Haskell Dev | `#ghc810` | adds `sodium-vrf`, `blst`, `secp256k1`, `R`, `postgresql` |
| `-minimal` | Only GHC, and Cabal | `#ghc810-minimal` | drops `hls`, `hlint` |
| `-static` | Building static binaries | `#ghc810-static` | static haskell cross compiler |
| `-js` | JavaScript Cross Compiler | `#ghc810-js` | javascript haskell cross compiler |
| `-windows` | Windows Cross Compiler | `#ghc810-windows` | windows haskell cross compiler |

these can then be comined following this schema:
```
#ghc<ver>[-js|-windows|-static][-minimal][-iog]
```
For example
```bash
nix develop github:input-output-hk/devx#ghc8107-windows-minimal-iog --no-write-lock-file --refresh
nix develop github:input-output-hk/devx#ghc810-windows-minimal-iog --no-write-lock-file --refresh
```
would provide a development shell with a windows cross compiler as well as cabal, and the IOG specific libraries, but no Haskell Language Server (hls), and no HLint.

Expand Down
14 changes: 9 additions & 5 deletions cross-js.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
let tool-version-map = import ./tool-map.nix;
tool = tool-name: pkgs.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
cabal-install = tool "cabal";
cabal-install = pkgs.haskell-nix.nix-tools-unchecked.exes.cabal;
# add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler.
compiler-not-in = compiler-list: name: (if __elem compiler-nix-name compiler-list then __trace "No ${name}. Not yet compatible with ${compiler-nix-name}" false else true);

Expand Down Expand Up @@ -73,14 +73,18 @@ pkgs.mkShell ({

nativeBuildInputs = [ wrapped-hsc2hs wrapped-cabal compiler ] ++ (with pkgs; [
nodejs # helpful to evaluate output on the commandline.
haskell-nix.cabal-install.${compiler-nix-name}
pkgconfig
cabal-install
(pkgs.pkg-config or pkgconfig)
(tool "happy")
(tool "alex")
stdenv.cc.cc.lib ]) ++ (with pkgs.buildPackages; [
])
++ pkgs.lib.optional (withHLS) (tool "haskell-language-server")
++ pkgs.lib.optional (withHlint && (compiler-not-in ["ghc961" "ghc962"] "HLint")) (tool "hlint")
++ pkgs.lib.optional (withHLS && (compiler-not-in (
pkgs.lib.optional (builtins.compareVersions compiler.version "9.9" >= 0) compiler-nix-name
++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server")
++ pkgs.lib.optional (withHlint && (compiler-not-in (
pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name
++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint")
++ pkgs.lib.optional withIOG
(with pkgs; [ cddl cbor-diag ]
++ map pkgs.lib.getDev (with pkgs; [
Expand Down
18 changes: 11 additions & 7 deletions cross-windows.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
let tool-version-map = import ./tool-map.nix;
tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name (tool-version-map compiler-nix-name tool-name);
cabal-install = tool "cabal";
tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
cabal-install = pkgs.pkgsBuildBuild.haskell-nix.nix-tools-unchecked.exes.cabal;
# add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler.
compiler-not-in = compiler-list: name: (if __elem compiler-nix-name compiler-list then __trace "No ${name}. Not yet compatible with ${compiler-nix-name}" false else true);

Expand Down Expand Up @@ -157,17 +157,21 @@ pkgs.pkgsBuildBuild.mkShell ({
buildPackages.bintools.bintools
stdenv.cc
pkgsBuildBuild.haskell-nix.cabal-install.${compiler-nix-name}
pkgsBuildBuild.pkgconfig
(pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name "happy" "1.20.1.1")
(pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name "alex" "3.2.7.3")
(pkgsBuildBuild.pkg-config or pkgsBuildBuild.pkgconfig)
(tool "happy")
(tool "alex")
stdenv.cc.cc.lib ])
++ map pkgs.lib.getDev (with pkgs; [
zlib pcre openssl
windows.mcfgthreads
windows.mingw_w64_pthreads
])
++ pkgs.lib.optional (withHLS && (compiler-not-in (pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server")
++ pkgs.lib.optional (withHlint && (compiler-not-in (["ghc961" "ghc962"] ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint")
++ pkgs.lib.optional (withHLS && (compiler-not-in (
pkgs.lib.optional (builtins.compareVersions compiler.version "9.9" >= 0) compiler-nix-name
++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server")
++ pkgs.lib.optional (withHlint && (compiler-not-in (
pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name
++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint")
++ pkgs.lib.optional withIOG
(with pkgs.pkgsBuildBuild; [ cddl cbor-diag ]
++ map pkgs.lib.getDev (with pkgs; [
Expand Down
4 changes: 2 additions & 2 deletions docs/direnv.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi
# https://github.com/input-output-hk/devx Slightly opinionated shared GitHub Action for Cardano-Haskell projects
use flake "github:input-output-hk/devx#ghc8107-iog"
use flake "github:input-output-hk/devx#ghc96-iog"
```

This will tell `direnv` to instantiate a shell with the same environment as `nix develop github:input-output-hk/devx#ghc8107-iog`, when changing into the folder where the `.envrc` resides.
This will tell `direnv` to instantiate a shell with the same environment as `nix develop github:input-output-hk/devx#ghc96-iog`, when changing into the folder where the `.envrc` resides.

You can also pin the flake to a specific version. This is a good practice to ensure reproducibility across different machines and systems. Refer to the Nix Flakes documentation on how to do this. Then, allow Direnv to take effect:

Expand Down
12 changes: 8 additions & 4 deletions dynamic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
let tool-version-map = import ./tool-map.nix;
tool = tool-name: pkgs.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
cabal-install = tool "cabal";
cabal-install = pkgs.haskell-nix.nix-tools-unchecked.exes.cabal;
# add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler.
compiler-not-in = compiler-list: name: (if __elem compiler-nix-name compiler-list then __trace "No ${name}. Not yet compatible with ${compiler-nix-name}" false else true);

Expand Down Expand Up @@ -72,7 +72,7 @@ pkgs.mkShell {
fixup-nix-deps
compiler
] ++ (with pkgs; [
pkgconfig
(pkgs.pkg-config or pkgconfig)
# for libstdc++; ghc not being able to find this properly is bad,
# it _should_ probably call out to a g++ or clang++ but doesn't.
stdenv.cc.cc.lib
Expand All @@ -85,8 +85,12 @@ pkgs.mkShell {
]
++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isLinux systemd
)
++ pkgs.lib.optional (withHLS && (compiler-not-in (pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server")
++ pkgs.lib.optional (withHlint && (compiler-not-in (["ghc961" "ghc962"] ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint")
++ pkgs.lib.optional (withHLS && (compiler-not-in (
pkgs.lib.optional (builtins.compareVersions compiler.version "9.9" >= 0) compiler-nix-name
++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server")
++ pkgs.lib.optional (withHlint && (compiler-not-in (
pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name
++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint")
++ pkgs.lib.optional withIOG
(with pkgs; [
cddl
Expand Down
Loading

0 comments on commit 117b356

Please sign in to comment.