alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
clan_modules: add tor clan_module
author
lassulus
date
1 year ago
(Jul 8, 2025, 5:08 PM CEST)
commit
5a6d0567
5a6d0567e5a7175f128cf36583da4858be260f34
parent
53a28423
53a28423f7a2cbd52e8aebf42ad3db9638885e4b
+108
3 changed files
Expand all
Collapse all
Unified
Split
clan_modules
default.nix
tor.nix
flake.nix
+1
flake.nix
View file
Reviewed
···
143
143
};
144
144
};
145
145
};
146
146
+
modules = import ./clan_modules { inherit nixpkgs; };
146
147
inventory = {
147
148
meta.name = "superconfig";
148
149
machines = {
+23
clan_modules/default.nix
View file
Reviewed
···
1
1
+
{
2
2
+
nixpkgs,
3
3
+
...
4
4
+
}:
5
5
+
let
6
6
+
# Get all .nix files in this directory except default.nix
7
7
+
nixFiles = builtins.filter (name: name != "default.nix" && nixpkgs.lib.hasSuffix ".nix" name) (
8
8
+
builtins.attrNames (builtins.readDir ./.)
9
9
+
);
10
10
+
11
11
+
# Convert filename to module name (remove .nix extension)
12
12
+
nameFromPath = path: nixpkgs.lib.removeSuffix ".nix" path;
13
13
+
14
14
+
# Import each module
15
15
+
importModule = name: import (./. + "/${name}");
16
16
+
in
17
17
+
# Create attribute set with all modules
18
18
+
nixpkgs.lib.listToAttrs (
19
19
+
map (file: {
20
20
+
name = nameFromPath file;
21
21
+
value = importModule file;
22
22
+
}) nixFiles
23
23
+
)
+84
clan_modules/tor.nix
View file
Reviewed
···
1
1
+
{
2
2
+
_class = "clan.service";
3
3
+
manifest.name = "tor";
4
4
+
manifest.description = "tor networking between hosts";
5
5
+
manifest.categories = [ "networking" ];
6
6
+
roles.default = {
7
7
+
# interface =
8
8
+
# { lib, ... }:
9
9
+
# {
10
10
+
# options = {
11
11
+
# OciSettings = lib.mkOption {
12
12
+
# type = lib.types.raw;
13
13
+
# default = null;
14
14
+
# description = "NixOS settings for virtualisation.oci-container.<name>.settings";
15
15
+
# };
16
16
+
# buildContainer = lib.mkOption {
17
17
+
# type = lib.types.nullOr lib.types.str;
18
18
+
# default = null;
19
19
+
# };
20
20
+
# };
21
21
+
# };
22
22
+
perInstance =
23
23
+
{
24
24
+
instanceName,
25
25
+
roles,
26
26
+
lib,
27
27
+
...
28
28
+
}:
29
29
+
{
30
30
+
# nix run .#clan.inventory.instances.<instanceName>.actions.build-docker-container
31
31
+
exports.networking = {
32
32
+
priority = lib.mkDefault 10;
33
33
+
# TODO add user space network support to clan-cli
34
34
+
technology = "tor";
35
35
+
peers = lib.mapAttrs (name: machine: {
36
36
+
host.var = {
37
37
+
machine = name;
38
38
+
generator = "tor-ssh";
39
39
+
file = "hostname";
40
40
+
};
41
41
+
}) roles.default.machines;
42
42
+
};
43
43
+
nixosModule =
44
44
+
{
45
45
+
pkgs,
46
46
+
config,
47
47
+
...
48
48
+
}:
49
49
+
{
50
50
+
config = {
51
51
+
services.tor = {
52
52
+
enable = true;
53
53
+
relay.onionServices."clan_${instanceName}" = {
54
54
+
version = 3;
55
55
+
# TODO get ports from instance machine config
56
56
+
map = [
57
57
+
{
58
58
+
port = 22;
59
59
+
target.port = 22;
60
60
+
}
61
61
+
];
62
62
+
secretKey = config.clan.core.vars.generators."tor_${instanceName}".files.hs_ed25519_secret_key.path;
63
63
+
};
64
64
+
};
65
65
+
clan.core.vars.generators."tor_${instanceName}" = {
66
66
+
files.hs_ed25519_secret_key = { };
67
67
+
files.hostname = { };
68
68
+
runtimeInputs = with pkgs; [
69
69
+
coreutils
70
70
+
tor
71
71
+
];
72
72
+
script = ''
73
73
+
mkdir -p data
74
74
+
echo -e "DataDirectory ./data\nSocksPort 0\nHiddenServiceDir ./hs\nHiddenServicePort 80 127.0.0.1:80" > torrc
75
75
+
timeout 2 tor -f torrc || :
76
76
+
mv hs/hs_ed25519_secret_key $out/hs_ed25519_secret_key
77
77
+
mv hs/hostname $out/hostname
78
78
+
'';
79
79
+
};
80
80
+
};
81
81
+
};
82
82
+
};
83
83
+
};
84
84
+
}