Skip to content

Commit

Permalink
reformat crproxy.nix with new rfc style
Browse files Browse the repository at this point in the history
  • Loading branch information
senseab committed Jan 3, 2025
1 parent a9630a5 commit 2f62713
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions nixos/modules/services/networking/crproxy.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.crproxy;

Expand All @@ -13,9 +18,18 @@ let
};
useBlockIPList = (lib.length cfg.blockIPList) != 0;
inherit (lib)
mkIf mkEnableOption mkOption types concatStringsSep concatLists optionals
literalExpression mkPackageOption;
in {
mkIf
mkEnableOption
mkOption
types
concatStringsSep
concatLists
optionals
literalExpression
mkPackageOption
;
in
{
options.services.crproxy = {
enable = mkEnableOption "CRProxy, a generic Docker image proxy";

Expand All @@ -36,8 +50,7 @@ in {
true
'';
type = types.bool;
description =
"Behind the reverse proxy such as nginx or caddy, which can receive HTTP headers from fronted nginx or caddy. Enable it when enable nginx or caddy as a reverse proxy server.";
description = "Behind the reverse proxy such as nginx or caddy, which can receive HTTP headers from fronted nginx or caddy. Enable it when enable nginx or caddy as a reverse proxy server.";
};

userpass = mkOption {
Expand Down Expand Up @@ -97,15 +110,13 @@ in {
example = literalExpression ''
[ "user1:password" "user2:password" ]
'';
description =
"Users which may access the crproxy. An empty list disables simple authentication.";
description = "Users which may access the crproxy. An empty list disables simple authentication.";
};

privilegedIPList = mkOption {
default = [ ];
type = types.listOf types.str;
description =
"Privileged IP list, which can access the crproxy without limits.";
description = "Privileged IP list, which can access the crproxy without limits.";
};

extraOptions = mkOption {
Expand Down Expand Up @@ -136,12 +147,9 @@ in {
"--address=${cfg.listenAddress}"
]
(optionals cfg.behindProxy [ "--behind" ])
(optionals useAllowImageList
[ "--allow-image-list-from-file=${allowImageListFile}" ])
(optionals useAllowImageList
[ "--block-message=${cfg.blockMessage}" ])
(optionals useBlockIPList
[ "--block-ip-list-from-file=${blockIPListFile}" ])
(optionals useAllowImageList [ "--allow-image-list-from-file=${allowImageListFile}" ])
(optionals useAllowImageList [ "--block-message=${cfg.blockMessage}" ])
(optionals useBlockIPList [ "--block-ip-list-from-file=${blockIPListFile}" ])
(optionals (cfg.simpleAuthUser != [ ]) [ "--simple-auth" ])
(map (e: "--simple-auth-user=${e}") cfg.simpleAuthUser)
(map (e: "--allow-host-list=${e}") cfg.allowHostList)
Expand Down

0 comments on commit 2f62713

Please sign in to comment.