This repository has no description
1{
2 config,
3 lib,
4 pkgs,
5 ...
6}: let
7 cfg = config.services.tangled.shuttle;
8
9 postBuildHook = pkgs.writeShellApplication {
10 name = "spindle-post-build-hook";
11 text = ''
12 set -f
13
14 if [ -z "''${OUT_PATHS:-}" ]; then
15 exit 0
16 fi
17
18 # OUT_PATHS is intentionally split into individual store paths for the agent
19 # shellcheck disable=SC2086
20 exec ${cfg.package}/bin/shuttle enqueue-built-paths $OUT_PATHS
21 '';
22 };
23in {
24 options.services.tangled.shuttle = {
25 enable = lib.mkEnableOption "the shuttle guest agent";
26
27 package = lib.mkOption {
28 type = lib.types.package;
29 description = "package providing the shuttle executable.";
30 };
31 };
32
33 config = lib.mkIf cfg.enable {
34 nix.settings.post-build-hook = "${postBuildHook}/bin/spindle-post-build-hook";
35
36 systemd.services.shuttle = {
37 description = "shuttle guest agent";
38 wantedBy = ["multi-user.target"];
39 wants = ["network-online.target"];
40 after = [
41 "local-fs.target"
42 "network-online.target"
43 ];
44 before = ["nix-daemon.service"];
45 restartIfChanged = false;
46 # nix flakes require git
47 path = [pkgs.gitMinimal];
48 environment = {
49 NIX_PATH = lib.concatStringsSep ":" config.nix.nixPath;
50 };
51 serviceConfig = {
52 Type = "simple";
53 ExecStart = "${cfg.package}/bin/shuttle";
54 Restart = "always";
55 RestartSec = "1s";
56 };
57 };
58 };
59}