From 7e80de22807df96d1433f1a75346a543432b9730 Mon Sep 17 00:00:00 2001 From: rsoeldner Date: Thu, 6 Jul 2023 14:10:47 +0200 Subject: [PATCH 1/4] add nix cache workflow --- .github/workflows/nix.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 000000000..e191d59d2 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,34 @@ +name: Build and cache with Nix + +on: + workflow_dispatch: + push: + +jobs: + build-and-cache: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Nix with caching + uses: kadena-io/setup-nix-with-cache@v1 + with: + cache_url: s3://nixcache.chainweb.com?region=us-east-1 + signing_private_key: ${{ secrets.NIX_CACHE_PRIVATE_KEY }} + + - name: Set up AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.NIX_CACHE_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.NIX_CACHE_AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Build and cache artifacts + timeout-minutes: 740 + run: | + echo Building the project and its devShell + nix build \ No newline at end of file From 7f6a1c17e42b3dfb42b25bbf1b8c3eb9aa08fae7 Mon Sep 17 00:00:00 2001 From: rsoeldner Date: Fri, 7 Jul 2023 10:18:49 +0200 Subject: [PATCH 2/4] Correct print output --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index e191d59d2..abfe77cfe 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -30,5 +30,5 @@ jobs: - name: Build and cache artifacts timeout-minutes: 740 run: | - echo Building the project and its devShell + echo Building the default flake nix build \ No newline at end of file From 04ddfce28c583b9c8342d0c4f07983e2bff45443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enis=20Bayramo=C4=9Flu?= Date: Thu, 20 Jul 2023 15:55:40 +0200 Subject: [PATCH 3/4] Add devShell to Nix action --- .github/workflows/nix.yml | 4 ++-- flake.nix | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index abfe77cfe..6a419a9e8 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -30,5 +30,5 @@ jobs: - name: Build and cache artifacts timeout-minutes: 740 run: | - echo Building the default flake - nix build \ No newline at end of file + echo Building the default package and its devShell + nix build .#check diff --git a/flake.nix b/flake.nix index 0d2f68bbc..61053f32c 100644 --- a/flake.nix +++ b/flake.nix @@ -41,8 +41,20 @@ }; }) ]; - in flake // { + # This package depends on other packages at buildtime, but its output does not + # depend on them. This way, we don't have to download the entire closure to verify + # that those packages build. + mkCheck = name: package: pkgs.runCommand ("check-"+name) {} '' + echo ${name}: ${package} + echo works > $out + ''; + in flake // rec { packages.default = flake.packages."pact:exe:pact"; + packages.check = pkgs.runCommand "check" {} '' + echo ${mkCheck "pact" packages.default} + echo ${mkCheck "devShell" devShell} + echo works > $out + ''; devShell = pkgs.haskellPackages.shellFor { buildInputs = with pkgs.haskellPackages; [ From 3a52ce961865ef6a9d9065fd9a1da6a6be3a7865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enis=20Bayramo=C4=9Flu?= Date: Thu, 20 Jul 2023 16:01:39 +0200 Subject: [PATCH 4/4] Use the devShell from haskell.nix --- flake.nix | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index a4ad522af..fd0413a1d 100644 --- a/flake.nix +++ b/flake.nix @@ -52,18 +52,8 @@ packages.default = flake.packages."pact:exe:pact"; packages.check = pkgs.runCommand "check" {} '' echo ${mkCheck "pact" packages.default} - echo ${mkCheck "devShell" devShell} + echo ${mkCheck "devShell" flake.devShell} echo works > $out ''; - - devShell = pkgs.haskellPackages.shellFor { - buildInputs = with pkgs.haskellPackages; [ - cabal-install - haskell-language-server - # hlint - ]; - - withHoogle = true; - }; }); }