From df8b563222a5244ad29196509025caea23f48130 Mon Sep 17 00:00:00 2001 From: cy Date: Mon, 20 Jan 2025 01:48:35 -0500 Subject: [PATCH 1/6] try cachix without daemon --- .github/workflows/build-and-cache.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-and-cache.yml b/.github/workflows/build-and-cache.yml index 0e2e1df..2c06dbd 100644 --- a/.github/workflows/build-and-cache.yml +++ b/.github/workflows/build-and-cache.yml @@ -99,6 +99,11 @@ jobs: endpoint: ${{ vars.ATTIC_ENDPOINT }} cache: ${{ vars.ATTIC_CACHE }} token: ${{ secrets.ATTIC_TOKEN }} + - uses: cachix/cachix-action@v14 + with: + name: cything + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + useDaemon: false - name: Sync repository uses: actions/checkout@v4 with: -- 2.47.1 From 2c3c08c640e991b67f688ffd3ea255c932bbe8dd Mon Sep 17 00:00:00 2001 From: cy Date: Mon, 20 Jan 2025 01:57:06 -0500 Subject: [PATCH 2/6] use cachix to install and refactor --- .github/workflows/build-and-cache.yml | 40 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-cache.yml b/.github/workflows/build-and-cache.yml index 2c06dbd..da48f1d 100644 --- a/.github/workflows/build-and-cache.yml +++ b/.github/workflows/build-and-cache.yml @@ -11,20 +11,22 @@ jobs: os: - ubuntu-latest - macos-latest + runs-on: ${{ matrix.os }} continue-on-error: true steps: - - uses: DeterminateSystems/nix-installer-action@main - with: - logger: pretty - - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Install Nix + uses: cachix/install-nix-action@v30 + - name: Setup Attic cache uses: ryanccn/attic-action@v0 with: endpoint: ${{ vars.ATTIC_ENDPOINT }} cache: ${{ vars.ATTIC_CACHE }} token: ${{ secrets.ATTIC_TOKEN }} + - run: nix build -L '${{ matrix.package }}' + build-machines: strategy: matrix: @@ -35,6 +37,7 @@ jobs: os: - ubuntu-latest # - macos-latest + runs-on: ${{ matrix.os }} continue-on-error: true steps: @@ -50,21 +53,30 @@ jobs: remove-docker-images: 'true' build-mount-path: /nix build-mount-path-ownership: 'root:root' - - uses: DeterminateSystems/nix-installer-action@main - with: - logger: pretty - - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Install Nix + uses: cachix/install-nix-action@v30 + - name: Setup Attic cache uses: ryanccn/attic-action@v0 with: endpoint: ${{ vars.ATTIC_ENDPOINT }} cache: ${{ vars.ATTIC_CACHE }} token: ${{ secrets.ATTIC_TOKEN }} + + - uses: cachix/cachix-action@v14 + with: + name: cything + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + useDaemon: false + - name: Sync repository uses: actions/checkout@v4 with: persist-credentials: false + - run: nix build -L --accept-flake-config .#nixosConfigurations.${{ matrix.machine }}.config.system.build.toplevel + build-homes: strategy: matrix: @@ -74,6 +86,7 @@ jobs: os: - ubuntu-latest # - macos-latest + runs-on: ${{ matrix.os }} continue-on-error: true steps: @@ -89,23 +102,26 @@ jobs: remove-docker-images: 'true' build-mount-path: /nix build-mount-path-ownership: 'root:root' - - uses: DeterminateSystems/nix-installer-action@main - with: - logger: pretty - - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Install Nix + uses: cachix/install-nix-action@v30 + - name: Setup Attic cache uses: ryanccn/attic-action@v0 with: endpoint: ${{ vars.ATTIC_ENDPOINT }} cache: ${{ vars.ATTIC_CACHE }} token: ${{ secrets.ATTIC_TOKEN }} + - uses: cachix/cachix-action@v14 with: name: cything authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' useDaemon: false + - name: Sync repository uses: actions/checkout@v4 with: persist-credentials: false + - run: nix build -L --accept-flake-config .#homeConfigurations."${{ matrix.home }}".activationPackage -- 2.47.1 From 5146a40096937457cd41a291e6c28ebe40d68853 Mon Sep 17 00:00:00 2001 From: cy Date: Mon, 20 Jan 2025 02:09:16 -0500 Subject: [PATCH 3/6] use new cli to install cachix --- .github/workflows/build-and-cache.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build-and-cache.yml b/.github/workflows/build-and-cache.yml index da48f1d..937167e 100644 --- a/.github/workflows/build-and-cache.yml +++ b/.github/workflows/build-and-cache.yml @@ -18,6 +18,13 @@ jobs: - name: Install Nix uses: cachix/install-nix-action@v30 + - uses: cachix/cachix-action@v14 + with: + name: cything + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + useDaemon: false + installCommand: nix profile install nixpkgs#cachix + - name: Setup Attic cache uses: ryanccn/attic-action@v0 with: @@ -69,6 +76,7 @@ jobs: name: cything authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' useDaemon: false + installCommand: nix profile install nixpkgs#cachix - name: Sync repository uses: actions/checkout@v4 @@ -118,6 +126,7 @@ jobs: name: cything authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' useDaemon: false + installCommand: nix profile install nixpkgs#cachix - name: Sync repository uses: actions/checkout@v4 -- 2.47.1 From c463d0f55379bc46d203b51ae830de7a6b96831f Mon Sep 17 00:00:00 2001 From: cy Date: Mon, 20 Jan 2025 02:35:46 -0500 Subject: [PATCH 4/6] use nix-community cache action and nixbuild installer --- .github/workflows/build-and-cache.yml | 106 +++++++++++++------------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build-and-cache.yml b/.github/workflows/build-and-cache.yml index 937167e..6207e34 100644 --- a/.github/workflows/build-and-cache.yml +++ b/.github/workflows/build-and-cache.yml @@ -3,37 +3,6 @@ on: workflow_dispatch: push: jobs: - build-packages: - strategy: - matrix: - package: - - github:cything/nixpkgs#hello - os: - - ubuntu-latest - - macos-latest - - runs-on: ${{ matrix.os }} - continue-on-error: true - steps: - - name: Install Nix - uses: cachix/install-nix-action@v30 - - - uses: cachix/cachix-action@v14 - with: - name: cything - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - useDaemon: false - installCommand: nix profile install nixpkgs#cachix - - - name: Setup Attic cache - uses: ryanccn/attic-action@v0 - with: - endpoint: ${{ vars.ATTIC_ENDPOINT }} - cache: ${{ vars.ATTIC_CACHE }} - token: ${{ secrets.ATTIC_TOKEN }} - - - run: nix build -L '${{ matrix.package }}' - build-machines: strategy: matrix: @@ -43,7 +12,6 @@ jobs: - titan os: - ubuntu-latest - # - macos-latest runs-on: ${{ matrix.os }} continue-on-error: true @@ -61,15 +29,12 @@ jobs: build-mount-path: /nix build-mount-path-ownership: 'root:root' - - name: Install Nix - uses: cachix/install-nix-action@v30 + - uses: nixbuild/nix-quick-install-action@master - - name: Setup Attic cache - uses: ryanccn/attic-action@v0 + - name: Sync repository + uses: actions/checkout@v4 with: - endpoint: ${{ vars.ATTIC_ENDPOINT }} - cache: ${{ vars.ATTIC_CACHE }} - token: ${{ secrets.ATTIC_TOKEN }} + persist-credentials: false - uses: cachix/cachix-action@v14 with: @@ -78,10 +43,30 @@ jobs: useDaemon: false installCommand: nix profile install nixpkgs#cachix - - name: Sync repository - uses: actions/checkout@v4 + - name: Setup Attic cache + uses: ryanccn/attic-action@v0 with: - persist-credentials: false + endpoint: ${{ vars.ATTIC_ENDPOINT }} + cache: ${{ vars.ATTIC_CACHE }} + token: ${{ secrets.ATTIC_TOKEN }} + + - name: Restore and cache Nix store + uses: nix-community/cache-nix-action@v5.1.0 + with: + # restore and save a cache using this key + primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }} + # if there's no cache hit, restore a cache by this prefix + restore-prefixes-first-match: nix-${{ runner.os }}- + # do purge caches + purge: true + # purge all versions of the cache + purge-prefixes: nix-${{ runner.os }}- + # created more than this number of seconds ago relative to the start of the `Post Restore` phase + purge-last-accessed: 86400 + # except the version with the `primary-key`, if it exists + purge-primary-key: never + # always save the cache + save-always: true - run: nix build -L --accept-flake-config .#nixosConfigurations.${{ matrix.machine }}.config.system.build.toplevel @@ -111,15 +96,12 @@ jobs: build-mount-path: /nix build-mount-path-ownership: 'root:root' - - name: Install Nix - uses: cachix/install-nix-action@v30 + - uses: nixbuild/nix-quick-install-action@master - - name: Setup Attic cache - uses: ryanccn/attic-action@v0 + - name: Sync repository + uses: actions/checkout@v4 with: - endpoint: ${{ vars.ATTIC_ENDPOINT }} - cache: ${{ vars.ATTIC_CACHE }} - token: ${{ secrets.ATTIC_TOKEN }} + persist-credentials: false - uses: cachix/cachix-action@v14 with: @@ -128,9 +110,29 @@ jobs: useDaemon: false installCommand: nix profile install nixpkgs#cachix - - name: Sync repository - uses: actions/checkout@v4 + - name: Setup Attic cache + uses: ryanccn/attic-action@v0 with: - persist-credentials: false + endpoint: ${{ vars.ATTIC_ENDPOINT }} + cache: ${{ vars.ATTIC_CACHE }} + token: ${{ secrets.ATTIC_TOKEN }} + + - name: Restore and cache Nix store + uses: nix-community/cache-nix-action@v5.1.0 + with: + # restore and save a cache using this key + primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }} + # if there's no cache hit, restore a cache by this prefix + restore-prefixes-first-match: nix-${{ runner.os }}- + # do purge caches + purge: true + # purge all versions of the cache + purge-prefixes: nix-${{ runner.os }}- + # created more than this number of seconds ago relative to the start of the `Post Restore` phase + purge-last-accessed: 86400 + # except the version with the `primary-key`, if it exists + purge-primary-key: never + # always save the cache + save-always: true - run: nix build -L --accept-flake-config .#homeConfigurations."${{ matrix.home }}".activationPackage -- 2.47.1 From 3f49b1023be4e19b2bbb05dea81c23bc17099435 Mon Sep 17 00:00:00 2001 From: cy Date: Mon, 20 Jan 2025 02:40:29 -0500 Subject: [PATCH 5/6] fix perms on /nix --- .github/workflows/build-and-cache.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-and-cache.yml b/.github/workflows/build-and-cache.yml index 6207e34..4c2c311 100644 --- a/.github/workflows/build-and-cache.yml +++ b/.github/workflows/build-and-cache.yml @@ -27,7 +27,6 @@ jobs: remove-codeql: 'true' remove-docker-images: 'true' build-mount-path: /nix - build-mount-path-ownership: 'root:root' - uses: nixbuild/nix-quick-install-action@master @@ -94,7 +93,6 @@ jobs: remove-codeql: 'true' remove-docker-images: 'true' build-mount-path: /nix - build-mount-path-ownership: 'root:root' - uses: nixbuild/nix-quick-install-action@master -- 2.47.1 From b03abfaff38e130f2be1c3afb7a1dd5766761fc2 Mon Sep 17 00:00:00 2001 From: cy Date: Mon, 20 Jan 2025 02:53:31 -0500 Subject: [PATCH 6/6] use better primary key --- .github/workflows/build-and-cache.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-cache.yml b/.github/workflows/build-and-cache.yml index 4c2c311..217fd43 100644 --- a/.github/workflows/build-and-cache.yml +++ b/.github/workflows/build-and-cache.yml @@ -53,7 +53,7 @@ jobs: uses: nix-community/cache-nix-action@v5.1.0 with: # restore and save a cache using this key - primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }} + primary-key: nix-${{ runner.os }}-${{ matrix.machine }}-${{ hashFiles('flake.lock') }} # if there's no cache hit, restore a cache by this prefix restore-prefixes-first-match: nix-${{ runner.os }}- # do purge caches @@ -67,7 +67,7 @@ jobs: # always save the cache save-always: true - - run: nix build -L --accept-flake-config .#nixosConfigurations.${{ matrix.machine }}.config.system.build.toplevel + - run: nix build -L .#nixosConfigurations.${{ matrix.machine }}.config.system.build.toplevel build-homes: strategy: @@ -119,7 +119,7 @@ jobs: uses: nix-community/cache-nix-action@v5.1.0 with: # restore and save a cache using this key - primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }} + primary-key: nix-${{ runner.os }}-${{ matrix.home }}-${{ hashFiles('flake.lock') }} # if there's no cache hit, restore a cache by this prefix restore-prefixes-first-match: nix-${{ runner.os }}- # do purge caches @@ -133,4 +133,4 @@ jobs: # always save the cache save-always: true - - run: nix build -L --accept-flake-config .#homeConfigurations."${{ matrix.home }}".activationPackage + - run: nix build -L .#homeConfigurations."${{ matrix.home }}".activationPackage -- 2.47.1