nixos: add peerflix module
This commit is contained in:
parent
b90b899b0c
commit
3424ded286
@ -170,6 +170,7 @@
|
||||
scollector = 160;
|
||||
bosun = 161;
|
||||
kubernetes = 162;
|
||||
peerflix = 163;
|
||||
|
||||
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
|
||||
|
||||
|
@ -309,6 +309,7 @@
|
||||
./services/system/nscd.nix
|
||||
./services/system/uptimed.nix
|
||||
./services/torrent/deluge.nix
|
||||
./services/torrent/peerflix.nix
|
||||
./services/torrent/transmission.nix
|
||||
./services/ttys/agetty.nix
|
||||
./services/ttys/gpm.nix
|
||||
|
63
nixos/modules/services/torrent/peerflix.nix
Normal file
63
nixos/modules/services/torrent/peerflix.nix
Normal file
@ -0,0 +1,63 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.peerflix;
|
||||
|
||||
configFile = pkgs.writeText "peerflix-config.json" ''
|
||||
{
|
||||
"connections": 50,
|
||||
"tmp": "${cfg.downloadDir}"
|
||||
}
|
||||
'';
|
||||
|
||||
in {
|
||||
|
||||
###### interface
|
||||
|
||||
options.services.peerflix = {
|
||||
enable = mkOption {
|
||||
description = "Whether to enable graphite web frontend.";
|
||||
default = false;
|
||||
type = types.uniq types.bool;
|
||||
};
|
||||
|
||||
stateDir = mkOption {
|
||||
description = "Peerflix state directory.";
|
||||
default = "/var/lib/peerflix";
|
||||
type = types.path;
|
||||
};
|
||||
|
||||
downloadDir = mkOption {
|
||||
description = "Peerflix temporary download directory.";
|
||||
default = "${cfg.stateDir}/torrents";
|
||||
type = types.path;
|
||||
};
|
||||
};
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.peerflix = {
|
||||
description = "Peerflix Daemon";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-interfaces.target" ];
|
||||
environment.HOME = cfg.stateDir;
|
||||
|
||||
preStart = ''
|
||||
mkdir -p "${cfg.stateDir}"/{torrents,.config/peerflix-server}
|
||||
if [ "$(id -u)" = 0 ]; then chown -R peerflix "${cfg.stateDir}"; fi
|
||||
ln -fs "${configFile}" "${cfg.stateDir}/.config/peerflix-server/config.json"
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.nodePackages.peerflix-server}/bin/peerflix-server";
|
||||
PermissionsStartOnly = true;
|
||||
User = "peerflix";
|
||||
};
|
||||
};
|
||||
|
||||
users.extraUsers.peerflix.uid = config.ids.uids.peerflix;
|
||||
};
|
||||
}
|
21
nixos/tests/peerflix.nix
Normal file
21
nixos/tests/peerflix.nix
Normal file
@ -0,0 +1,21 @@
|
||||
# This test runs peerflix and checks if peerflix starts
|
||||
|
||||
import ./make-test.nix {
|
||||
name = "peerflix";
|
||||
|
||||
nodes = {
|
||||
peerflix =
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
services.peerflix.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
|
||||
$peerflix->waitForUnit("peerflix.service");
|
||||
$peerflix->waitUntilSucceeds("curl localhost:9000");
|
||||
'';
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user