---
image: nixos/nix:latest

default:
  cache:
    paths:
      - .nix
  before_script:
    - test -d .nix || cp -a /nix .nix
    - mount --bind .nix /nix
    - mkdir -p /etc/nix
    - echo keep-outputs = true >> /etc/nix/nix.conf
    - echo keep-derivations = true >> /etc/nix/nix.conf
    - echo experimental-features = nix-command flakes >> /etc/nix/nix.conf
    - nix-env -iA nixpkgs.nixFlakes nixpkgs.git

build:
  stage: build
  script:
    - nix build
    - nix build -o ocamlPackages_4_10.p2p '.#ocamlPackages_4_10.p2p'
    - nix build -o ocamlPackages_4_11.p2p '.#ocamlPackages_4_11.p2p'
    #- nix build -o ocamlPackages_4_12.p2p '.#ocamlPackages_4_12.p2p'
    - nix-collect-garbage -d
