Skip to content

Commit

Permalink
Use short names
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishmack committed Oct 17, 2023
1 parent 9cd6731 commit 80ed5ca
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 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: 6 additions & 6 deletions .github/workflows/hello.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
#- aarch64-darwin
#- aarch64-linux
compiler-nix-name:
- ghc8107
- ghc928
- ghc963
- ghc981
- ghc810
- ghc92
- ghc96
- ghc98
target-platform:
- ""
- "-static"
Expand All @@ -33,9 +33,9 @@ jobs:
- true
exclude:
# Just cross compiling javascript with ghc 9.6 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
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ jobs:
# Currently broken
#- aarch64-linux
compiler-nix-name:
- ghc8107
- ghc928
- ghc963
- ghc981
- ghc810
- ghc92
- ghc96
- ghc98
- ghc99
target-platform:
- ""
Expand All @@ -74,9 +74,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
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
20 changes: 10 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#
# Usage:
#
# nix develop github:input-output-hk/devx#ghc924 --no-write-lock-file -c cabal build
# nix develop github:input-output-hk/devx#ghc96 --no-write-lock-file -c cabal build
#
static-pkgs = if pkgs.stdenv.hostPlatform.isLinux
then if pkgs.stdenv.hostPlatform.isAarch64
Expand All @@ -72,22 +72,22 @@
# Map the compiler-nix-name to a final compiler-nix-name the way haskell.nix
# projects do (that way we can use short names)
let compilers = pkgs: pkgs.lib.genAttrs [
"ghc8107"
"ghc902"
"ghc928"
"ghc947"
"ghc963"
"ghc981"
"ghc810"
"ghc90"
"ghc92"
"ghc94"
"ghc96"
"ghc98"
"ghc99"] (short-name: rec {
inherit pkgs self toolsModule;
compiler-nix-name = pkgs.haskell-nix.resolve-compiler-name short-name;
compiler = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name};
});
js-compilers = pkgs: builtins.removeAttrs (compilers pkgs)
[
"ghc902"
"ghc928"
"ghc947"
"ghc90"
"ghc92"
"ghc94"
];
windows-compilers = pkgs:
pkgs.lib.optionalAttrs (__elem system ["x86_64-linux"])
Expand Down

0 comments on commit 80ed5ca

Please sign in to comment.