From 1defb2dc475dec871343a182e60936b85a162e69 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 24 Oct 2024 16:46:40 -0400 Subject: [PATCH 1/2] chore(ci): Setup cachix, then push & pin --- .github/workflows/ci.yaml | 11 ++++++++++- dev/flake.lock | 40 ++++++++++++++++++++++++--------------- dev/flake.nix | 11 ++++++++++- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3acf834a..14c8dad5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,8 +12,17 @@ jobs: strategy: matrix: # Intel mac excluded; See https://github.com/juspay/services-flake/issues/231 - system: [ x86_64-linux, aarch64-darwin ] + system: [x86_64-linux, aarch64-darwin] steps: - uses: actions/checkout@v4 + - uses: cachix/cachix-action@v14 + with: + name: services-flake + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + skipPush: true - name: om ci run: om ci --extra-access-tokens "github.com=${{ secrets.GITHUB_TOKEN }}" run --systems "${{ matrix.system }}" + # Push the Nix cache + - name: Push to cachix + if: github.ref == 'refs/heads/main' + run: nix --option system "${{ matrix.system }}" run ./dev#cachix-push diff --git a/dev/flake.lock b/dev/flake.lock index a8512fac..4a38308e 100644 --- a/dev/flake.lock +++ b/dev/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "cachix-push": { + "locked": { + "lastModified": 1726080112, + "narHash": "sha256-OcmKmI5lO6ZcJNdZkWK5ObauO8YyazG3nBqGlwC9Y+0=", + "owner": "juspay", + "repo": "cachix-push", + "rev": "8ed534b817ab110387ff3bc95c211f668d7ccf2f", + "type": "github" + }, + "original": { + "owner": "juspay", + "repo": "cachix-push", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -21,11 +36,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1685662779, - "narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=", + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", "type": "github" }, "original": { @@ -106,20 +121,14 @@ }, "nixpkgs-lib": { "locked": { - "dir": "lib", - "lastModified": 1685564631, - "narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a", - "type": "github" + "lastModified": 1727825735, + "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" }, "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" } }, "nixpkgs_2": { @@ -166,6 +175,7 @@ }, "root": { "inputs": { + "cachix-push": "cachix-push", "flake-parts": "flake-parts", "flake-root": "flake-root", "nixpkgs": "nixpkgs", diff --git a/dev/flake.nix b/dev/flake.nix index 26e59f28..79091b91 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -9,6 +9,8 @@ inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs-stable.follows = "nixpkgs"; }; + cachix-push.url = "github:juspay/cachix-push"; + # CI will override `services-flake` to run checks on the latest source services-flake.url = "github:juspay/services-flake"; }; @@ -19,9 +21,10 @@ inputs.flake-root.flakeModule inputs.treefmt-nix.flakeModule inputs.pre-commit-hooks-nix.flakeModule + inputs.cachix-push.flakeModule ./nix/pre-commit.nix ]; - perSystem = { pkgs, lib, config, ... }: { + perSystem = { self', pkgs, config, ... }: { treefmt = { projectRoot = inputs.services-flake; projectRootFile = "flake.nix"; @@ -32,6 +35,12 @@ nixpkgs-fmt.enable = true; }; }; + cachix-push = { + cacheName = "services-flake"; + pathsToCache = { + devshell = self'.devShells.default; + }; + }; devShells.default = pkgs.mkShell { packages = with pkgs; [ just From 9a8b2a3b96183e59fc695110053ed7d0222504a8 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 24 Oct 2024 18:09:28 -0400 Subject: [PATCH 2/2] chore(dev): Update nixpkgs Need latest cachix --- dev/flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/flake.lock b/dev/flake.lock index 4a38308e..e04bfb13 100644 --- a/dev/flake.lock +++ b/dev/flake.lock @@ -105,11 +105,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1716190602, - "narHash": "sha256-xYRimrR0duWvokWQEvB87bSsICeCvvX9DxpUOzCfsDE=", + "lastModified": 1729755165, + "narHash": "sha256-6IpnOHWsaSSjT3yvqlrWfHW6HVCT+wOAlUpcooGJ+FQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5a5ac83292c7842072318f57d68a48474f8bd34d", + "rev": "cabaf14d3e69c9921d7acedf5d7d60bb2b90be02", "type": "github" }, "original": {