diff --git a/.github/workflows/cachix.yaml b/.github/workflows/cachix.yaml new file mode 100644 index 000000000..d06d22fdd --- /dev/null +++ b/.github/workflows/cachix.yaml @@ -0,0 +1,77 @@ +name: Cachix + +# This workflow serves to +# - keep cachix up to date with the main branch +# - incrementally update cachix for large dependency +# updates, e.g. after running postgrest-nixpkgs-upgrade, +# which can cause the main CI workflow to time out + +on: + workflow_dispatch: + push: + branches: + - main + - rel-* + tags: + - v* + +jobs: + Seed-Cachix: + strategy: + matrix: + include: + - os: Linux + runs-on: ubuntu-latest + - os: MacOS + runs-on: macos-latest + name: Seed ${{ matrix.os }} + runs-on: ${{ matrix.runs-on }} + steps: + - uses: actions/checkout@v3 + - name: Setup Nix Environment + uses: ./.github/actions/setup-nix + with: + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + + - name: Install cachix tooling + run: | + nix-env -f default.nix -iA devTools.pushCachix.bin + postgrest-push-cachix + + - name: Seed dynamic postgrest build + run: | + nix-build -A postgrestPackage + postgrest-push-cachix + + - name: Seed style tools + run: | + nix-build -A style + postgrest-push-cachix + + - name: Seed test tools + run: | + nix-build -A tests + postgrest-push-cachix + + - name: Seed static toolchain + if: matrix.os == 'Linux' + run: | + nix-build -A packagesStatic.haskellPackages.hello + postgrest-push-cachix + + - name: Seed static postgresql build (for libpq) + if: matrix.os == 'Linux' + run: | + nix-build -A packagesStatic.pkgs.postgresql + postgrest-push-cachix + + - name: Seed static postgrest build + if: matrix.os == 'Linux' + run: | + nix-build -A postgrestStatic + postgrest-push-cachix + + - name: Build and push everything to Cachix + run: | + nix-build + postgrest-push-cachix diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b7f973cf9..e0a4f8486 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -108,7 +108,6 @@ jobs: - name: Setup Nix Environment uses: ./.github/actions/setup-nix with: - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' tools: tests - name: Build static executable @@ -131,13 +130,6 @@ jobs: path: postgrest-docker.tar.gz if-no-files-found: error - - name: Build and push everything to Cachix (main branch only) - if: ${{ github.ref == 'refs/heads/main' }} - run: | - nix-build - nix-env -f default.nix -iA devTools - postgrest-push-cachix - Build-Macos-Nix: name: Build MacOS (Nix) @@ -146,18 +138,10 @@ jobs: - uses: actions/checkout@v3 - name: Setup Nix Environment uses: ./.github/actions/setup-nix - with: - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Build everything run: | nix-build - nix-env -f default.nix -iA devTools - - - name: Push to Cachix (main branch only) - if: ${{ github.ref == 'refs/heads/main' }} - run: | - postgrest-push-cachix Build-Stack: diff --git a/default.nix b/default.nix index 62ec8b6fe..ebad92df2 100644 --- a/default.nix +++ b/default.nix @@ -65,11 +65,17 @@ let postgrest = pkgs.haskell.packages."${compiler}".callCabal2nix name src { }; - # Function that derives a fully static Haskell package based on + # Functionality that derives a fully static Haskell package based on # nh2/static-haskell-nix staticHaskellPackage = import nix/static-haskell-package.nix { inherit nixpkgs system compiler patches allOverlays; }; + # Static executable. + postgrestStatic = + lib.justStaticExecutables (lib.dontCheck (staticHaskellPackage name src).package); + + packagesStatic = (staticHaskellPackage name src).survey; + # Options passed to cabal in dev tools and tests devCabalOptions = "-f dev --test-show-detail=direct"; @@ -152,8 +158,8 @@ rec { pkgs.callPackage nix/tools/withTools.nix { inherit devCabalOptions postgresqlVersions postgrest; }; } // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux rec { # Static executable. - postgrestStatic = - lib.justStaticExecutables (lib.dontCheck (staticHaskellPackage name src)); + inherit postgrestStatic; + inherit packagesStatic; # Docker images and loading script. docker = diff --git a/nix/static-haskell-package.nix b/nix/static-haskell-package.nix index 551e13318..60f97bb8b 100644 --- a/nix/static-haskell-package.nix +++ b/nix/static-haskell-package.nix @@ -59,4 +59,7 @@ let survey = import "${patched-static-haskell-nix}/survey" { inherit normalPkgs compiler defaultCabalPackageVersionComingWithGhc; }; in -survey.haskellPackages."${name}" +{ + inherit survey; + package = survey.haskellPackages."${name}"; +} diff --git a/nix/tools/devTools.nix b/nix/tools/devTools.nix index b59b03978..8745054a2 100644 --- a/nix/tools/devTools.nix +++ b/nix/tools/devTools.nix @@ -303,4 +303,5 @@ buildToolbox hsieGraphModules hsieGraphSymbols ]; + extra = { inherit pushCachix; }; }