commit 9447dcb310330cc56a9f7f53b3b93a343fc69bb3 Author: Technofab Date: Mon May 29 13:52:53 2023 +0200 chore: initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bbd4d22 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +ARG NIX_TAG="latest" + +FROM nixos/nix:$NIX_TAG + +COPY entrypoint.sh /usr/local/bin/ + +ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..dbebe7e --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Gitlab Nix Docker Image +Image: [`technofab/nix-gitlab-ci:latest`](https://hub.docker.com/repository/docker/technofab/nix-gitlab-ci/general) + +This simple image tries to start a Nix devShell from a flake.nix in the repository. +It uses the devShell named `ci` (optionally just link to the default shell, see below). + +```nix +... +rec { + default = devenv.lib.mkShell {}; + ci = default; +}; +... +``` diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..8d67102 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +cd "$CI_PROJECT_DIR" + +echo "Trying to activate flake's CI shell..." +{ + nix --extra-experimental-features "flakes nix-command" develop .#ci --impure --command "bash" >/dev/null +} || { + echo "nix develop failed, falling back to normal shell..." + eval "bash" +}