Skip to content

Commit 50c9b61

Browse files
authored
Cleanup (#49)
1 parent 37d93bd commit 50c9b61

File tree

6 files changed

+72
-40
lines changed

6 files changed

+72
-40
lines changed

Diff for: .github/workflows/main.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Prebuild DevX closures
22
on:
33
push:
4+
branches:
5+
- main
6+
47
workflow_dispatch:
58

69
env:
@@ -54,14 +57,14 @@ jobs:
5457
target-platform: "-windows"
5558
- platform: aarch64-linux
5659
target-platform: "-windows"
57-
60+
5861
runs-on: ubuntu-latest
5962
permissions:
6063
contents: read
6164
packages: write
6265
steps:
6366
- name: Install Nix with good defaults
64-
uses: cachix/install-nix-action@v17
67+
uses: cachix/install-nix-action@v20
6568
with:
6669
extra_nix_config: |
6770
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=
@@ -70,7 +73,7 @@ jobs:
7073
- name: Checkout repository
7174
uses: actions/checkout@v3
7275
- name: Log in to the Container registry
73-
uses: docker/login-action@v1
76+
uses: docker/login-action@v2.1.0
7477
with:
7578
registry: ${{ env.REGISTRY }}
7679
username: ${{ github.actor }}

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
result
2+
.DS_Store

Diff for: cross-js.nix

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
{ pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
1+
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
22
let tool-version-map = import ./tool-map.nix;
33
tool = tool-name: pkgs.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
44
cabal-install = tool "cabal";
55
# add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler.
6-
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);
6+
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);
77

