Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions nixos/modules/security/apparmor.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
options,
config,
lib,
pkgs,
Expand All @@ -10,11 +11,6 @@ let
cfg = config.security.apparmor;
enabledPolicies = lib.filterAttrs (n: p: p.state != "disable") cfg.policies;
buildPolicyPath = n: p: lib.defaultTo (pkgs.writeText n p.profile) p.path;

# Accessing submodule options when not defined results in an error thunk rather than a regular option object
# We can emulate the behavior of `<option>.isDefined` by attempting to evaluate it instead
# This is required because getting isDefined on a submodule is not possible in global module asserts.
submoduleOptionIsDefined = value: (builtins.tryEval value).success;
in

{
Expand Down Expand Up @@ -130,7 +126,9 @@ in
# which does not recurse into sub-directories.
}
{
assertion = lib.xor (policyCfg.path != null) (submoduleOptionIsDefined policyCfg.profile);
assertion =
lib.xor (policyCfg.path != null)
options.security.apparmor.policies.valueMeta.attrs.${policyName}.configuration.options.profile.isDefined;
message = "`security.apparmor.policies.\"${policyName}\"` must define exactly one of either path or profile.";
}
]) cfg.policies
Expand Down
39 changes: 29 additions & 10 deletions nixos/modules/services/torrent/transmission.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ let
optionalString
optional
mkDefault
mkOptionDefault
versionOlder
escapeShellArgs
optionalAttrs
mkMerge
Expand Down Expand Up @@ -176,17 +178,12 @@ in
};
umask = mkOption {
type = types.either types.int types.str;
default = if cfg.package == pkgs.transmission_3 then 18 else "022";
defaultText = literalExpression "if cfg.package == pkgs.transmission_3 then 18 else \"022\"";
default = "022";
description = ''
Sets transmission's file mode creation mask.
See the {manpage}`umask(2)` manpage for more information.
Users who want their saved torrents to be world-writable
may want to set this value to 0/`"000"`.

Keep in mind, that if you are using Transmission 3, this has to
be passed as a base 10 integer, whereas Transmission 4 takes
an octal number in a string instead.
'';
};
utp-enabled = mkOption {
Expand Down Expand Up @@ -222,10 +219,19 @@ in
};
};

package = mkPackageOption pkgs "transmission" {
default = "transmission_3";
example = "pkgs.transmission_4";
};
package =
mkPackageOption pkgs "transmission" {
default = "transmission_4";
example = "pkgs.transmission_4";
}
// {
defaultText = ''
if lib.versionAtLeast config.system.stateVersion "25.11" then
pkgs.transmission_4
else
«error message»
'';
Comment on lines +226 to +233

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need this additional defaultText, I'd just stick with the default.

};

downloadDirPermissions = mkOption {
type = with types; nullOr str;
Expand Down Expand Up @@ -331,6 +337,19 @@ in
};

config = mkIf cfg.enable {
services.transmission.package = mkIf (versionOlder config.system.stateVersion "25.11") (
mkOptionDefault (throw ''
`services.transmission.package` previously defaulted to
`pkgs.transmission_3`, which has been removed in favour
of `pkgs.transmission_4`.

Please set `services.transmission.package` to
`pkgs.transmission_4` explicitly. Note that upgrade
caused data loss for some users so backup is recommended
(see NixOS 24.11 release notes for details)
'')
);

# Note that using systemd.tmpfiles would not work here
# because it would fail when creating a directory
# with a different owner than its parent directory, by saying:
Expand Down
3 changes: 1 addition & 2 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1537,8 +1537,7 @@ in
traefik = runTestOn [ "aarch64-linux" "x86_64-linux" ] ./traefik.nix;
trafficserver = runTest ./trafficserver.nix;
transfer-sh = runTest ./transfer-sh.nix;
transmission_3 = handleTest ./transmission.nix { transmission = pkgs.transmission_3; };
transmission_4 = handleTest ./transmission.nix { transmission = pkgs.transmission_4; };
transmission_4 = handleTest ./transmission.nix { };
trezord = runTest ./trezord.nix;
trickster = runTest ./trickster.nix;
trilium-server = runTestOn [ "x86_64-linux" ] ./trilium-server.nix;
Expand Down
7 changes: 3 additions & 4 deletions nixos/tests/bittorrent.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
# which only works if the first client successfully uses the UPnP-IGD
# protocol to poke a hole in the NAT.

{ pkgs, ... }:
{ lib, hostPkgs, ... }:

let

# Some random file to serve.
file = pkgs.hello.src;
file = hostPkgs.hello.src;

internalRouterAddress = "192.168.3.1";
internalClient1Address = "192.168.3.2";
Expand All @@ -23,7 +23,6 @@ let
transmissionConfig =
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.transmission_3 ];
Comment thread
wolfgangwalther marked this conversation as resolved.
services.transmission = {
enable = true;
settings = {
Expand All @@ -37,7 +36,7 @@ in

{
name = "bittorrent";
meta = with pkgs.lib.maintainers; {
meta = with lib.maintainers; {
maintainers = [
rob
bobvanderlinden
Expand Down
3 changes: 1 addition & 2 deletions nixos/tests/transmission.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ./make-test-python.nix (
{ pkgs, transmission, ... }:
{ pkgs, ... }:
{
name = "transmission";
meta = with pkgs.lib.maintainers; {
Expand All @@ -16,7 +16,6 @@ import ./make-test-python.nix (
security.apparmor.enable = true;

services.transmission.enable = true;
services.transmission.package = transmission;
};

testScript = ''
Expand Down
5 changes: 2 additions & 3 deletions pkgs/build-support/fetchtorrent/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
lib,
runCommand,
transmission_3_noSystemd,
transmission_4,
rqbit,
writeShellScript,
formats,
Expand Down Expand Up @@ -97,7 +97,7 @@ runCommand name
]
++ (
if (backend == "transmission") then
[ transmission_3_noSystemd ]
[ transmission_4 ]
else if (backend == "rqbit") then
[ rqbit ]
else
Expand Down Expand Up @@ -132,7 +132,6 @@ runCommand name
--portmap \
--finish ${transmissionFinishScript} \
--download-dir "$downloadedDirectory" \
--config-dir "$HOME"/.config/transmission \
"$url"
''
else
Expand Down
86 changes: 0 additions & 86 deletions pkgs/by-name/to/torrential/package.nix

This file was deleted.

Loading
Loading