052a1a49371c | atagen | 2026-09-27 03:59 UTC | 1 | self: |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 2 | { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 3 | config, |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 4 | lib, |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 5 | pkgs, |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 6 | ... |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 7 | }: |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 8 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 9 | let |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 10 | cfg = config.programs.roundabout; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 11 | toml = pkgs.formats.toml { }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 12 | plugin = pkgs.callPackage ./plugin.nix { roundabout = cfg.package; }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 13 | codexPlugin = pkgs.callPackage ./codex-plugin.nix { roundabout = cfg.package; }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 14 | ompPlugin = pkgs.callPackage ./omp-plugin.nix { roundabout = cfg.package; }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 15 | in |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 16 | { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 17 | options.programs.roundabout = { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 18 | enable = lib.mkEnableOption "roundabout, build admission for agents"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 19 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 20 | package = lib.mkOption { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 21 | type = lib.types.package; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 22 | default = self.packages.${pkgs.stdenv.hostPlatform.system}.roundabout; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 23 | defaultText = lib.literalExpression "roundabout.packages.\${system}.roundabout"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 24 | description = "the roundabout package"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 25 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 26 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 27 | socketActivation = lib.mkOption { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 28 | type = lib.types.bool; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 29 | default = true; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 30 | description = '' |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 31 | let a systemd user socket own `$XDG_RUNTIME_DIR/roundabout.sock` and start the |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 32 | daemon on demand. when disabled, the first client spawns daemon instead |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 33 | ''; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 34 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 35 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 36 | settings = lib.mkOption { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 37 | inherit (toml) type; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 38 | default = { }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 39 | example = lib.literalExpression '' |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 40 | { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 41 | budget.ram = "16GiB"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 42 | enforce.unwrapped = "wrap"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 43 | artifacts.stop = "block"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 44 | } |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 45 | ''; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 46 | description = '' |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 47 | written to `/etc/roundabout/config.toml`, which anyone without a |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 48 | `~/.config/roundabout/config.toml` of their own gets. see readme |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 49 | ''; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 50 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 51 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 52 | claude = { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 53 | hooks = lib.mkOption { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 54 | type = lib.types.attrs; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 55 | readOnly = true; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 56 | default = import ./hooks.nix { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 57 | inherit lib; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 58 | roundabout = cfg.package; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 59 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 60 | defaultText = lib.literalMD "roundabout's hooks, keyed by event"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 61 | description = '' |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 62 | hooks in `settings.json` shape, for whatever writes your claude config. |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 63 | lists concatenate under the json format type, so they sit alongside |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 64 | hooks you already have |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 65 | ''; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 66 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 67 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 68 | skill = lib.mkOption { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 69 | type = lib.types.path; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 70 | readOnly = true; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 71 | default = "${plugin}/plugins/roundabout/skills/roundabout"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 72 | defaultText = lib.literalMD "the roundabout skill directory"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 73 | description = "the skill directory, for configs that manage `~/.claude/skills` themselves"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 74 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 75 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 76 | plugin = lib.mkOption { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 77 | type = lib.types.package; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 78 | readOnly = true; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 79 | default = plugin; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 80 | defaultText = lib.literalMD "the roundabout plugin marketplace"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 81 | description = "hooks and skill as a marketplace, for `claude plugin marketplace add`"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 82 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 83 | }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 84 | |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 85 | codex = { |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 86 | hooks = lib.mkOption { |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 87 | type = lib.types.attrs; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 88 | readOnly = true; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 89 | default = import ./codex-hooks.nix { |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 90 | inherit lib; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 91 | roundabout = cfg.package; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 92 | }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 93 | defaultText = lib.literalMD "roundabout's Codex hooks, keyed by event"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 94 | description = "hooks in Codex hooks.json shape, for configs that manage Codex themselves"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 95 | }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 96 | |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 97 | skill = lib.mkOption { |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 98 | type = lib.types.path; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 99 | readOnly = true; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 100 | default = "${codexPlugin}/plugins/roundabout/skills/roundabout"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 101 | defaultText = lib.literalMD "the roundabout skill directory for Codex"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 102 | description = "the skill directory, for configs that manage Codex skills themselves"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 103 | }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 104 | |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 105 | plugin = lib.mkOption { |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 106 | type = lib.types.package; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 107 | readOnly = true; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 108 | default = codexPlugin; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 109 | defaultText = lib.literalMD "the roundabout Codex plugin marketplace"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 110 | description = "hooks and skill as a marketplace for Codex"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 111 | }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 112 | }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 113 | |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 114 | omp = { |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 115 | plugin = lib.mkOption { |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 116 | type = lib.types.package; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 117 | readOnly = true; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 118 | default = ompPlugin; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 119 | defaultText = lib.literalMD "the roundabout OMP plugin"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 120 | description = "the extension and skill for omp plugin link"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 121 | }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 122 | |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 123 | skill = lib.mkOption { |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 124 | type = lib.types.path; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 125 | readOnly = true; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 126 | default = "${ompPlugin}/skills/roundabout"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 127 | defaultText = lib.literalMD "the roundabout skill directory for OMP"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 128 | description = "the skill directory, for configs that manage OMP skills themselves"; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 129 | }; |
4e5ca2e20401 | atagen | 2026-09-28 11:42 UTC | 130 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 131 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 132 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 133 | config = lib.mkIf cfg.enable { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 134 | environment.systemPackages = [ cfg.package ]; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 135 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 136 | # a real file rather than the usual /etc/static symlink, so a rebuild |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 137 | # renames over it where the daemon's inotify watch can see |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 138 | environment.etc."roundabout/config.toml" = lib.mkIf (cfg.settings != { }) { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 139 | source = toml.generate "roundabout-config.toml" cfg.settings; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 140 | mode = "0444"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 141 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 142 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 143 | systemd.user.sockets.roundabout = lib.mkIf cfg.socketActivation { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 144 | description = "roundabout build admission socket"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 145 | wantedBy = [ "sockets.target" ]; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 146 | listenStreams = [ "%t/roundabout.sock" ]; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 147 | socketConfig.SocketMode = "0600"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 148 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 149 | |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 150 | systemd.user.services.roundabout = lib.mkIf cfg.socketActivation { |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 151 | description = "roundabout build admission daemon"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 152 | serviceConfig.ExecStart = "${lib.getExe cfg.package} daemon"; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 153 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 154 | }; |
052a1a49371c | atagen | 2026-09-27 03:59 UTC | 155 | } |