mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 07:23:20 +00:00
nixos/services.chisel-server: remove with lib;
This commit is contained in:
parent
87c989da08
commit
f6077c6bcd
@ -1,69 +1,66 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.chisel-server;
|
cfg = config.services.chisel-server;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
services.chisel-server = {
|
services.chisel-server = {
|
||||||
enable = mkEnableOption "Chisel Tunnel Server";
|
enable = lib.mkEnableOption "Chisel Tunnel Server";
|
||||||
host = mkOption {
|
host = lib.mkOption {
|
||||||
description = "Address to listen on, falls back to 0.0.0.0";
|
description = "Address to listen on, falls back to 0.0.0.0";
|
||||||
type = with types; nullOr str;
|
type = with lib.types; nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
example = "[::1]";
|
example = "[::1]";
|
||||||
};
|
};
|
||||||
port = mkOption {
|
port = lib.mkOption {
|
||||||
description = "Port to listen on, falls back to 8080";
|
description = "Port to listen on, falls back to 8080";
|
||||||
type = with types; nullOr port;
|
type = with lib.types; nullOr port;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
authfile = mkOption {
|
authfile = lib.mkOption {
|
||||||
description = "Path to auth.json file";
|
description = "Path to auth.json file";
|
||||||
type = with types; nullOr path;
|
type = with lib.types; nullOr path;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
keepalive = mkOption {
|
keepalive = lib.mkOption {
|
||||||
description = "Keepalive interval, falls back to 25s";
|
description = "Keepalive interval, falls back to 25s";
|
||||||
type = with types; nullOr str;
|
type = with lib.types; nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
example = "5s";
|
example = "5s";
|
||||||
};
|
};
|
||||||
backend = mkOption {
|
backend = lib.mkOption {
|
||||||
description = "HTTP server to proxy normal requests to";
|
description = "HTTP server to proxy normal requests to";
|
||||||
type = with types; nullOr str;
|
type = with lib.types; nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
example = "http://127.0.0.1:8888";
|
example = "http://127.0.0.1:8888";
|
||||||
};
|
};
|
||||||
socks5 = mkOption {
|
socks5 = lib.mkOption {
|
||||||
description = "Allow clients access to internal SOCKS5 proxy";
|
description = "Allow clients access to internal SOCKS5 proxy";
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
reverse = mkOption {
|
reverse = lib.mkOption {
|
||||||
description = "Allow clients reverse port forwarding";
|
description = "Allow clients reverse port forwarding";
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.services.chisel-server = {
|
systemd.services.chisel-server = {
|
||||||
description = "Chisel Tunnel Server";
|
description = "Chisel Tunnel Server";
|
||||||
wantedBy = [ "network-online.target" ];
|
wantedBy = [ "network-online.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${pkgs.chisel}/bin/chisel server " + concatStringsSep " " (
|
ExecStart = "${pkgs.chisel}/bin/chisel server " + lib.concatStringsSep " " (
|
||||||
optional (cfg.host != null) "--host ${cfg.host}"
|
lib.optional (cfg.host != null) "--host ${cfg.host}"
|
||||||
++ optional (cfg.port != null) "--port ${builtins.toString cfg.port}"
|
++ lib.optional (cfg.port != null) "--port ${builtins.toString cfg.port}"
|
||||||
++ optional (cfg.authfile != null) "--authfile ${cfg.authfile}"
|
++ lib.optional (cfg.authfile != null) "--authfile ${cfg.authfile}"
|
||||||
++ optional (cfg.keepalive != null) "--keepalive ${cfg.keepalive}"
|
++ lib.optional (cfg.keepalive != null) "--keepalive ${cfg.keepalive}"
|
||||||
++ optional (cfg.backend != null) "--backend ${cfg.backend}"
|
++ lib.optional (cfg.backend != null) "--backend ${cfg.backend}"
|
||||||
++ optional cfg.socks5 "--socks5"
|
++ lib.optional cfg.socks5 "--socks5"
|
||||||
++ optional cfg.reverse "--reverse"
|
++ lib.optional cfg.reverse "--reverse"
|
||||||
);
|
);
|
||||||
|
|
||||||
# Security Hardening
|
# Security Hardening
|
||||||
@ -95,5 +92,5 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
meta.maintainers = with maintainers; [ clerie ];
|
meta.maintainers = with lib.maintainers; [ clerie ];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user