cachix / cachix-action

Build software only once and put it in a global cache
https://cachix.org
Apache License 2.0
255 stars 40 forks source link

flakes support #47

Open domenkozar opened 4 years ago

domenkozar commented 4 years ago

https://docs.cachix.org/pushing#flakes

mpscholten commented 1 year ago

Any updates on this one here since 2020? We're migrating IHP to devenv via nix flakes and there's a lot of reports from people using latest IHP master that their IHP is building from scratch instead of fetching from cachix (https://github.com/digitallyinduced/ihp/issues/1740 https://github.com/digitallyinduced/ihp/issues/1728)

If flakes are not supported with the cachix-action, this would explain the problem

sandydoo commented 1 year ago

@mpscholten, AFAIK this is a feature request for automatically building and caching the inputs/outputs of a flake.

The action should pick up any paths built during the run, whether it's through nix build or nix develop. I've been digging through the IHP actions logs and the only suspicious thing I see is this build of nodejs that doesn't get uploaded to the cache. But it seems to be available in the next run, so perhaps some concurrent job got to it first?

mpscholten commented 1 year ago

Thanks for taking a look! :)

The action should pick up any paths built during the run, whether it's through nix build or nix develop.

Thanks for clarifying 👍 Re nodejs: unlikely to be a concurrent job, more likely that it's already stored in cachix (we don't have any custom nix code related to nodejs, so it should come right from within nixpkgs)

Then the cache misses of IHP need to be caused by something else. Could this be the use of --impure or something related to that? I would expect all binaries to get served from cachix as long as the flake.lock stays the same (nix-build was working perfectly before)

domenkozar commented 1 year ago

@mpscholten --impure just implies that Nix can access some otherwise restrictive operations.

What paths do you see that are built on CI but not substituted?

mpscholten commented 1 year ago

--impure just implies that Nix can access some otherwise restrictive operations.

Thanks for confirming 👍

What paths do you see that are built on CI but not substituted?

Since the changes I did on friday on our github actions, I cannot reproduce the issue anymore. And it seems to be fixed for other people that reported the problem as well. So right now I cannot pinpoint it to a specific path.

One possible explanation: We've added a call to git add . to the github action on friday. A script in our pipeline patches the flake.nix to add a ?ref=CURRENT_GH_ACTION_COMMIT to the ihp flake input url. As I understand without the git add ., nix develop didn't pick up the latest flake.nix but instead used the one without the ?ref=.. url parameter. Thus evaulating an older version of IHP and not the current one which we want to build.

domenkozar commented 1 year ago

As far as I know, flakes use git only to check what paths are tracked by git, but they do use the latest version.

mpscholten commented 1 year ago

Ok, then I'm out of ideas what could have caused this. I'll post here if we eventually figure out the root cause. So far no one has reported the problem anymore.

(btw: thanks again for making devenv :) it's now used across nearly all our projects (even in non IHP projects))

skykanin commented 1 year ago

I have a flake which exports two devShells, but even when using cachix/cachix-action@v12 I get this error in the post setup:

Post job cleanup.
Stopping SSH agent
The "file" argument must be of type string. Received undefined
Error stopping the SSH agent, proceeding anyway

I'm using Nix version 2.17.0 for this.

domenkozar commented 1 year ago

Could you give us a link to the job?

skykanin commented 1 year ago

Could you give us a link to the job?

Unfortunately I cannot as this is for work purposes. I might try to make a repro.