share nix store between ci runners

This commit is contained in:
Cyryl Płotnicki 2022-12-21 20:11:47 +00:00
parent c2946cb23a
commit 397182ac97
3 changed files with 31 additions and 7 deletions

View file

@ -4,8 +4,9 @@ pipeline:
image: nixpkgs/nix-flakes:latest image: nixpkgs/nix-flakes:latest
pull: true pull: true
commands: commands:
- nix --no-sandbox develop --eval-store ./nix-store -c git remote add github https://cyplo:$GITHUB_TOKEN@github.com/cyplo/dotfiles.git - nix --no-sandbox develop --eval-store /var/build-nix-store -c git remote add github https://cyplo:$GITHUB_TOKEN@github.com/cyplo/dotfiles.git
- nix --no-sandbox develop --eval-store /var/build-nix-store -c git lfs fetch --all
- nix --no-sandbox develop --eval-store ./nix-store -c git lfs fetch --all - nix --no-sandbox develop --eval-store /var/build-nix-store -c git push github --all --force
- nix --no-sandbox develop --eval-store ./nix-store -c git push github --all --force
secrets: [ github_token ] secrets: [ github_token ]
volumes:
- /var/lib/woodpecker/nix-store:/var/build-nix-store

View file

@ -5,5 +5,7 @@ pipeline:
pull: true pull: true
commands: commands:
- time nix flake metadata - time nix flake metadata
- time nix --no-sandbox develop -c statix check - time nix --no-sandbox develop --eval-store /var/build-nix-store -c statix check
- time nix flake check - time nix flake check --eval-store /var/build-nix-store
volumes:
- /var/lib/woodpecker/nix-store:/var/build-nix-store

View file

@ -18,6 +18,7 @@
}; };
woodpeckerEnvSecretName = "woodpecker-env"; woodpeckerEnvSecretName = "woodpecker-env";
woodpeckerEnvSecretPath = "/run/secrets/${woodpeckerEnvSecretName}"; woodpeckerEnvSecretPath = "/run/secrets/${woodpeckerEnvSecretName}";
woodpeckerNixStorePath = "/var/lib/woodpecker/nix-store";
woodpeckerAgentContainer = { woodpeckerAgentContainer = {
autoStart = true; autoStart = true;
forwardPorts = [ forwardPorts = [
@ -27,6 +28,10 @@
hostPath = "${woodpeckerEnvSecretPath}"; hostPath = "${woodpeckerEnvSecretPath}";
isReadOnly = true; isReadOnly = true;
}; };
"${woodpeckerNixStorePath}" = {
hostPath = woodpeckerNixStorePath;
isReadOnly = false;
};
"/var/run/docker.sock" = { "/var/run/docker.sock" = {
hostPath = "/var/run/podman/podman.sock"; hostPath = "/var/run/podman/podman.sock";
isReadOnly = false; isReadOnly = false;
@ -59,12 +64,14 @@
}; };
systemd.services.woodpecker-agent = { systemd.services.woodpecker-agent = {
enable = true;
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
environment = { environment = {
WOODPECKER_SERVER = "${domain}:${toString agentPort}"; WOODPECKER_SERVER = "${domain}:${toString agentPort}";
WOODPECKER_MAX_PROCS = "1"; WOODPECKER_MAX_PROCS = "1";
WOODPECKER_DEBUG_PRETTY = "true"; WOODPECKER_DEBUG_PRETTY = "true";
WOODPECKER_LOG_LEVEL = "info"; WOODPECKER_LOG_LEVEL = "debug";
}; };
serviceConfig = { serviceConfig = {
EnvironmentFile = [ EnvironmentFile = [
@ -109,8 +116,22 @@ in {
virtualisation.podman = { virtualisation.podman = {
enable = true; enable = true;
}; };
systemd.services.woodpecker-make-path = {
script = ''
mkdir -p ${woodpeckerNixStorePath}
chown -R ${systemUserName}:${systemGroupName} ${woodpeckerNixStorePath}
'';
serviceConfig = {
Type = "oneshot";
};
};
containers.woodpecker-agent1 = woodpeckerAgentContainer; containers.woodpecker-agent1 = woodpeckerAgentContainer;
containers.woodpecker-agent2 = woodpeckerAgentContainer; containers.woodpecker-agent2 = woodpeckerAgentContainer;
containers.woodpecker-agent3 = woodpeckerAgentContainer; containers.woodpecker-agent3 = woodpeckerAgentContainer;
containers.woodpecker-agent4 = woodpeckerAgentContainer; containers.woodpecker-agent4 = woodpeckerAgentContainer;
systemd.services."container@woodpecker-agent1".requires = ["woodpecker-make-path.service"];
systemd.services."container@woodpecker-agent2".requires = ["woodpecker-make-path.service"];
systemd.services."container@woodpecker-agent3".requires = ["woodpecker-make-path.service"];
systemd.services."container@woodpecker-agent4".requires = ["woodpecker-make-path.service"];
} }