summaryrefslogtreecommitdiffstats
path: root/makefu/3modules
diff options
context:
space:
mode:
authorjeschli <jeschli@gmail.com>2018-10-26 12:25:40 +0200
committerjeschli <jeschli@gmail.com>2018-10-26 12:25:40 +0200
commita6670e5090dd71aacd7c7605b12d8d3410d25daa (patch)
tree8475a3cc3583d94959a1cc8b6effcd3b8c10a32a /makefu/3modules
parentf6ad60a0c6cbac45e8ba715b24a7a37f8e2560dc (diff)
parent24f4e8dcf0eca55378fa018a9ed980625222653d (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'makefu/3modules')
-rw-r--r--makefu/3modules/airdcpp.nix210
-rw-r--r--makefu/3modules/default.nix4
-rw-r--r--makefu/3modules/state.nix7
3 files changed, 9 insertions, 212 deletions
diff --git a/makefu/3modules/airdcpp.nix b/makefu/3modules/airdcpp.nix
deleted file mode 100644
index 5250ee67a..000000000
--- a/makefu/3modules/airdcpp.nix
+++ /dev/null
@@ -1,210 +0,0 @@
-{ config, lib, pkgs, ... }:
-with import <stockholm/lib>; #genid
-let
- cfg = config.makefu.airdcpp;
-
- out = {
- options.makefu.airdcpp = api;
- config = lib.mkIf cfg.enable imp;
- };
-
- api = with types;{
- enable = mkEnableOption "airdcpp";
-
- package = mkOption {
- type = package;
- default = pkgs.airdcpp-webclient;
- };
-
- user = mkOption {
- description = ''
- user which will run udpt. if kept default a new user will be created
- '';
- type = str;
- default = "airdcpp";
- };
- extraGroups = mkOption {
- description = ''extra groups for the user (only for default user)'';
- type = listOf str;
- default = [];
- example = [ "nginx" ];
- };
-
- stateDir = mkOption {
- description = ''
- directory for storing state (pid,config)
- '';
- type = str;
- default = "/var/lib/airdcpp";
- };
- dcpp = {
- Nick = mkOption {
- description = ''
- Nick Name for connection
- '';
- type = str;
- default = "kevin";
- };
- InPort = mkOption {
- description = "Input Port";
- type = int;
- default = 16849;
- };
- UDPPort = mkOption {
- description = "UDP open Port";
- type = int;
- default = 16849;
- };
- TLSPort = mkOption {
- description = "TLS open Port";
- type = int;
- default = 16869;
- };
- DownloadSpeed = mkOption {
- description = "Total Download Speed in Mbps/s";
- type = str;
- default = "100";
- };
- UploadSpeed = mkOption {
- description = "Total Upload Speed in Mbp/s";
- type = str;
- default = "100";
- };
- shares = mkOption {
- default = {};
- type = attrsOf (submodule ( { config, ... }: {
- options = {
- path = mkOption {
- description = "path to the share";
- type = str;
- };
- incoming = mkOption {
- description = "incoming";
- type = bool;
- default = false;
- };
- };
- }));
- };
- initialConfigFile = mkOption {
- description = ''
- path inital DCPlusPlus.xml configuration if none exists
- '';
- type = nullOr path;
- default = null;
- };
- };
- web = {
- port = mkOption {
- description = ''web-ui port
-
- NOTE: once the initial config had been written to the state directory it will not be replaced
- '';
- type = int;
- default = 5600;
- };
- initialConfigFile = mkOption {
- description = ''
- path inital WebServer.xml configuration if none exists
- '';
- type = nullOr path;
- default = null;
- };
- # TODO: tlsPort
- users = mkOption {
- type = attrsOf (submodule ( { config, ... }: {
- options = {
- password = mkOption {
- description = "password of user";
- type = str;
- };
- permissions = mkOption {
- description = "user permissions";
- type = str;
- default = "admin";
- };
- };
- }));
- };
- };
- };
-
- imp = let
- genUsers = users: concatMapStringsSep "\n" (user:
- ''<WebUser Username="${user.name}" Password="${user.password}" LastLogin="0" Permissions="${user.permissions}"/>'' )
- (mapAttrsToList (name: val: val // { inherit name; }) users);
- genShares = shares: concatMapStringsSep "\n" (share:
- ''<Directory Virtual="stockholm" Incoming="${
- if share.incoming then "1" else "0"
- }" LastRefreshTime="0">${share.path}</Directory>'' )
- (mapAttrsToList (name: val: val // { inherit name; }) shares);
- webConfigFile = if (cfg.web.initialConfigFile == null) then builtins.trace "warning: airdcpp passwords are stored in plain text" pkgs.writeText "initial-config" ''
- <?xml version="1.0" encoding="utf-8" standalone="yes"?>
- <WebServer>
- <Config>
- <Server Port="${toString cfg.web.port}"/>
- <TLSServer Port="0" Certificate="" CertificateKey=""/>
- </Config>
- <WebUsers>${genUsers cfg.web.users}
- </WebUsers>
- </WebServer>
- '' else cfg.web.initialConfigFile;
- dcppConfigFile = if (cfg.dcpp.initialConfigFile == null) then pkgs.writeText "initial-config" ''
- <?xml version="1.0" encoding="utf-8" standalone="yes"?>
- <DCPlusPlus>
- <Settings>
- <Nick type="string">${cfg.dcpp.Nick}</Nick>
- <ConfigVersion type="string">${cfg.package.version}</ConfigVersion>
- <InPort type="int">${toString cfg.dcpp.InPort}</InPort>
- <UDPPort type="int">${toString cfg.dcpp.UDPPort}</UDPPort>
- <TLSPort type="int">${toString cfg.dcpp.TLSPort}</TLSPort>
- <ConfigBuildNumber type="int">0</ConfigBuildNumber>
- <AutoDetectIncomingConnection type="int">0</AutoDetectIncomingConnection>
- <NoIpOverride type="int">1</NoIpOverride>
- <WizardRunNew type="int">0</WizardRunNew>
- <IPUpdate type="int">0</IPUpdate>
- <AlwaysCCPM type="int">1</AlwaysCCPM>
- <DownloadSpeed type="string">${cfg.dcpp.DownloadSpeed}</DownloadSpeed>
- <UploadSpeed type="string">${cfg.dcpp.UploadSpeed}</UploadSpeed>
- </Settings>
- <Share Token="0" Name="Default">
- ${genShares cfg.dcpp.shares}
- <NoShare/>
- </Share>
- <ChatFilterItems/>
- </DCPlusPlus>
- '' else cfg.dcpp.initialConfigFile;
- in {
- systemd.services.airdcpp = {
- description = "airdcpp webui";
- after = [ "network.target" ];
- wantedBy = [ "multi-user.target" ];
- restartIfChanged = true;
- serviceConfig = {
- Type = "simple";
- ExecStartPre = pkgs.writeDash "prepare-env" ''
- d=${cfg.stateDir}/WebServer.xml
- test -e $d || install -m700 -o${cfg.user} ${webConfigFile} $d
- d=${cfg.stateDir}/DCPlusPlus.xml
- test -e $d || install -m700 -o${cfg.user} ${dcppConfigFile} $d
- '';
- PermissionsStartOnly = true;
- ExecStart = "${cfg.package}/bin/airdcppd -c=${cfg.stateDir} -p=${cfg.stateDir}/airdcpp.pid";
- PrivateTmp = true;
- WorkingDirectory = cfg.stateDir;
- User = "${cfg.user}";
- };
- };
- users = lib.mkIf (cfg.user == "airdcpp") {
- users.airdcpp = {
- uid = genid "airdcpp";
- home = cfg.stateDir;
- createHome = true;
- inherit (cfg) extraGroups;
- };
- groups.airdcpp.gid = genid "airdcpp";
- };
- };
-in
-out
-
diff --git a/makefu/3modules/default.nix b/makefu/3modules/default.nix
index f06ce3d53..7146174fb 100644
--- a/makefu/3modules/default.nix
+++ b/makefu/3modules/default.nix
@@ -2,17 +2,17 @@ _:
{
imports = [
- ./state.nix
- ./populate.nix
./awesome-extra.nix
./deluge.nix
./forward-journal.nix
./opentracker.nix
./ps3netsrv.nix
./logging-config.nix
+ ./populate.nix
./sane-extra.nix
./server-config.nix
./snapraid.nix
+ ./state.nix
./torrent.nix
./udpt.nix
];
diff --git a/makefu/3modules/state.nix b/makefu/3modules/state.nix
index 461b90152..a87f438fe 100644
--- a/makefu/3modules/state.nix
+++ b/makefu/3modules/state.nix
@@ -6,4 +6,11 @@
description = "state which is currently scattered on the machine";
default = [];
};
+
+ config.system.activationScripts.state = lib.optionalString (config.state != []) ''
+ cat << EOF
+ This machine is burdened with state:
+ ${lib.concatMapStringsSep "\n" (d: "* ${d}") config.state}
+ EOF
+ '';
}