mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-28 00:24:18 +00:00
ef176dcf7e
conversions were done using https://github.com/pennae/nix-doc-munge using (probably) rev f34e145 running nix-doc-munge nixos/**/*.nix nix-doc-munge --import nixos/**/*.nix the tool ensures that only changes that could affect the generated manual *but don't* are committed, other changes require manual review and are discarded.
103 lines
2.5 KiB
Nix
103 lines
2.5 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
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 (lib.mdDoc "0bin");
|
|
|
|
dataDir = mkOption {
|
|
type = types.str;
|
|
default = "/var/lib/zerobin";
|
|
description = lib.mdDoc ''
|
|
Path to the 0bin data directory
|
|
'';
|
|
};
|
|
|
|
user = mkOption {
|
|
type = types.str;
|
|
default = "zerobin";
|
|
description = lib.mdDoc ''
|
|
The user 0bin should run as
|
|
'';
|
|
};
|
|
|
|
group = mkOption {
|
|
type = types.str;
|
|
default = "zerobin";
|
|
description = lib.mdDoc ''
|
|
The group 0bin should run as
|
|
'';
|
|
};
|
|
|
|
listenPort = mkOption {
|
|
type = types.int;
|
|
default = 8000;
|
|
example = 1357;
|
|
description = lib.mdDoc ''
|
|
The port zerobin should listen on
|
|
'';
|
|
};
|
|
|
|
listenAddress = mkOption {
|
|
type = types.str;
|
|
default = "localhost";
|
|
example = "127.0.0.1";
|
|
description = lib.mdDoc ''
|
|
The address zerobin should listen to
|
|
'';
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
example = ''
|
|
MENU = (
|
|
('Home', '/'),
|
|
)
|
|
COMPRESSED_STATIC_FILE = True
|
|
'';
|
|
description = lib.mdDoc ''
|
|
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.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig.ExecStart = "${pkgs.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}
|
|
'';
|
|
};
|
|
};
|
|
}
|
|
|