0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 14:10:33 +03:00

treewide: format all inactive Nix files

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-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
This commit is contained in:
Silvan Mosberger 2024-12-10 20:26:33 +01:00
parent b32a094368
commit 4f0dadbf38
21293 changed files with 701351 additions and 428307 deletions

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.oauth2-proxy;
@ -13,71 +18,99 @@ let
resource = cfg.azure.resource;
};
github = cfg: { github = {
inherit (cfg.github) org team;
}; };
github = cfg: {
github = {
inherit (cfg.github) org team;
};
};
google = cfg: { google = with cfg.google; lib.optionalAttrs (groups != []) {
admin-email = adminEmail;
service-account = serviceAccountJSON;
group = groups;
}; };
google = cfg: {
google =
with cfg.google;
lib.optionalAttrs (groups != [ ]) {
admin-email = adminEmail;
service-account = serviceAccountJSON;
group = groups;
};
};
};
authenticatedEmailsFile = pkgs.writeText "authenticated-emails" cfg.email.addresses;
getProviderOptions = cfg: provider: providerSpecificOptions.${provider} or (_: {}) cfg;
getProviderOptions = cfg: provider: providerSpecificOptions.${provider} or (_: { }) cfg;
allConfig = with cfg; {
inherit (cfg) provider scope upstream;
approval-prompt = approvalPrompt;
basic-auth-password = basicAuthPassword;
client-id = clientID;
client-secret = clientSecret;
custom-templates-dir = customTemplatesDir;
email-domain = email.domains;
http-address = httpAddress;
login-url = loginURL;
pass-access-token = passAccessToken;
pass-basic-auth = passBasicAuth;
pass-host-header = passHostHeader;
reverse-proxy = reverseProxy;
proxy-prefix = proxyPrefix;
profile-url = profileURL;
oidc-issuer-url = oidcIssuerUrl;
redeem-url = redeemURL;
redirect-url = redirectURL;
request-logging = requestLogging;
skip-auth-regex = skipAuthRegexes;
signature-key = signatureKey;
validate-url = validateURL;
htpasswd-file = htpasswd.file;
cookie = {
inherit (cookie) domain secure expire name secret refresh;
httponly = cookie.httpOnly;
};
set-xauthrequest = setXauthrequest;
} // lib.optionalAttrs (cfg.email.addresses != null) {
authenticated-emails-file = authenticatedEmailsFile;
} // lib.optionalAttrs (cfg.passBasicAuth) {
basic-auth-password = cfg.basicAuthPassword;
} // lib.optionalAttrs (cfg.htpasswd.file != null) {
display-htpasswd-form = cfg.htpasswd.displayForm;
} // lib.optionalAttrs tls.enable {
tls-cert-file = tls.certificate;
tls-key-file = tls.key;
https-address = tls.httpsAddress;
} // (getProviderOptions cfg cfg.provider) // cfg.extraConfig;
allConfig =
with cfg;
{
inherit (cfg) provider scope upstream;
approval-prompt = approvalPrompt;
basic-auth-password = basicAuthPassword;
client-id = clientID;
client-secret = clientSecret;
custom-templates-dir = customTemplatesDir;
email-domain = email.domains;
http-address = httpAddress;
login-url = loginURL;
pass-access-token = passAccessToken;
pass-basic-auth = passBasicAuth;
pass-host-header = passHostHeader;
reverse-proxy = reverseProxy;
proxy-prefix = proxyPrefix;
profile-url = profileURL;
oidc-issuer-url = oidcIssuerUrl;
redeem-url = redeemURL;
redirect-url = redirectURL;
request-logging = requestLogging;
skip-auth-regex = skipAuthRegexes;
signature-key = signatureKey;
validate-url = validateURL;
htpasswd-file = htpasswd.file;
cookie = {
inherit (cookie)
domain
secure
expire
name
secret
refresh
;
httponly = cookie.httpOnly;
};
set-xauthrequest = setXauthrequest;
}
// lib.optionalAttrs (cfg.email.addresses != null) {
authenticated-emails-file = authenticatedEmailsFile;
}
// lib.optionalAttrs (cfg.passBasicAuth) {
basic-auth-password = cfg.basicAuthPassword;
}
// lib.optionalAttrs (cfg.htpasswd.file != null) {
display-htpasswd-form = cfg.htpasswd.displayForm;
}
// lib.optionalAttrs tls.enable {
tls-cert-file = tls.certificate;
tls-key-file = tls.key;
https-address = tls.httpsAddress;
}
// (getProviderOptions cfg cfg.provider)
// cfg.extraConfig;
mapConfig = key: attr:
lib.optionalString (attr != null && attr != []) (
if lib.isDerivation attr then mapConfig key (toString attr) else
if (builtins.typeOf attr) == "set" then lib.concatStringsSep " "
(lib.mapAttrsToList (name: value: mapConfig (key + "-" + name) value) attr) else
if (builtins.typeOf attr) == "list" then lib.concatMapStringsSep " " (mapConfig key) attr else
if (builtins.typeOf attr) == "bool" then "--${key}=${lib.boolToString attr}" else
if (builtins.typeOf attr) == "string" then "--${key}='${attr}'" else
"--${key}=${toString attr}");
mapConfig =
key: attr:
lib.optionalString (attr != null && attr != [ ]) (
if lib.isDerivation attr then
mapConfig key (toString attr)
else if (builtins.typeOf attr) == "set" then
lib.concatStringsSep " " (lib.mapAttrsToList (name: value: mapConfig (key + "-" + name) value) attr)
else if (builtins.typeOf attr) == "list" then
lib.concatMapStringsSep " " (mapConfig key) attr
else if (builtins.typeOf attr) == "bool" then
"--${key}=${lib.boolToString attr}"
else if (builtins.typeOf attr) == "string" then
"--${key}='${attr}'"
else
"--${key}=${toString attr}"
);
configString = lib.concatStringsSep " " (lib.mapAttrsToList mapConfig allConfig);
in
@ -114,7 +147,10 @@ in
};
approvalPrompt = lib.mkOption {
type = lib.types.enum ["force" "auto"];
type = lib.types.enum [
"force"
"auto"
];
default = "force";
description = ''
OAuth approval_prompt.
@ -146,19 +182,19 @@ in
};
skipAuthRegexes = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = ''
Skip authentication for requests matching any of these regular
expressions.
'';
type = lib.types.listOf lib.types.str;
default = [ ];
description = ''
Skip authentication for requests matching any of these regular
expressions.
'';
};
# XXX: Not clear whether these two options are mutually exclusive or not.
email = {
domains = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
default = [ ];
description = ''
Authenticate emails with the specified domains. Use
`*` to authenticate any email.
@ -257,7 +293,7 @@ in
groups = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
default = [ ];
description = ''
Restrict logins to members of these Google groups.
'';
@ -289,12 +325,11 @@ in
};
};
####################################################
# UPSTREAM Configuration
upstream = lib.mkOption {
type = with lib.types; coercedTo str (x: [x]) (listOf str);
default = [];
type = with lib.types; coercedTo str (x: [ x ]) (listOf str);
default = [ ];
description = ''
The http url(s) of the upstream endpoint or `file://`
paths for static files. Routing is based on the path.
@ -538,7 +573,7 @@ in
};
extraConfig = lib.mkOption {
default = {};
default = { };
type = lib.types.attrsOf lib.types.anything;
description = ''
Extra config to pass to oauth2-proxy.
@ -575,12 +610,18 @@ in
group = "oauth2-proxy";
};
users.groups.oauth2-proxy = {};
users.groups.oauth2-proxy = { };
systemd.services.oauth2-proxy =
let needsKeycloak = lib.elem cfg.provider ["keycloak" "keycloak-oidc"]
&& config.services.keycloak.enable;
in {
let
needsKeycloak =
lib.elem cfg.provider [
"keycloak"
"keycloak-oidc"
]
&& config.services.keycloak.enable;
in
{
description = "OAuth2 Proxy";
path = [ cfg.package ];
wantedBy = [ "multi-user.target" ];