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

Trouble using Cachix with nix develop #579

Open
mtlynch opened this issue Sep 16, 2023 · 10 comments
Open

Trouble using Cachix with nix develop #579

mtlynch opened this issue Sep 16, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@mtlynch
Copy link

mtlynch commented Sep 16, 2023

I'm a newcomer to Nix, and I'm trying to integrate nix develop into some of my open-source projects.

I have it working alright for one of them, but when I tried to switch my CI environment to use Nix, every job got 2m slower because it had to populate the Nix store.

I thought Cachix might be a good solution to this issue, but I'm having trouble getting up and running.

Here's what my current CircleCI config looks like with Cachix:

https://github.com/mtlynch/whatgotdone/blob/1cbde15946c95df95033180ab287adaa71c64a78/.circleci/config.yml

And as a relatively simple example, my lint_sql job looks like this:

https://github.com/mtlynch/whatgotdone/blob/1cbde15946c95df95033180ab287adaa71c64a78/.circleci/config.yml#L94-L112

lint_sql runs in 10s without Nix, but adding Nix balloons the runtime to 2.5m.

I thought I'd get a significant speedup from integrating Cachix, but it doesn't seem to have any impact on performance. From my dashboard, it seems like the CI config is successfully storing some of the Nix store to Cachix:

image

Does Cachix work with nix develop?

@domenkozar
Copy link
Member

Do you have a log of those runs? I'd also recommend using a docker image with cachix installed to avoid installing cachix during the CI itself.

@mtlynch
Copy link
Author

mtlynch commented Sep 20, 2023

@domenkozar
Copy link
Member

Most likely this is fixed by 8c7825c

@domenkozar
Copy link
Member

I just released 1.6.1, it should be part of the official installation tomorrow or a day after.

@domenkozar
Copy link
Member

@mtlynch could you try again now with Cachix 1.6.1?

@domenkozar domenkozar added the bug Something isn't working label Sep 27, 2023
@mtlynch
Copy link
Author

mtlynch commented Sep 27, 2023

@domenkozar - Sure, thanks for publishing the new version!

It seems to have sped it up quite a bit. It's now 86s as opposed to 146s pre-1.6.1.

https://app.circleci.com/pipelines/github/mtlynch/whatgotdone/2257/workflows/113fd2d4-b575-4f80-9169-b3c82f6bc674/jobs/8790

Is that expected behavior?

@domenkozar
Copy link
Member

domenkozar commented Sep 28, 2023

@mtlynch it's not, there should be no overhead at all.

If you remove cachix watch-exec "${CACHIX_NAME}" -- , how long does it take? I am guessing it's nix develop that takes a long time.

@mtlynch
Copy link
Author

mtlynch commented Oct 4, 2023

it's not, there should be no overhead at all.

Right, I'm not expecting overhead from Cachix, but I was wondering how much I should expect Cachix to reduce the time it takes to initialize the Nix shell from the flake.

Is the current speed about what I should expect? Or is there more headroom to gain from using Cachix in a more effective way than what I'm currently doing?

If you remove cachix watch-exec "${CACHIX_NAME}" -- , how long does it take? I am guessing it's nix develop that takes a long time.

96s, so roughly the same as with cachix watch-exec.

@domenkozar
Copy link
Member

it's not, there should be no overhead at all.

Right, I'm not expecting overhead from Cachix, but I was wondering how much I should expect Cachix to reduce the time it takes to initialize the Nix shell from the flake.

Is the current speed about what I should expect? Or is there more headroom to gain from using Cachix in a more effective way than what I'm currently doing?

If you remove cachix watch-exec "${CACHIX_NAME}" -- , how long does it take? I am guessing it's nix develop that takes a long time.

96s, so roughly the same as with cachix watch-exec.

That's mostly because Nix needs to download 4x nixpkgs in your case. I'd try to reduce the number of invocations.

@mtlynch
Copy link
Author

mtlynch commented Oct 6, 2023

Ah, interesting. I consolidated to a single nixpkg, which brings it down to 55s.

Is that about maximum expected performance with Cachix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants