post-build-hook: Make post build hook async

This commit is contained in:
adisbladis 2020-04-18 12:35:10 +01:00
parent a5404a8379
commit 981ae44851
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7
2 changed files with 46 additions and 1 deletions

View file

@ -4,13 +4,46 @@ let
postBuildHook = pkgs.writeScript "post-build-hook.sh" ''
#!${pkgs.runtimeShell}
export PATH=$PATH:${pkgs.nix}/bin
exec ${pkgs.cachix}/bin/cachix -c /var/lib/post-build-hook/nix-community-cachix.dhall push nix-community $OUT_PATHS
'';
sockPath = "/run/post-build-hook.sock";
queueBuildHook = pkgs.writeScript "post-build-hook.sh" ''
${pkgs.queued-build-hook}/bin/queued-build-hook queue --socket ${sockPath}
'';
sources = import ../nix/sources.nix;
in {
nixpkgs.overlays = [
(self: super: {
queued-build-hook = (import sources.queued-build-hook {});
})
];
systemd.sockets.queued-build-hook = {
description = "Post-build-hook socket";
wantedBy = [ "sockets.target" ];
socketConfig = {
ListenStream = sockPath;
SocketUser = "root";
SocketMode = "0600";
};
};
systemd.services.queued-build-hook = {
description = "Post-build-hook service";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" "queued-build-hook.socket" ];
requires = [ "queued-build-hook.socket" ];
serviceConfig.ExecStart = "${pkgs.queued-build-hook}/bin/queued-build-hook daemon --retry-interval 30 --hook ${postBuildHook}";
};
nix.extraOptions = ''
post-build-hook = ${postBuildHook}
post-build-hook = ${queueBuildHook}
'';
}

View file

@ -47,6 +47,18 @@
"url": "https://github.com/jonringer/nixpkgs-update-pypi-releases/archive/cf72f9a94b0ccc306c025eba222a70456378433d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"queued-build-hook": {
"branch": "master",
"description": "Queue and retry Nix post-build-hook",
"homepage": null,
"owner": "nix-community",
"repo": "queued-build-hook",
"rev": "24882efb9b61fc39273c6421b914d45701f85cb8",
"sha256": "0q1bvbsny5xs5wnzn17zwgigb3xkrjxy7vm1yxk24kam1vcwymv9",
"type": "tarball",
"url": "https://github.com/nix-community/queued-build-hook/archive/24882efb9b61fc39273c6421b914d45701f85cb8.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"simple-hydra": {
"branch": "master",
"description": "A simple module for enabling Hydra",