Commit Graph

84 Commits

Author SHA1 Message Date
Amanda Graven
7d0213ac69 tor: Add example to onionServices.name.map 2026-03-15 17:23:29 +01:00
Julien Moutinho
49dc4455a6 nixos/tor: do not change the default of SystemCallErrorNumber=
No reason to do so.
2026-01-20 20:03:51 +01:00
Julien Moutinho
d5d3834b9d nixos/tor: do not bind storeDir when systemd-confinement is enabled
Otherwise it undermines systemd-confinement
whose job is to filter what gets bind mounted from the storeDir.
2026-01-20 20:03:51 +01:00
Julien Moutinho
aa24bdf88f nixos/tor: do not put Unix sockets in BindPaths=
- The socket may not be accessible at all times resulting in the Tor unit failing to start.
- If the socket is re-created it will become inaccessible.
- Tor can't be started if any of the UNIX sockets are not available,
which may result in a single service having issues affecting all services.
(It may be best to start Tor to serve N-1 sockets even if 1 socket isn't available).

Reverts: https://github.com/NixOS/nixpkgs/pull/440889
Fixes: https://github.com/NixOS/nixpkgs/issues/481673
Reported-by: https://github.com/kevincox
2026-01-20 20:03:51 +01:00
Defelo
1910e55108 nixos/tor: add obfs4Package option 2025-11-13 19:18:44 +01:00
Defelo
c1c350a142 nixos/tor: use cfg.package instead of pkgs.tor 2025-11-13 19:18:43 +01:00
Philipp Conrad
88b69de507 nixos/tor: allow only valid names in the Nickname option 2025-11-13 15:01:35 +01:00
n0099
ed40481861 nixos/tor: replace ints.between 0 65535 with lib.types.ints.u16 2025-10-28 03:21:43 +00:00
n0099
31b883fbe9 nixos/tor: replace ints.between 0 65535 with lib.types.port 2025-10-28 00:16:06 +00:00
h7x4
3487e7743f nixos/tor: fix nix expression for BindPaths
`BindPaths` would earlier fail to eval under certain configurations due
to a lack of null checking
2025-10-15 03:12:48 +09:00
euxane
16a1b0e531 nixos/tor: add onion service unix sockets to BindPaths
Setting up an onion service with a UNIX socket with
`services.tor.relay.onionServices.<name>.target.unix` didn't work out
of the box because the tor service runs within an isolated root.
This adds the missing path binding to make this work.
2025-09-07 13:09:20 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Peder Bergebakken Sundt
c77ac9dfc3 treewide: fix typos 2025-06-02 16:07:07 +02:00
h7x4
ab0564bd10 treewide: add documentation for nixos systemd units 2025-03-12 18:00:38 +01:00
Philip Taron
b74d409127 nixos/tor: fix eval take three
This time I looked through all the symbols in `lib` and verified that each instance had a `lib.` before it.

The `nixosTests.tor` continues to pass. It doesn't cover all the cases, sadly.
2025-01-01 14:43:02 -08:00
Philip Taron
18765d044a nixos/tor: fix eval
Resolves #369847
2025-01-01 12:10:04 -08:00
Mitchell Skaggs
10ef89de45 nixos/services.tor: remove with lib; 2025-01-01 00:18:07 -06:00
Felix Buehler
d9297314fe nixos/services.tor: fmt 2024-12-30 12:09:42 +01:00
Felix Buehler
a5b40fbc8b nixos/services.tor: remove with lib; 2024-12-30 12:09:42 +01:00
Silvan Mosberger
4f0dadbf38 treewide: format all inactive Nix files
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 a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
Dmitriy Kholkin
0929716b02 nixos/tor: fix transport plugin exe name 2023-12-29 23:20:15 +03:00
h7x4
0a37316d6c treewide: use mkPackageOption
This commit replaces a lot of usages of `mkOption` with the package
type, to be `mkPackageOption`, in order to reduce the amount of code.
2023-11-27 01:28:36 +01:00
Felix Buehler
933a41a73f treewide: use optional instead of 'then []' 2023-06-25 09:11:40 -03:00
figsoda
6bb0dbf91f nixos: fix typos 2022-12-17 19:31:14 -05:00
Artturin
7e49471316 treewide: optional -> optionals where the argument is a list
the argument to optional should not be list
2022-10-10 15:40:21 +03:00
pennae
1d41cff3dc nixos/*: convert straggler options to MD 2022-08-31 17:27:38 +02:00
pennae
bd56368848 nixos/*: md-convert hidden plaintext options
most of these are hidden because they're either part of a submodule that
doesn't have its type rendered (eg because the submodule type is used in
an either type) or because they are explicitly hidden. some of them are
merely hidden from nix-doc-munge by how their option is put together.
2022-08-31 16:32:54 +02:00
pennae
ef176dcf7e nixos/*: automatically convert option descriptions
conversions were done using https://github.com/pennae/nix-doc-munge
using (probably) rev f34e145 running

    nix-doc-munge nixos/**/*.nix
    nix-doc-munge --import nixos/**/*.nix

the tool ensures that only changes that could affect the generated
manual *but don't* are committed, other changes require manual review
and are discarded.
2022-08-31 16:32:53 +02:00
pennae
e4f876eb7e nixos/*: convert varlist-using options to MD
there are sufficiently few variable list around, and they are
sufficiently simple, that it doesn't seem helpful to add another
markdown extension for them. rendering differences are small, except in
the tor module: admonitions inside other blocks cannot be made to work
well with mistune (and likely most other markdown processors), so those
had to be shuffled a bit. we also lose paragraph breaks in the list
items due to how we have to render from markdown to docbook, but once we
remove docbook from the pipeline those paragraph breaks will be restored.
2022-08-31 16:32:53 +02:00
pennae
5841c386a0 nixos/*: remove indentation from long enable options
the way these are written they introduce lots of whitespace in each
line, which will cause those lines to render as code when converted to
markdown. override the whole description instead.
2022-08-31 16:21:14 +02:00
pennae
e607b30abe nixos/tor: convert option descriptions to MD
no change in rendered output. the html manual could render <screen>
blocks differently, but so far it hasn't (and if we need to make a
distinction we can use a special info string).
2022-08-27 19:18:29 +02:00
pennae
61e93df189 nixos/*: automatically convert option docs to MD
once again using nix-doc-munge (69d080323a)
2022-08-03 22:46:41 +02:00
pennae
3aebb4a2be nixos/*: normalize link format
make (almost) all links appear on only a single line, with no
unnecessary whitespace, using double quotes for attributes. this lets us
automatically convert them to markdown easily.

the few remaining links are extremely long link in a gnome module, we'll
come back to those at a later date.
2022-08-03 21:57:46 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Luflosi
1b34039b5f nixos/tor: fix services.tor.client.enable = false not working
If `services.tor.client.enable` is set to false (the default), the `SOCKSPort` option is not added to the torrc file but since Tor defaults to listening on port 9050 when the option is not specified, the tor client is not actually disabled. To fix this, simply set `SOCKSPort` to 0, which disables the client.
Use `mkForce` to prevent potentially two different `SOCKSPort` options in the torrc file, with one of them being 0 as this would cause Tor to fail to start. When `services.tor.client.enable` is set to false, this should always be disabled.
2022-03-15 23:39:02 +01:00
Luflosi
3c63da7cf8 nixos/tor: allow tor to read resolv.conf when using resolved
When `services.resolved.enable` is set to true, the file /etc/resolv.conf becomes a symlink to /etc/static/resolv.conf, which is a symlink to /run/systemd/resolve/stub-resolv.conf. Without this commit, tor does not have access to this file thanks to systemd confinement. This results in the following warning when tor starts:
```
[warn] Unable to stat resolver configuration in '/etc/resolv.conf': No such file or directory
[warn] Could not read your DNS config from '/etc/resolv.conf' - please investigate your DNS configuration. This is possibly a problem. Meanwhile, falling back to local DNS at 127.0.0.1.
```
To fix this, simply allow read-only access to the file when resolved is in use.
According to https://github.com/NixOS/nixpkgs/pull/161818#discussion_r824820462, the symlink may also point to /run/systemd/resolve/resolv.conf, so allow that as well.
2022-03-15 15:16:14 +01:00
lassulus
236a731da0 nixos/tor: admit newlines in secret key 2022-03-09 15:11:01 +01:00
Luflosi
c6bd1eea71 nixos/tor: fix tor getting killed by systemd when shuttding down
Tor waits ShutdownWaitLength seconds (30s by default) before actually shutting down. Since the systemd timeout is also set to 30 seconds, this results in a race condition that ends up killing Tor most of the time on my machine during shutdown.
To fix this, add the ShutdownWaitLength setting and tell systemd to wait 30 seconds more than that.
Arch Linux also has `TimeoutSec` set to 60 seconds: 6df716fe19/trunk/tor.service.
2022-01-25 15:02:18 +01:00
pennae
ed673a69db treewide: add defaultText for options with simple cfg.* expression defaults
adds defaultText for options with defaults that use only literals, full config.*
paths, and the cfg shortcut binding.
2021-12-09 01:14:16 +01:00
Sandro
e5ac2e1a52 Merge pull request #122452 from ju1m/tor 2021-11-09 21:50:57 +01:00
Naïm Favier
2ddc335e6f nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Pierre Bourdon
6b70d3e911 nixos/tor: allow AF_NETLINK address family
Tor attempts to detect what external IP address a machine is using by
listing addresses on all network interfaces on the system. This listing
is done using getifaddrs(3), which relies on netlink in order to get
IPv6 address information.

This change fixes Tor not finding the relay's IPv6 address unless
explicitly configured via either an ORPort directive or via DNS
resolution of the machine hostname.
2021-08-25 06:03:41 +02:00
Tom
33a4c43126 nixos/tor: fix HidServAuth (#122439)
* add an example for services.tor.settings.HidServAuth

* fix HidServAuth validation to require ".onion"
  Per https://manpages.debian.org/testing/tor/torrc.5.en.html :
  > Valid onion addresses contain 16 characters in a-z2-7 plus ".onion"
2021-05-11 10:10:32 +02:00
Julien Moutinho
cd1f6bc712 nixos/tor: harden ProcSubset and ProtectProc 2021-05-10 16:50:41 +02:00
Julien Moutinho
7a62c0bc95 nixos/tor: fix openFirewall when ORPort isInt 2021-01-12 10:14:14 +01:00
Julien Moutinho
74f9321966 nixos/tor: fix client.dns.automapHostsSuffixes renaming 2021-01-05 22:34:01 +01:00
Julien Moutinho
0ccdd6f2b0 nixos/tor: improve type-checking and hardening
Fixes #77395.
Fixes #82790.
2021-01-04 01:02:26 +01:00
Alyssa Ross
e17d4b05a1 nixos/tor: don't do privoxy stuff by default
It's very surprising that services.tor.client.enable would set
services.privoxy.enable.  This violates the principle of least
astonishment, because it's Privoxy that can integrate with Tor, rather
than the other way around.

So this patch moves the Privoxy Tor integration to the Privoxy module,
and it also disables it by default.  This change is documented in the
release notes.

Reported-by: V <v@anomalous.eu>
2020-12-16 12:20:03 +00:00
WORLDofPEACE
18348c7829 Merge pull request #96042 from rnhmjoj/loaOf
treewide: completely remove types.loaOf
2020-09-02 08:45:37 -04:00