Cache nix store between builds
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-10-15 20:46:37 +11:00
parent 1d75c44bc1
commit 45682cdbab
2 changed files with 151 additions and 1 deletions

View File

@@ -1,8 +1,45 @@
local Cache(name, settings) = {
name: name,
image: "meltwater/drone-cache",
pull: true,
settings: {
backend: "filesystem",
cache_key: "{{ .Repo.Name }}",
archive_format: "gzip",
mount: [
"/nix/store"
]
} + settings,
volumes: [
{
name: "cache",
path: "/tmp/cache"
}
]
};
local Pipeline(channel) = {
kind: "pipeline",
type: "docker",
name: channel,
// This is ignored by the drone-cli YAML translator, so unfortunately, it has
// to be copy-pasted into relevant steps.
environment: {
NIXPKGS_ALLOW_UNFREE: 1,
NUR_REPO: "xeals",
CACHIX_CACHE: "xeals",
CACHIX_SIGNING_KEY: { from_secret: "cachix_key" },
},
volumes: [
{
name: "cache",
temp: {}
}
],
steps: [
Cache("restore-nix-store", {
restore: true
}),
{
name: "build",
image: "nixos/nix",
@@ -32,7 +69,12 @@ local Pipeline(channel) = {
CACHIX_CACHE: "xeals",
CACHIX_SIGNING_KEY: { from_secret: "cachix_key" },
},
}
},
Cache("save-nix-store", {
rebuild: true
}) + {
when: { status: [ "success", "failure" ] }
},
]
};