Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfree package causes a rebuild for each new tree #72

Open
bd-bond opened this issue Jun 22, 2024 · 0 comments
Open

Unfree package causes a rebuild for each new tree #72

bd-bond opened this issue Jun 22, 2024 · 0 comments

Comments

@bd-bond
Copy link

bd-bond commented Jun 22, 2024

I have an unfree package in a devshell defined in a project's flake.nix, and for each unique git tree (branch) that executes a pipeline that uses that devshell, the package is rebuilt from scratch. The package is uploaded to the cache successfully, but other trees will not ever benefit from this. Subsequent pipeline runs on the same tree seem to re-use the cached package as expected.

This causes a painfully slow pipeline for each new branch, and for merging if using a merge queue. I'm led to believe that the cache is indexed on the specific tree.

  • Is this expected behavior?
  • Is there a way to avoid this behavior, such as ensuring that cache is indexed by some other identifier than what is currently being used? For example, a common pattern when using the GHA cache is to set restore-keys to foo-bar-${{ hashFiles('flake.nix') }} AND foo-bar-. This lets the action/cache fall back. Can this kind of behavior be implicitly supported in this action?

For context, here's a snippet from my flake.nix showing the package and devshell:

config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [
  "terraform"
];

...

devShells = forAllSystems ({ pkgs }: {
  terraform-shell = with pkgs; mkShell {
    packages = [
      terraform
    ];
  };
};

And the pipeline configuration:

name: lint

on:
  workflow_call:

jobs:
  filter:
    name: filter
    runs-on: ubuntu-latest
    outputs:
      terraform: ${{ steps.filter.outputs.terraform }}
      terraform_files: ${{ steps.filter.outputs.terraform_files }}
    steps:
      - uses: actions/checkout@v4
      - uses: dorny/paths-filter@v3
        id: filter
        with:
          list-files: shell
          filters: |
            terraform:
              - added|modified: '**/*.tf'

  terraform:
    name: terraform
    runs-on: ubuntu-latest
    needs:
      - filter
    if: needs.filter.outputs.terraform == 'true'
    steps:
      - uses: actions/checkout@v4
      - uses: determinatesystems/nix-installer-action@main
      - uses: determinatesystems/magic-nix-cache-action@main
        with:
          use-flakehub: false
      - run: |
          nix develop .#terraform-shell \
            --command terraform fmt -check -diff ${{ needs.filter.outputs.terraform_files }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant