This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

clan_modules: add tor clan_module

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