Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus-kirk committed Dec 4, 2024
1 parent 7d1dd5e commit c6a6d0f
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 184 deletions.
63 changes: 32 additions & 31 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,41 @@
nixpkgs,
vpnconfinement,
...
} @ inputs:
let
# Systems supported
supportedSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
} @ inputs: let
# Systems supported
supportedSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];

# Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in {
nixosModules = {
default = {
imports = [ ./nixarr vpnconfinement.nixosModules.default ];
};
# Helper to provide system-specific attributes
forAllSystems = f:
nixpkgs.lib.genAttrs supportedSystems (system:
f {
pkgs = import nixpkgs {inherit system;};
});
in {
nixosModules = {
default = {
imports = [./nixarr vpnconfinement.nixosModules.default];
};
};

devShells = forAllSystems ({ pkgs } : {
default = pkgs.mkShell {
packages = with pkgs; [
alejandra
nixd
];
};
});
devShells = forAllSystems ({pkgs}: {
default = pkgs.mkShell {
packages = with pkgs; [
alejandra
nixd
];
};
});

packages = forAllSystems ({ pkgs } : {
default = pkgs.callPackage ./mkDocs.nix {inherit inputs;};
});
packages = forAllSystems ({pkgs}: {
default = pkgs.callPackage ./mkDocs.nix {inherit inputs;};
});

formatter = forAllSystems ({ pkgs }: pkgs.alejandra);
};
formatter = forAllSystems ({pkgs}: pkgs.alejandra);
};
}
2 changes: 1 addition & 1 deletion nixarr/bazarr/bazarr-module/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ in {
util-nixarr.services.bazarr = {
enable = mkEnableOption "bazarr, a subtitle manager for Sonarr and Radarr";

package = mkPackageOption pkgs "bazarr" { };
package = mkPackageOption pkgs "bazarr" {};

openFirewall = mkOption {
type = types.bool;
Expand Down
6 changes: 3 additions & 3 deletions nixarr/bazarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ in {
'';
};

package = mkPackageOption pkgs "bazarr" { };
package = mkPackageOption pkgs "bazarr" {};

stateDir = mkOption {
type = types.path;
Expand All @@ -36,11 +36,11 @@ in {
> **Warning:** Setting this to any path, where the subpath is not
> owned by root, will fail! For example:
>
>
> ```nix
> stateDir = /home/user/nixarr/.state/bazarr
> ```
>
>
> Is not supported, because `/home/user` is owned by `user`.
'';
};
Expand Down
101 changes: 56 additions & 45 deletions nixarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,58 @@ with lib; let
fix-permissions = pkgs.writeShellApplication {
name = "fix-permissions";
runtimeInputs = with pkgs; [util-linux];
text = ''
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
find "${cfg.mediaDir}" \( -type d -exec chmod 0775 {} + -true \) -o \( -exec chmod 0664 {} + \)
'' + strings.optionalString cfg.jellyfin.enable ''
chown -R streamer:media "${cfg.mediaDir}/library"
chown -R streamer:root "${cfg.jellyfin.stateDir}"
find "${cfg.jellyfin.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'' + strings.optionalString cfg.transmission.enable ''
chown -R torrenter:media "${cfg.mediaDir}/torrents"
chown -R torrenter:cross-seed "${cfg.transmission.stateDir}"
find "${cfg.transmission.stateDir}" \( -type d -exec chmod 0750 {} + -true \) -o \( -exec chmod 0640 {} + \)
'' + strings.optionalString cfg.sabnzbd.enable ''
chown -R usenet:media "${cfg.mediaDir}/usenet"
chown -R usenet:root "${cfg.sabnzbd.stateDir}"
find "${cfg.sabnzbd.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'' + strings.optionalString cfg.transmission.privateTrackers.cross-seed.enable ''
chown -R cross-seed:root "${cfg.transmission.privateTrackers.cross-seed.stateDir}"
find "${cfg.transmission.privateTrackers.cross-seed.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'' + strings.optionalString cfg.prowlarr.enable ''
chown -R prowlarr:root "${cfg.prowlarr.stateDir}"
find "${cfg.prowlarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'' + strings.optionalString cfg.sonarr.enable ''
chown -R sonarr:root "${cfg.sonarr.stateDir}"
find "${cfg.sonarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'' + strings.optionalString cfg.radarr.enable ''
chown -R radarr:root "${cfg.radarr.stateDir}"
find "${cfg.radarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'' + strings.optionalString cfg.lidarr.enable ''
chown -R lidarr:root "${cfg.lidarr.stateDir}"
find "${cfg.lidarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'' + strings.optionalString cfg.bazarr.enable ''
chown -R bazarr:root "${cfg.bazarr.stateDir}"
find "${cfg.bazarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'' + strings.optionalString cfg.readarr.enable ''
chown -R readarr:root "${cfg.readarr.stateDir}"
find "${cfg.readarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'';
text =
''
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
find "${cfg.mediaDir}" \( -type d -exec chmod 0775 {} + -true \) -o \( -exec chmod 0664 {} + \)
''
+ strings.optionalString cfg.jellyfin.enable ''
chown -R streamer:media "${cfg.mediaDir}/library"
chown -R streamer:root "${cfg.jellyfin.stateDir}"
find "${cfg.jellyfin.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
''
+ strings.optionalString cfg.transmission.enable ''
chown -R torrenter:media "${cfg.mediaDir}/torrents"
chown -R torrenter:cross-seed "${cfg.transmission.stateDir}"
find "${cfg.transmission.stateDir}" \( -type d -exec chmod 0750 {} + -true \) -o \( -exec chmod 0640 {} + \)
''
+ strings.optionalString cfg.sabnzbd.enable ''
chown -R usenet:media "${cfg.mediaDir}/usenet"
chown -R usenet:root "${cfg.sabnzbd.stateDir}"
find "${cfg.sabnzbd.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
''
+ strings.optionalString cfg.transmission.privateTrackers.cross-seed.enable ''
chown -R cross-seed:root "${cfg.transmission.privateTrackers.cross-seed.stateDir}"
find "${cfg.transmission.privateTrackers.cross-seed.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
''
+ strings.optionalString cfg.prowlarr.enable ''
chown -R prowlarr:root "${cfg.prowlarr.stateDir}"
find "${cfg.prowlarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
''
+ strings.optionalString cfg.sonarr.enable ''
chown -R sonarr:root "${cfg.sonarr.stateDir}"
find "${cfg.sonarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
''
+ strings.optionalString cfg.radarr.enable ''
chown -R radarr:root "${cfg.radarr.stateDir}"
find "${cfg.radarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
''
+ strings.optionalString cfg.lidarr.enable ''
chown -R lidarr:root "${cfg.lidarr.stateDir}"
find "${cfg.lidarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
''
+ strings.optionalString cfg.bazarr.enable ''
chown -R bazarr:root "${cfg.bazarr.stateDir}"
find "${cfg.bazarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
''
+ strings.optionalString cfg.readarr.enable ''
chown -R readarr:root "${cfg.readarr.stateDir}"
find "${cfg.readarr.stateDir}" \( -type d -exec chmod 0700 {} + -true \) -o \( -exec chmod 0600 {} + \)
'';
};
in {
imports = [
Expand Down Expand Up @@ -135,11 +146,11 @@ in {
> **Warning:** Setting this to any path, where the subpath is not
> owned by root, will fail! For example:
>
>
> ```nix
> mediaDir = /home/user/nixarr
> ```
>
>
> Is not supported, because `/home/user` is owned by `user`.
'';
};
Expand All @@ -153,11 +164,11 @@ in {
> **Warning:** Setting this to any path, where the subpath is not
> owned by root, will fail! For example:
>
>
> ```nix
> stateDir = /home/user/nixarr/.state
> ```
>
>
> Is not supported, because `/home/user` is owned by `user`.
'';
};
Expand Down
6 changes: 3 additions & 3 deletions nixarr/jellyfin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in
'';
};

package = mkPackageOption pkgs "jellyfin" { };
package = mkPackageOption pkgs "jellyfin" {};

stateDir = mkOption {
type = types.path;
Expand All @@ -33,11 +33,11 @@ in
> **Warning:** Setting this to any path, where the subpath is not
> owned by root, will fail! For example:
>
>
> ```nix
> stateDir = /home/user/nixarr/.state/jellyfin
> ```
>
>
> Is not supported, because `/home/user` is owned by `user`.
'';
};
Expand Down
2 changes: 1 addition & 1 deletion nixarr/lidarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in {
'';
};

package = mkPackageOption pkgs "lidarr" { };
package = mkPackageOption pkgs "lidarr" {};

stateDir = mkOption {
type = types.path;
Expand Down
6 changes: 3 additions & 3 deletions nixarr/prowlarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ in {
'';
};

package = mkPackageOption pkgs "prowlarr" { };
package = mkPackageOption pkgs "prowlarr" {};

stateDir = mkOption {
type = types.path;
Expand All @@ -37,11 +37,11 @@ in {
> **Warning:** Setting this to any path, where the subpath is not
> owned by root, will fail! For example:
>
>
> ```nix
> stateDir = /home/user/nixarr/.state/prowlarr
> ```
>
>
> Is not supported, because `/home/user` is owned by `user`.
'';
};
Expand Down
6 changes: 3 additions & 3 deletions nixarr/radarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in {
'';
};

package = mkPackageOption pkgs "radarr" { };
package = mkPackageOption pkgs "radarr" {};

stateDir = mkOption {
type = types.path;
Expand All @@ -33,11 +33,11 @@ in {
> **Warning:** Setting this to any path, where the subpath is not
> owned by root, will fail! For example:
>
>
> ```nix
> stateDir = /home/user/nixarr/.state/radarr
> ```
>
>
> Is not supported, because `/home/user` is owned by `user`.
'';
};
Expand Down
6 changes: 3 additions & 3 deletions nixarr/readarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in {
'';
};

package = mkPackageOption pkgs "readarr" { };
package = mkPackageOption pkgs "readarr" {};

stateDir = mkOption {
type = types.path;
Expand All @@ -33,11 +33,11 @@ in {
> **Warning:** Setting this to any path, where the subpath is not
> owned by root, will fail! For example:
>
>
> ```nix
> stateDir = /home/user/nixarr/.state/readarr
> ```
>
>
> Is not supported, because `/home/user` is owned by `user`.
'';
};
Expand Down
Loading

0 comments on commit c6a6d0f

Please sign in to comment.