88
# * wrapped tools:
99
# A cabal-install wrapper that sets the appropriate static flags
@@ -18,17 +18,17 @@ let tool-version-map = import ./tool-map.nix;
1818
build)
1919
cabal \
2020
"$@" \
21-
$NIX_CABAL_FLAGS
21+
$NIX_CABAL_FLAGS
2222
;;
2323
clean|unpack)
2424
cabal "$@"
2525
;;
2626
*)
2727
cabal $NIX_CABAL_FLAGS "$@"
2828
;;
29-
esac
29+
esac
3030
'';
31-
};
31+
};
3232
wrapped-hsc2hs = pkgs.pkgsBuildBuild.writeShellApplication {
3333
name = "${compiler.targetPrefix}hsc2hs";
3434
text = ''
@@ -67,11 +67,12 @@ pkgs.mkShell ({
6767
'';
6868

6969
shellHook = with pkgs; ''
70-
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
71-
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
72-
${figlet}/bin/figlet -f small "*= JS edition =*"
73-
export CABAL_DIR=$HOME/.cabal-js
74-
echo "CABAL_DIR set to $CABAL_DIR"
70+
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
71+
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
72+
${figlet}/bin/figlet -f small "*= JS edition =*"
73+
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
74+
export CABAL_DIR=$HOME/.cabal-js
75+
echo "CABAL_DIR set to $CABAL_DIR"
7576
'';
7677
buildInputs = [];
7778

Diff for: dynamic.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# define a development shell for dynamically linked applications (default)
2-
{ pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
2+
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
33
let tool-version-map = import ./tool-map.nix;
44
tool = tool-name: pkgs.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
55
cabal-install = tool "cabal";
@@ -11,7 +11,7 @@ let tool-version-map = import ./tool-map.nix;
1111
# linked directly.
1212
#
1313
# FIXME: this is the same as in static.nix; and we should probably put this into
14-
# a shared file. It will also not work for anything that has more than
14+
# a shared file. It will also not work for anything that has more than
1515
# the system libs linked.
1616
fixup-nix-deps = pkgs.writeShellApplication {
1717
name = "fixup-nix-deps";
@@ -53,6 +53,7 @@ pkgs.mkShell {
5353
shellHook = with pkgs; ''
5454
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
5555
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
56+
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
5657
export CABAL_DIR=$HOME/.cabal
5758
echo "CABAL_DIR set to $CABAL_DIR"
5859
''
@@ -65,6 +66,7 @@ pkgs.mkShell {
6566

6667
buildInputs = [
6768
wrapped-cabal
69+
fixup-nix-deps
6870
compiler
6971
] ++ (with pkgs; [
7072
pkgconfig

Diff for: flake.nix

+37-14
Original file line numberDiff line numberDiff line change
@@ -86,51 +86,51 @@
8686
else pkgs;
8787
js-pkgs = pkgs.pkgsCross.ghcjs;
8888
in (builtins.mapAttrs (compiler-nix-name: compiler:
89-
import ./dynamic.nix { inherit pkgs compiler compiler-nix-name toolsModule; withIOG = false; }
89+
import ./dynamic.nix { inherit pkgs self compiler compiler-nix-name toolsModule; withIOG = false; }
9090
) (compilers pkgs)
9191
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
9292
pkgs.lib.nameValuePair "${compiler-nix-name}-minimal" (
93-
import ./dynamic.nix { inherit pkgs compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = false; }
93+
import ./dynamic.nix { inherit pkgs self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = false; }
9494
)) (compilers pkgs)
9595
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
9696
pkgs.lib.nameValuePair "${compiler-nix-name}-static" (
97-
import ./static.nix { pkgs = static-pkgs; inherit compiler compiler-nix-name toolsModule; withIOG = false; }
97+
import ./static.nix { pkgs = static-pkgs; inherit self compiler compiler-nix-name toolsModule; withIOG = false; }
9898
)) (compilers static-pkgs.buildPackages)
9999
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
100100
pkgs.lib.nameValuePair "${compiler-nix-name}-static-minimal" (
101-
import ./static.nix { pkgs = static-pkgs; inherit compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = false; }
101+
import ./static.nix { pkgs = static-pkgs; inherit self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = false; }
102102
)) (compilers static-pkgs.buildPackages)
103103
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
104104
pkgs.lib.nameValuePair "${compiler-nix-name}-js" (
105-
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit compiler compiler-nix-name toolsModule; }
105+
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit self compiler compiler-nix-name toolsModule; }
106106
)) (js-compilers js-pkgs.buildPackages)
107107
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
108108
pkgs.lib.nameValuePair "${compiler-nix-name}-js-minimal" (
109-
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; }
109+
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; }
110110
)) (js-compilers js-pkgs.buildPackages)
111111
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
112112
pkgs.lib.nameValuePair "${compiler-nix-name}-iog" (
113-
import ./dynamic.nix { inherit pkgs compiler compiler-nix-name toolsModule; withIOG = true; }
113+
import ./dynamic.nix { inherit pkgs self compiler compiler-nix-name toolsModule; withIOG = true; }
114114
)) (compilers pkgs)
115115
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
116116
pkgs.lib.nameValuePair "${compiler-nix-name}-minimal-iog" (
117-
import ./dynamic.nix { inherit pkgs compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
117+
import ./dynamic.nix { inherit pkgs self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
118118
)) (compilers pkgs)
119119
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
120120
pkgs.lib.nameValuePair "${compiler-nix-name}-static-iog" (
121-
import ./static.nix { pkgs = static-pkgs; inherit compiler compiler-nix-name toolsModule; withIOG = true; }
121+
import ./static.nix { pkgs = static-pkgs; inherit self compiler compiler-nix-name toolsModule; withIOG = true; }
122122
)) (compilers static-pkgs.buildPackages)
123123
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
124124
pkgs.lib.nameValuePair "${compiler-nix-name}-static-minimal-iog" (
125-
import ./static.nix { pkgs = static-pkgs; inherit compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
125+
import ./static.nix { pkgs = static-pkgs; inherit self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
126126
)) (compilers static-pkgs.buildPackages)
127127
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
128128
pkgs.lib.nameValuePair "${compiler-nix-name}-js-iog" (
129-
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit compiler compiler-nix-name toolsModule; withIOG = true; }
129+
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit self compiler compiler-nix-name toolsModule; withIOG = true; }
130130
)) (js-compilers js-pkgs.buildPackages)
131131
// pkgs.lib.mapAttrs' (compiler-nix-name: compiler:
132132
pkgs.lib.nameValuePair "${compiler-nix-name}-js-minimal-iog" (
133-
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
133+
import ./cross-js.nix { pkgs = js-pkgs.buildPackages; inherit self compiler compiler-nix-name toolsModule; withHLS = false; withHlint = false; withIOG = true; }
134134
)) (js-compilers js-pkgs.buildPackages)
135135
);
136136
devShells = devShellsWithToolsModule {};
@@ -143,13 +143,36 @@
143143
hydraJobs = devShells //
144144
(pkgs.lib.mapAttrs' (name: drv:
145145
pkgs.lib.nameValuePair "${name}-env" (
146-
pkgs.runCommand "${name}-env.sh" {
146+
let env = pkgs.runCommand "${name}-env.sh" {
147147
requiredSystemFeatures = [ "recursive-nix" ];
148148
nativeBuildInputs = [ pkgs.nix ];
149149
} ''
150150
nix --offline --extra-experimental-features "nix-command flakes" \
151151
print-dev-env ${drv.drvPath} >> $out
152-
'')) devShellsWithEvalOnLinux) // {
152+
''; in pkgs.writeTextFile {
153+
name = "devx";
154+
executable = true;
155+
text = ''
156+
#!/bin/bash
157+
158+
set -euo pipefail
159+
160+
source ${env}
161+
source "$1"
162+
'';
163+
meta = {
164+
description = "DevX shell";
165+
longDescription = ''
166+
The DevX shell is supposed to be used with GitHub Actions, and
167+
can be used by setting the default shell to:
168+
169+
shell: devx {0}
170+
'';
171+
homepage = "https://github.com/input-output-hk/devx";
172+
license = pkgs.lib.licenses.asl20;
173+
platforms = pkgs.lib.platforms.unix;
174+
};
175+
})) devShellsWithEvalOnLinux) // {
153176
};
154177
});
155178

