diff options
Diffstat (limited to 'ext/terranix/tailscale')
| -rw-r--r-- | ext/terranix/tailscale/acl.nix | 65 | ||||
| -rw-r--r-- | ext/terranix/tailscale/default.nix | 3 | ||||
| -rw-r--r-- | ext/terranix/tailscale/devices.nix | 19 | ||||
| -rw-r--r-- | ext/terranix/tailscale/tags.nix | 17 |
4 files changed, 70 insertions, 34 deletions
diff --git a/ext/terranix/tailscale/acl.nix b/ext/terranix/tailscale/acl.nix index 338e373..80e3537 100644 --- a/ext/terranix/tailscale/acl.nix +++ b/ext/terranix/tailscale/acl.nix @@ -1,24 +1,51 @@ -{lib, ...}: { +{ lib, ... }: +{ resource.tailscale_acl.default = { - acl = toString (builtins.toJSON { - tagOwners = let - me = ["getchoo@github"]; - tags = map (name: "tag:${name}") ["server" "personal"]; - in - lib.genAttrs tags (_: me); + acl = toString ( + builtins.toJSON { + tagOwners = + let + me = [ "getchoo@github" ]; + tags = map (name: "tag:${name}") [ + "server" + "personal" + ]; + in + lib.genAttrs tags (_: me); - acls = let - mkAcl = action: src: dst: {inherit action src dst;}; - in [ - (mkAcl "accept" ["tag:personal"] ["*:*"]) - (mkAcl "accept" ["tag:server"] ["tag:server:*"]) - ]; + acls = + let + mkAcl = action: src: dst: { inherit action src dst; }; + in + [ + (mkAcl "accept" [ "tag:personal" ] [ "*:*" ]) + (mkAcl "accept" [ "tag:server" ] [ "tag:server:*" ]) + ]; - ssh = let - mkSshAcl = action: src: dst: users: {inherit action src dst users;}; - in [ - (mkSshAcl "accept" ["tag:personal"] ["tag:server" "tag:personal"] ["autogroup:nonroot" "root"]) - ]; - }); + ssh = + let + mkSshAcl = action: src: dst: users: { + inherit + action + src + dst + users + ; + }; + in + [ + (mkSshAcl "accept" [ "tag:personal" ] + [ + "tag:server" + "tag:personal" + ] + [ + "autogroup:nonroot" + "root" + ] + ) + ]; + } + ); }; } diff --git a/ext/terranix/tailscale/default.nix b/ext/terranix/tailscale/default.nix index 2225fd5..b370b34 100644 --- a/ext/terranix/tailscale/default.nix +++ b/ext/terranix/tailscale/default.nix @@ -1,4 +1,5 @@ -{lib, ...}: { +{ lib, ... }: +{ imports = [ ./acl.nix ./devices.nix diff --git a/ext/terranix/tailscale/devices.nix b/ext/terranix/tailscale/devices.nix index 44ee3f1..625c56e 100644 --- a/ext/terranix/tailscale/devices.nix +++ b/ext/terranix/tailscale/devices.nix @@ -1,11 +1,14 @@ -{lib, ...}: { - data.tailscale_device = let - toDevices = devices: - lib.genAttrs devices (name: { - name = "${name}.tailc59d6.ts.net"; - wait_for = "60s"; - }); - in +{ lib, ... }: +{ + data.tailscale_device = + let + toDevices = + devices: + lib.genAttrs devices (name: { + name = "${name}.tailc59d6.ts.net"; + wait_for = "60s"; + }); + in toDevices [ "atlas" "caroline" diff --git a/ext/terranix/tailscale/tags.nix b/ext/terranix/tailscale/tags.nix index ff41c82..3e82dbb 100644 --- a/ext/terranix/tailscale/tags.nix +++ b/ext/terranix/tailscale/tags.nix @@ -1,10 +1,15 @@ -{lib, ...}: { - resource.tailscale_device_tags = let - getDeviceID = device: lib.tfRef "data.tailscale_device.${device}.id"; - toTags = n: v: {device_id = getDeviceID n;} // v; +{ lib, ... }: +{ + resource.tailscale_device_tags = + let + getDeviceID = device: lib.tfRef "data.tailscale_device.${device}.id"; + toTags = n: v: { device_id = getDeviceID n; } // v; - tags = lib.genAttrs ["server" "personal"] (n: ["tag:${n}"]); - in + tags = lib.genAttrs [ + "server" + "personal" + ] (n: [ "tag:${n}" ]); + in builtins.mapAttrs toTags { atlas.tags = tags.server; caroline.tags = tags.personal; |
