this post was submitted on 14 Mar 2025
6 points (100.0% liked)

Nix / NixOS

2038 readers
2 users here now

Main links

Videos

founded 2 years ago
MODERATORS
 

I am attempting to configure the Tor daemon on nix-darwin. There is unfortunately no services.tor on this platform (yet ! maybe I'll port it from nixOS once I know enough Nix to do that)

I could manage it with homebrew, however, that seems like a sub-par solution, effectively moving tor entirely out of the nix store.

I have installed the package in my flake, and I would like to link a torrc config file to the right directory /etc/tor. However, when done with environment.etc, the file is linked to the general /etc outside of the store, where tor cannot find it.

How can I link this file inside tor's own /etc in the store, so it can use the configuration ?

Link to my config repo fixed at the current commit

you are viewing a single comment's thread
view the rest of the comments
[–] termaxima@jlai.lu 2 points 2 days ago (1 children)

I haven’t made it a service yet (it was going to be my next step), for now I was just starting it manually ! Your suggestion works (probably, not tested yet), but I was looking for a way to have the config loaded automatically even when running the tor command directly in a terminal (without any arguments)

[–] InnerScientist@lemmy.world 1 points 13 hours ago

Another way would be to create a small derivation that copies the default tor derivation, overwrites the etc folder and then use that as your system Tor. (See runCommand)

environment.systemPackages =
let
  my-custom-tor = pkgs.runCommand "my-custom-tor" {} ''
          mkdir $out
          cp -r ${pkgs.tor}/* $out/
          chmod -R 755 $out
          echo "config" > $out/etc/tor/torrc
          ''
in
[
...
my-custom-tor
...
]