Skip to content

Commit

Permalink
Adapt the depext docker CI tests for the nix backend
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGibb committed Jul 18, 2024
1 parent bb82cb0 commit 2184b56
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
49 changes: 45 additions & 4 deletions .github/scripts/depexts/generate-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eu

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

Expand Down Expand Up @@ -102,6 +102,12 @@ RUN apt install -y $mainlibs $ocaml
RUN apt install -y g++
EOF
;;
nix)
cat >$dir/Dockerfile << EOF
FROM nixos/nix
RUN nix-channel --update
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
EOF
esac

OCAML_INVARIANT="\"ocaml\" {>= \"4.09.0\"$OCAML_CONSTRAINT}"
Expand All @@ -121,12 +127,34 @@ RUN echo 'default-invariant: [ $OCAML_INVARIANT ]' > /opam/opamrc
RUN /usr/bin/opam init --no-setup --disable-sandboxing --bare --config /opam/opamrc git+$OPAM_REPO#$OPAM_REPO_SHA
RUN echo 'archive-mirrors: "https://opam.ocaml.org/cache"' >> \$OPAMROOT/config
RUN /usr/bin/opam switch create this-opam --formula='$OCAML_INVARIANT'
EOF

# we can't `nix-env -i binutils`
# https://github.com/NixOS/nix/issues/10587
if [ $target == "nix" ]; then
cat >>$dir/Dockerfile << EOF
RUN nix-shell -p binutils --run "/usr/bin/opam install opam-core opam-state opam-solver opam-repository opam-format opam-client --deps"
EOF
else
cat >>$dir/Dockerfile << EOF
RUN /usr/bin/opam install opam-core opam-state opam-solver opam-repository opam-format opam-client --deps
EOF
fi

cat >>$dir/Dockerfile << EOF
RUN /usr/bin/opam clean -as --logs
COPY entrypoint.sh /opam/entrypoint.sh
ENTRYPOINT ["/opam/entrypoint.sh"]
EOF

if [ $target == "nix" ]; then
cat >>$dir/Dockerfile << EOF
ENTRYPOINT ["nix-shell", "-p", "binutils", "--run", "/opam/entrypoint.sh"]
EOF
else
cat >>$dir/Dockerfile << EOF
ENTRYPOINT ["/opam/entrypoint.sh"]
EOF
fi

### Generate the entrypoint
cat >$dir/entrypoint.sh << EOF
Expand All @@ -142,10 +170,23 @@ cd /github/workspace
#git clone https://github.com/ocaml/opam --single-branch --branch 2.2 --depth 1 local-opam
#cd local-opam
opam install . --deps
eval \$(opam env)
/usr/bin/opam install . --deps
eval \$(/usr/bin/opam env)
./configure
make
EOF

if [ $target == "nix" ]; then
cat >>$dir/entrypoint.sh << EOF
./opam var --global os-family=nixos
./opam var --global os-distribution=nixos
EOF
fi


cat >>$dir/entrypoint.sh << EOF
./opam config report
./opam switch create confs --empty
EOF
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/depexts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,21 @@ jobs:
- name: depexts actions ubuntu
uses: ./.github/actions/ubuntu
id: depexts-ubuntu

depexts-nix:
needs: opam-cache
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: opam binary cache
uses: actions/cache@v3
with:
path: binary/opam
key: binary-${{ env.OPAMVERSION }}
- name: generate action
run: |
bash .github/scripts/depexts/generate-actions.sh nix
- name: depexts actions nix
uses: ./.github/actions/nix
id: depexts-nix
1 change: 0 additions & 1 deletion src/state/opamSwitchState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ let depexts_status_of_packages_raw
in
let syspkg_set = syspkg_set -- bypass in
let ret =
Printf.printf "here\n\r";
match OpamSysInteract.packages_status ?env global_config syspkg_set ~old_packages:old_syspkg_set with
| avail, required, not_found ->
let avail, not_found =
Expand Down

0 comments on commit 2184b56

Please sign in to comment.