~ruther/agent-environments

ref: 5c9177d3efc133d65f5bccfbb5a2e36c6a282985 agent-environments/examples/multi-account/flake.nix -rw-r--r-- 2.3 KiB
5c9177d3 — František Boháček Update flake inputs a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
  description = "agent-environments example: several logins and several environments";

  inputs = {
    # In your own flake: github:<owner>/agent-environments
    agent-environments.url = "path:../..";
    nixpkgs.follows = "agent-environments/nixpkgs";
  };

  outputs =
    { agent-environments, nixpkgs, ... }:
    let
      forAllSystems = nixpkgs.lib.genAttrs [
        "x86_64-linux"
        "aarch64-linux"
        "x86_64-darwin"
        "aarch64-darwin"
      ];
      inherit (agent-environments.lib) mkEnvironment;

      # Shared by both environments.
      common = {
        claude.enable = true;
        instructions.common.text = ''
          Always run the test suite before claiming a task is done.
        '';
      };
    in
    {
      packages = forAllSystems (
        system:
        let
          pkgs = nixpkgs.legacyPackages.${system};

          # One environment, three launchers. Each launcher id gets its own state
          # dir (~/.local/agent-environments/<id>), so each one logs in separately.
          main = mkEnvironment {
            inherit pkgs;
            modules = [
              common
              {
                codex.enable = true;
                launchers = {
                  claude-work-acc.agent = "claude";
                  claude-pers-acc.agent = "claude";
                  codex-work-acc.agent = "codex";
                };
              }
            ];
          };

          # A different set of modules with its own launcher and login.
          review = mkEnvironment {
            inherit pkgs;
            modules = [
              common
              {
                instructions.review = {
                  order = 2000;
                  text = "You only review code. Never edit files.";
                };
                claude.settings.permissions.deny = [
                  "Edit"
                  "Write"
                ];
                launchers.claude-review.agent = "claude";
              }
            ];
          };
        in
        {
          main = main.package;
          review = review.package;
          default = pkgs.symlinkJoin {
            name = "agent-environments";
            paths = [
              main.package
              review.package
            ];
          };
        }
      );
    };
}