mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRev57b193d8dd
result/bin/apply-formatting $NIXPKGS_PATH
104 lines
2.3 KiB
Nix
104 lines
2.3 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 "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} = optionalAttrs (cfg.user == "zerobin") {
|
|
isSystemUser = true;
|
|
group = cfg.group;
|
|
home = cfg.dataDir;
|
|
createHome = true;
|
|
};
|
|
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}
|
|
'';
|
|
};
|
|
};
|
|
}
|