Diff for: static.nix

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
1+
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
22
let tool-version-map = import ./tool-map.nix;
33
tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
44
cabal-install = tool "cabal";
@@ -82,21 +82,22 @@ pkgs.mkShell ({
8282
'';
8383

8484
shellHook = with pkgs; ''
85-
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
86-
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
87-
${figlet}/bin/figlet -f small "*= static edition =*"
88-
echo "NOTE (macos): you can use fixup-nix-deps FILE, to fix iconv, ffi, and zlib dependencies that point to the /nix/store"
89-
export CABAL_DIR=$HOME/.cabal-static
90-
echo "CABAL_DIR set to $CABAL_DIR"
91-
echo "Quirks:"
92-
echo -e "\tif you have the zlib, HsOpenSSL, or digest package in your dependency tree, please make sure to"
93-
echo -e "\techo \"\$CABAL_PROJECT_LOCAL_TEMPLATE\" > cabal.project.local"
85+
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
86+
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
87+
${figlet}/bin/figlet -f small "*= static edition =*"
88+
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
89+
echo "NOTE (macos): you can use fixup-nix-deps FILE, to fix iconv, ffi, and zlib dependencies that point to the /nix/store"
90+
export CABAL_DIR=$HOME/.cabal-static
91+
echo "CABAL_DIR set to $CABAL_DIR"
92+
echo "Quirks:"
93+
echo -e "\tif you have the zlib, HsOpenSSL, or digest package in your dependency tree, please make sure to"
94+
echo -e "\techo \"\$CABAL_PROJECT_LOCAL_TEMPLATE\" > cabal.project.local"
9495
'';
9596
buildInputs = (with pkgs; [
9697
# for libstdc++; ghc not being able to find this properly is bad,
9798
# it _should_ probably call out to a g++ or clang++ but doesn't.
9899
stdenv.cc.cc.lib
99-
]) ++ map pkgs.lib.getDev (with pkgs; [
100+
]) ++ map pkgs.lib.getDev (with pkgs; [
100101
static-gmp
101102

102103
zlib

0 commit comments

Comments
 (0)