Skip to content

Commit 2184b56

Browse files
committed
Adapt the depext docker CI tests for the nix backend
1 parent bb82cb0 commit 2184b56

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

.github/scripts/depexts/generate-actions.sh

+45-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -eu
44

5-
#for target in alpine archlinux centos debian fedora gentoo opensuse oraclelinux ubuntu; do
5+
#for target in alpine archlinux centos debian fedora gentoo opensuse oraclelinux ubuntu nix; do
66
target=$1
77
dir=.github/actions/$target
88

@@ -102,6 +102,12 @@ RUN apt install -y $mainlibs $ocaml
102102
RUN apt install -y g++
103103
EOF
104104
;;
105+
nix)
106+
cat >$dir/Dockerfile << EOF
107+
FROM nixos/nix
108+
RUN nix-channel --update
109+
RUN nix-env -i gnum4 git rsync patch bzip2 gnumake wget ocaml ocaml5.1.1-ocaml-compiler-libs unzip gcc diffutils patch getconf-glibc gnused
110+
EOF
105111
esac
106112

107113
OCAML_INVARIANT="\"ocaml\" {>= \"4.09.0\"$OCAML_CONSTRAINT}"
@@ -121,12 +127,34 @@ RUN echo 'default-invariant: [ $OCAML_INVARIANT ]' > /opam/opamrc
121127
RUN /usr/bin/opam init --no-setup --disable-sandboxing --bare --config /opam/opamrc git+$OPAM_REPO#$OPAM_REPO_SHA
122128
RUN echo 'archive-mirrors: "https://opam.ocaml.org/cache"' >> \$OPAMROOT/config
123129
RUN /usr/bin/opam switch create this-opam --formula='$OCAML_INVARIANT'
130+
EOF
131+
132+
# we can't `nix-env -i binutils`
133+
# https://github.com/NixOS/nix/issues/10587
134+
if [ $target == "nix" ]; then
135+
cat >>$dir/Dockerfile << EOF
136+
RUN nix-shell -p binutils --run "/usr/bin/opam install opam-core opam-state opam-solver opam-repository opam-format opam-client --deps"
137+
EOF
138+
else
139+
cat >>$dir/Dockerfile << EOF
124140
RUN /usr/bin/opam install opam-core opam-state opam-solver opam-repository opam-format opam-client --deps
141+
EOF
142+
fi
143+
144+
cat >>$dir/Dockerfile << EOF
125145
RUN /usr/bin/opam clean -as --logs
126146
COPY entrypoint.sh /opam/entrypoint.sh
127-
ENTRYPOINT ["/opam/entrypoint.sh"]
128147
EOF
129148

149+
if [ $target == "nix" ]; then
150+
cat >>$dir/Dockerfile << EOF
151+
ENTRYPOINT ["nix-shell", "-p", "binutils", "--run", "/opam/entrypoint.sh"]
152+
EOF
153+
else
154+
cat >>$dir/Dockerfile << EOF
155+
ENTRYPOINT ["/opam/entrypoint.sh"]
156+
EOF
157+
fi
130158

131159
### Generate the entrypoint
132160
cat >$dir/entrypoint.sh << EOF
@@ -142,10 +170,23 @@ cd /github/workspace
142170
#git clone https://github.com/ocaml/opam --single-branch --branch 2.2 --depth 1 local-opam
143171
#cd local-opam
144172
145-
opam install . --deps
146-
eval \$(opam env)
173+
/usr/bin/opam install . --deps
174+
eval \$(/usr/bin/opam env)
147175
./configure
148176
make
177+
178+
EOF
179+
180+
if [ $target == "nix" ]; then
181+
cat >>$dir/entrypoint.sh << EOF
182+
./opam var --global os-family=nixos
183+
./opam var --global os-distribution=nixos
184+
185+
EOF
186+
fi
187+
188+
189+
cat >>$dir/entrypoint.sh << EOF
149190
./opam config report
150191
./opam switch create confs --empty
151192
EOF

.github/workflows/depexts.yml

+18
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,21 @@ jobs:
199199
- name: depexts actions ubuntu
200200
uses: ./.github/actions/ubuntu
201201
id: depexts-ubuntu
202+
203+
depexts-nix:
204+
needs: opam-cache
205+
runs-on: ubuntu-latest
206+
steps:
207+
- name: Checkout
208+
uses: actions/checkout@v3
209+
- name: opam binary cache
210+
uses: actions/cache@v3
211+
with:
212+
path: binary/opam
213+
key: binary-${{ env.OPAMVERSION }}
214+
- name: generate action
215+
run: |
216+
bash .github/scripts/depexts/generate-actions.sh nix
217+
- name: depexts actions nix
218+
uses: ./.github/actions/nix
219+
id: depexts-nix

src/state/opamSwitchState.ml

-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ let depexts_status_of_packages_raw
201201
in
202202
let syspkg_set = syspkg_set -- bypass in
203203
let ret =
204-
Printf.printf "here\n\r";
205204
match OpamSysInteract.packages_status ?env global_config syspkg_set ~old_packages:old_syspkg_set with
206205
| avail, required, not_found ->
207206
let avail, not_found =

0 commit comments

Comments
 (0)