# Docker + nix + gitlab ci: cache /nix/store per-machine

**URL:** https://discourse.nixos.org/t/docker-nix-gitlab-ci-cache-nix-store-per-machine/2003
**Category:** Deployments
**Created:** [January 30, 2019, 9:29pm UTC](https://discourse.nixos.org/t/docker-nix-gitlab-ci-cache-nix-store-per-machine/2003 "2019-01-30T21:29:36Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![turion](https://discourse.nixos.org/user_avatar/discourse.nixos.org/turion/32/583_2.png) [@turion](https://discourse.nixos.org/u/turion)
#### Post date: [March 21, 2020, 3:45pm UTC](https://discourse.nixos.org/t/docker-nix-gitlab-ci-cache-nix-store-per-machine/2003/8 "2020-03-21T15:45:59Z")

</div>

I ended up using [https://cachix.org/](https://cachix.org/) for caching. The setup is basically:

```auto
$ cat .gitlab-ci.yml
image: nixos/nix:latest

before_script:
  - nix-env -iA nixpkgs.cachix
  - cachix use insertyourcachixnamehere

build:
  stage: build
  script:
    - nix-build

```

Before I push build on CI, I do `nix-build | cachix push insertyourcachixnamehere` on my dev machine. It uploads store paths to my personal cache, and CI downloads them instead of rebuilding them. I could cut down the pipeline time from 30 minutes to 3 that way.

---

_[View the full topic](https://discourse.nixos.org/t/docker-nix-gitlab-ci-cache-nix-store-per-machine/2003)._
