Skip to content

Commit e910902

Browse files
DavidMazarroCristhianMotochesestrella
authoredOct 1, 2024··
Simplification of Nix flake and removal of GHC 8 (#245)
Co-authored-by: CristhianMotoche <[email protected]> Co-authored-by: Sebastián Estrella <[email protected]>
1 parent 0cf8b70 commit e910902

File tree

8 files changed

+97
-142
lines changed

8 files changed

+97
-142
lines changed
 

‎.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

‎.github/workflows/build.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ jobs:
1515
- macos-13 # x86_64-darwin
1616
- macos-latest # aarch64-darwin
1717
- ubuntu-latest # x86_64-linux
18-
ghc:
19-
- ghc8107
20-
- ghc902
2118
fail-fast: true
2219
runs-on: ${{ matrix.os }}
2320
timeout-minutes: 30
@@ -28,9 +25,9 @@ jobs:
2825
extra-conf: accept-flake-config = true
2926
- uses: DeterminateSystems/magic-nix-cache-action@v7
3027
- name: Compile code ${{ matrix.ghc }}
31-
run: nix build .#test-${{ matrix.ghc }}
28+
run: nix build .#test
3229
- name: Run tests ${{ matrix.ghc }}
33-
run: nix run .#test-${{ matrix.ghc }}
30+
run: nix run .#test
3431

3532
docker:
3633
uses: ./.github/workflows/reusable-docker.yml

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*.o
77
.cabal-sandbox/
88
.direnv/
9-
.envrc
109
.hpc
1110
.hsenv
1211
.tool-versions

‎Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM utdemir/ghc-musl:v24-ghc902 AS build
1+
FROM quay.io/benz0li/ghc-musl:9.6.6 AS build
22
WORKDIR /usr/src/app
33
COPY hapistrano.cabal .
44
RUN cabal update && \
@@ -8,7 +8,7 @@ RUN cabal build --enable-executable-static && \
88
cp $(cabal exec which hap) hap
99

1010
FROM alpine:3.15
11-
MAINTAINER Nicolas Vivar <nvivar@stackbuilders.com>
11+
MAINTAINER Cristhian Motoche <cmotoche@stackbuilders.com>
1212
RUN apk update && \
1313
apk add \
1414
ca-certificates \

‎docs/NIX.md

+10-23
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,27 @@ sudo launchctl start org.nixos.nix-daemon
2222
```
2323

2424
If the following messages appear running the scripts detailed in the section
25-
below, it means that the Nix is not able to talk with the cache, in which case
26-
is recommended to go over the steps detailed in this section again:
25+
below, it means that Nix is not picking up the substituters we described
26+
earlier and is unable to use them as a derivation cache:
2727

2828
```
2929
warning: ignoring untrusted substituter 'https://cache.iog.io'
3030
```
31+
in which case
32+
it is recommended to go over the steps detailed in this section again, or look for alternative ways to add extra substituters in [nix.conf](https://nix.dev/manual/nix/2.18/command-ref/conf-file).
3133

32-
## Switching between different GHC versions
34+
## Enabling the development environment
3335

34-
The `bin` directory, holds all available shells:
36+
To enable the development environment exposed by the project's [Nix flake](../flake.nix), you can start a development shell by running the following command from within the project's root:
3537

3638
```
37-
ls bin | grep ghc
39+
nix develop
3840
```
3941

40-
To spawn a new shell with a pre-defined GHC version, choose one of the scripts
41-
listed above and run the following command:
42+
Alternatively, if you are using [nix-direnv](https://github.com/nix-community/nix-direnv) (recommended), you can run:
4243

43-
```sh
44-
./bin/ghc90
4544
```
46-
47-
Once inside the shell, verify the GHC version matches the script name:
48-
49-
```
50-
ghc --version
45+
direnv allow
5146
```
5247

53-
After that, all commands detailed in the [Getting
54-
Started](../README.md#getting-started) section should work the same.
55-
56-
Alternatively, to run a command without spawning a new shell use the `-c`
57-
option:
58-
59-
```sh
60-
./bin/ghc90 -c <command>
61-
```
48+
that will enable the development shell according to the contents of [.envrc](../.envrc). It is advisable not to run `direnv allow` blindly and always check the contents of [.envrc](../.envrc) files first to ensure nothing malicious is executed.

‎flake.lock

+57-61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flake.nix

+23-48
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,37 @@
2121
# https://input-output-hk.github.io/haskell.nix/tutorials/getting-started-flakes.html
2222
flake-utils.lib.eachDefaultSystem (system:
2323
let
24-
pkgs = import nixpkgs {
25-
inherit system;
26-
inherit (haskellNix) config;
27-
overlays = [
28-
haskellNix.overlay
29-
(final: prev: {
30-
hapistrano-ghc8107 = final.haskell-nix.cabalProject' {
31-
src = final.haskell-nix.haskellLib.cleanGit {
32-
name = "hapistrano";
33-
src = ./.;
34-
};
35-
compiler-nix-name = "ghc8107";
24+
overlays = [
25+
haskellNix.overlay
26+
(final: prev: {
27+
hapistrano = final.haskell-nix.cabalProject' {
28+
src = final.haskell-nix.haskellLib.cleanGit {
29+
name = "hapistrano";
30+
src = ./.;
3631
};
37-
hapistrano-ghc902 = final.haskell-nix.cabalProject' {
38-
src = final.haskell-nix.haskellLib.cleanGit {
39-
name = "hapistrano";
40-
src = ./.;
41-
};
42-
compiler-nix-name = "ghc902";
32+
# This is used by `nix develop .` to open a shell for use with
33+
# `cabal`, `hlint` and `haskell-language-server`
34+
shell.tools = {
35+
cabal = {};
36+
hlint = {};
37+
haskell-language-server = {};
4338
};
44-
})
45-
];
46-
};
47-
flake-ghc8107 = pkgs.hapistrano-ghc8107.flake { };
48-
flake-ghc902 = pkgs.hapistrano-ghc902.flake { };
39+
compiler-nix-name = "ghc966";
40+
};
41+
})
42+
];
43+
pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
44+
flake = pkgs.hapistrano.flake { };
4945
in rec {
5046
apps = {
51-
test-ghc8107 = {
52-
type = "app";
53-
program = "${packages.test-ghc8107}/bin/test";
54-
};
55-
test-ghc902 = {
47+
test = {
5648
type = "app";
57-
program = "${packages.test-ghc902}/bin/test";
49+
program = "${packages.test}/bin/test";
5850
};
5951
};
6052
packages = {
61-
default = flake-ghc8107.packages."hapistrano:exe:hap";
62-
test-ghc8107 = flake-ghc8107.packages."hapistrano:test:test".overrideAttrs (_: {
53+
default = flake.packages."hapistrano:exe:hap";
54+
test = flake.packages."hapistrano:test:test".overrideAttrs (_: {
6355
postFixup = ''
6456
wrapProgram $out/bin/test \
6557
--set PATH ${pkgs.lib.makeBinPath [
@@ -71,23 +63,6 @@
7163
]}
7264
'';
7365
});
74-
test-ghc902 = flake-ghc902.packages."hapistrano:test:test".overrideAttrs (_: {
75-
postFixup = ''
76-
wrapProgram $out/bin/test \
77-
--set PATH ${pkgs.lib.makeBinPath [
78-
pkgs.bash
79-
pkgs.coreutils
80-
pkgs.findutils
81-
pkgs.git
82-
pkgs.zsh
83-
]}
84-
'';
85-
});
86-
};
87-
devShells = {
88-
default = devShells.ghc902;
89-
ghc8107 = flake-ghc8107.devShells.default;
90-
ghc902 = flake-ghc902.devShells.default;
9166
};
9267
});
9368
}

‎hapistrano.cabal

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ category: System
2828
homepage: https://github.com/stackbuilders/hapistrano
2929
bug-reports: https://github.com/stackbuilders/hapistrano/issues
3030
build-type: Simple
31-
tested-with: GHC==8.10.17, GHC==9.0.2
31+
tested-with: GHC==9.6.6
3232
extra-doc-files: CHANGELOG.md
3333
, README.md
3434

@@ -66,7 +66,7 @@ library
6666
, text >= 1.2 && < 3
6767
, typed-process >= 0.2 && < 0.3
6868
, time >= 1.5 && < 1.13
69-
, transformers >= 0.4 && < 0.6
69+
, transformers >= 0.4 && < 0.7
7070
, exceptions >= 0.10 && < 0.11
7171
, yaml >= 0.11.7 && < 0.12
7272
if flag(dev)

0 commit comments

Comments
 (0)
Please sign in to comment.