diff --git a/nix/Dockerfile b/nix/Dockerfile new file mode 100644 index 000000000..99fefa87c --- /dev/null +++ b/nix/Dockerfile @@ -0,0 +1,22 @@ +# This Dockerfile is only used as a development environment for +# non-nix systems, i.e. Windows. + +FROM nixos/nix:latest + +RUN apk --no-cache add \ + wget + +RUN nix-env -iA cachix -f https://cachix.org/api/v1/install \ + && cachix use postgrest + +# We need an unprivileged user here, to make PG run at all. +RUN adduser --disabled-password --ingroup root nix \ + && chown -R nix:root /nix +USER nix:root +ENV USER=nix + +VOLUME /nix +VOLUME /postgrest +WORKDIR /postgrest + +CMD nix-shell diff --git a/nix/README.md b/nix/README.md index b0b111bf5..81bc5babd 100644 --- a/nix/README.md +++ b/nix/README.md @@ -12,6 +12,11 @@ their dependencies will be stored. It will also link the Nix executables like other PostgREST dependencies from here on out. To clean up older build artifacts from the `/nix/store`, you can run `nix-collect-garbage`. +If you are on a system that does not support nix, for example Windows, you can +run the nix development environment in a docker container. Inside the `nix/` +directory run `docker-compose run --rm nix` to start the docker container. This +will set up the binary cache and launch `nix-shell` automatically. + ## Building PostgREST To build PostgREST from your local checkout of the repository, run: diff --git a/nix/docker-compose.yml b/nix/docker-compose.yml new file mode 100644 index 000000000..857c881d6 --- /dev/null +++ b/nix/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' + +services: + nix: + container_name: postgrest-nix + build: . + volumes: + - ../:/postgrest + - nix:/nix + +volumes: + nix: