about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/networking/zerobin.nix102
-rw-r--r--pkgs/top-level/python-packages.nix100
3 files changed, 203 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 972802b2341f..b238003dd0ca 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -401,6 +401,7 @@
   ./services/networking/wicd.nix
   ./services/networking/wpa_supplicant.nix
   ./services/networking/xinetd.nix
+  ./services/networking/zerobin.nix
   ./services/networking/zerotierone.nix
   ./services/networking/znc.nix
   ./services/printing/cupsd.nix
diff --git a/nixos/modules/services/networking/zerobin.nix b/nixos/modules/services/networking/zerobin.nix
new file mode 100644
index 000000000000..1c524602f8e9
--- /dev/null
+++ b/nixos/modules/services/networking/zerobin.nix
@@ -0,0 +1,102 @@
+{ config, pkgs, lib, nodes, ... }:
+with lib;
+let
+  cfg = config.services.zerobin;
+
+  zerobin_config = pkgs.writeText "zerobin-config.py" ''
+  PASTE_FILES_ROOT = "${cfg.dataDir}"
+  ${cfg.extraConfig}
+  '';
+
+in
+  {
+    options = {
+      services.zerobin = {
+        enable = mkEnableOption "0bin";
+
+        dataDir = mkOption {
+          type = types.str;
+          default = "/var/lib/zerobin";
+          description = ''
+          Path to the 0bin data directory
+          '';
+        };
+
+        user = mkOption {
+          type = types.str;
+          default = "zerobin";
+          description = ''
+          The user 0bin should run as
+          '';
+        };
+
+        group = mkOption {
+          type = types.str;
+          default = "zerobin";
+          description = ''
+          The group 0bin should run as
+          '';
+        };
+
+        listenPort = mkOption {
+          type = types.int;
+          default = 8000;
+          example = 1357;
+          description = ''
+          The port zerobin should listen on
+          '';
+        };
+
+        listenAddress = mkOption {
+          type = types.str;
+          default = "localhost";
+          example = "127.0.0.1";
+          description = ''
+          The address zerobin should listen to
+          '';
+        };
+
+        extraConfig = mkOption {
+          type = types.lines;
+          default = "";
+          example = ''
+          MENU = (
+          ('Home', '/'),
+          )
+          COMPRESSED_STATIC_FILE = True
+          '';
+          description = ''
+          Extra configuration to be appended to the 0bin config file
+          (see https://0bin.readthedocs.org/en/latest/en/options.html)
+          '';
+        };
+      };
+    };
+
+    config = mkIf (cfg.enable) {
+      users.users."${cfg.user}" =
+      if cfg.user == "zerobin" then {
+        isSystemUser = true;
+        group = cfg.group;
+        home = cfg.dataDir;
+        createHome = true;
+      }
+      else {};
+      users.groups."${cfg.group}" = {};
+
+      systemd.services.zerobin = {
+        enable = true;
+        after = [ "network-interfaces.target" ];
+        wantedBy = [ "multi-user.target" ];
+        serviceConfig.ExecStart = "${pkgs.pythonPackages.zerobin}/bin/zerobin ${cfg.listenAddress} ${toString cfg.listenPort} false ${cfg.user} ${cfg.group} ${zerobin_config}";
+        serviceConfig.PrivateTmp="yes";
+        serviceConfig.User = cfg.user;
+        serviceConfig.Group = cfg.group;
+        preStart = ''
+        mkdir -p ${cfg.dataDir}
+        chown ${cfg.user} ${cfg.dataDir}
+        '';
+      };
+    };
+  }
+
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 1232f7a58fd2..304c4932d8e8 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -26588,4 +26588,104 @@ in modules // {
       maintainers = with maintainers; [];
     };
   };
+
+  repeated_test = buildPythonPackage rec {
+    name = "repeated_test-${version}";
+    version = "0.1a3";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/r/repeated-test/${name}.tar.gz";
+      sha256 = "062syp7kl2g0x6qx3z8zb5sdycpi7qcpxp9iml2v8dqzqnij9bpg";
+    };
+
+    buildInputs = with self; [
+      unittest2
+    ];
+    propagatedBuildInputs = with self; [
+      six
+    ];
+
+    meta = {
+      description = "A quick unittest-compatible framework for repeating a test function over many fixtures";
+      homepage = "https://github.com/epsy/repeated_test";
+      license = licenses.mit;
+    };
+  };
+
+  sigtools = buildPythonPackage rec {
+    name = "sigtools-${version}";
+    version = "1.1a3";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/s/sigtools/${name}.tar.gz";
+      sha256 = "190w14vzbiyvxcl9jmyyimpahar5b0bq69v9iv7chi852yi71w6w";
+    };
+
+    buildInputs = with self; [
+      repeated_test
+      sphinx
+      mock
+      coverage
+      unittest2
+    ];
+    propagatedBuildInputs = with self; [
+      funcsigs
+      six
+    ];
+
+    patchPhase = ''sed -i s/test_suite="'"sigtools.tests"'"/test_suite="'"unittest2.collector"'"/ setup.py'';
+
+    meta = {
+      description = "Utilities for working with 3.3's inspect.Signature objects.";
+      homepage = "https://pypi.python.org/pypi/sigtools";
+      license = licenses.mit;
+    };
+  };
+
+  clize = buildPythonPackage rec {
+    name = "clize-${version}";
+    version = "3.0";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/c/clize/${name}.tar.gz";
+      sha256 = "1xkr3h404d7pgj5gdpg6bddv3v3yq2hgx8qlwkgw5abg218k53hm";
+    };
+
+    buildInputs = with self; [
+      dateutil
+    ];
+    propagatedBuildInputs = with self; [
+      sigtools
+    ];
+
+    meta = {
+      description = "Command-line argument parsing for Python";
+      homepage = "https://github.com/epsy/clize";
+      license = licenses.mit;
+    };
+  };
+
+  zerobin = buildPythonPackage rec {
+    name = "zerobin-${version}";
+    version = "20160108";
+
+    src = pkgs.fetchFromGitHub {
+      owner = "sametmax";
+      repo = "0bin";
+      rev = "7da1615";
+      sha256 = "1pzcwy454kn5216pvwjqzz311s6jbh7viw9s6kw4xps6f5h44bid";
+    };
+
+    propagatedBuildInputs = with self; [
+      cherrypy
+      bottle
+      lockfile
+      clize
+    ];
+    meta = {
+      description = "A client side encrypted pastebin";
+      homepage = "http://0bin.net/";
+      license = licenses.wtfpl;
+    };
+  };
 }