mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-19 16:40:32 +03:00

After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
--argstr baseRev 0128fbb0a5
result/bin/apply-formatting $NIXPKGS_PATH
85 lines
1.8 KiB
Nix
85 lines
1.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
|
|
cfg = config.services.tor;
|
|
|
|
torify = pkgs.writeTextFile {
|
|
name = "tsocks";
|
|
text = ''
|
|
#!${pkgs.runtimeShell}
|
|
TSOCKS_CONF_FILE=${pkgs.writeText "tsocks.conf" cfg.tsocks.config} LD_PRELOAD="${pkgs.tsocks}/lib/libtsocks.so $LD_PRELOAD" "$@"
|
|
'';
|
|
executable = true;
|
|
destination = "/bin/tsocks";
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.tor.tsocks = {
|
|
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to build tsocks wrapper script to relay application traffic via Tor.
|
|
|
|
::: {.important}
|
|
You shouldn't use this unless you know what you're
|
|
doing because your installation of Tor already comes with
|
|
its own superior (doesn't leak DNS queries)
|
|
`torsocks` wrapper which does pretty much
|
|
exactly the same thing as this.
|
|
:::
|
|
'';
|
|
};
|
|
|
|
server = mkOption {
|
|
type = types.str;
|
|
default = "localhost:9050";
|
|
example = "192.168.0.20";
|
|
description = ''
|
|
IP address of TOR client to use.
|
|
'';
|
|
};
|
|
|
|
config = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
description = ''
|
|
Extra configuration. Contents will be added verbatim to TSocks
|
|
configuration file.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.tsocks.enable {
|
|
|
|
environment.systemPackages = [ torify ]; # expose it to the users
|
|
|
|
services.tor.tsocks.config = ''
|
|
server = ${toString (head (splitString ":" cfg.tsocks.server))}
|
|
server_port = ${toString (tail (splitString ":" cfg.tsocks.server))}
|
|
|
|
local = 127.0.0.0/255.128.0.0
|
|
local = 127.128.0.0/255.192.0.0
|
|
'';
|
|
};
|
|
|
|
}
|