summaryrefslogtreecommitdiff
path: root/Biz/Cloud/Cgit.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-04-01 13:30:45 -0400
committerBen Sima <ben@bsima.me>2024-04-01 13:30:45 -0400
commitdb373a8c727cad91d375b40a6c70b11ed73bdafb (patch)
treea7ed24e98242b6e38f44cb0c9884718d248cc613 /Biz/Cloud/Cgit.nix
parent5c8ef1bf4dff4fc7c6e66a57673a81477bcc850a (diff)
Add nixfmt to Lint.hs
nixfmt is the soon-to-be official formatter for Nix code, as per the NixOS GitHub group. So I figure I should just adopt it without worrying too much about the specifics of the formatting. I just formatted everything in one go, hence the huge diff, oh well.
Diffstat (limited to 'Biz/Cloud/Cgit.nix')
-rw-r--r--Biz/Cloud/Cgit.nix85
1 files changed, 37 insertions, 48 deletions
diff --git a/Biz/Cloud/Cgit.nix b/Biz/Cloud/Cgit.nix
index 0b3a71b..23fa00f 100644
--- a/Biz/Cloud/Cgit.nix
+++ b/Biz/Cloud/Cgit.nix
@@ -4,20 +4,21 @@ with lib;
let
globalConfig = config;
settingsFormat = {
- type = with lib.types; let
- value = oneOf [ int str ] // {
- description = "INI-like atom (int or string)";
- };
- values = coercedTo value lib.singleton (listOf value) // {
- description = value.description + " or a list of them for duplicate keys";
- };
- in
- attrsOf (values);
+ type = with lib.types;
+ let
+ value = oneOf [ int str ] // {
+ description = "INI-like atom (int or string)";
+ };
+ values = coercedTo value lib.singleton (listOf value) // {
+ description = value.description
+ + " or a list of them for duplicate keys";
+ };
+ in attrsOf (values);
generate = name: values:
- pkgs.writeText name (lib.generators.toKeyValue { listsAsDuplicateKeys = true; } values);
+ pkgs.writeText name
+ (lib.generators.toKeyValue { listsAsDuplicateKeys = true; } values);
};
-in
-{
+in {
options.services.nginx.virtualHosts = mkOption {
type = types.attrsOf (types.submodule ({ config, ... }:
let
@@ -48,8 +49,7 @@ in
# Remove the global options for serialization into cgitrc
settings = removeAttrs cfg (attrNames options);
- in
- {
+ in {
options.cgit = mkOption {
type = types.submodule {
freeformType = settingsFormat.type;
@@ -86,60 +86,49 @@ in
'';
};
- config = let
- location = removeSuffix "/" cfg.location;
+ config = let location = removeSuffix "/" cfg.location;
in mkIf cfg.enable {
locations."${location}/" = {
root = "${pkgs.cgit}/cgit/";
tryFiles = "$uri @cgit";
};
- locations."~ ^${location}/(cgit.(css|png)|favicon.ico|robots.txt)$" = {
- alias = "${pkgs.cgit}/cgit/$1";
- };
+ locations."~ ^${location}/(cgit.(css|png)|favicon.ico|robots.txt)$" =
+ {
+ alias = "${pkgs.cgit}/cgit/$1";
+ };
locations."@cgit" = {
extraConfig = ''
include ${pkgs.nginx}/conf/fastcgi_params;
- fastcgi_param CGIT_CONFIG ${settingsFormat.generate "cgitrc" settings};
+ fastcgi_param CGIT_CONFIG ${
+ settingsFormat.generate "cgitrc" settings
+ };
fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
fastcgi_param QUERY_STRING $args;
fastcgi_param HTTP_HOST $server_name;
fastcgi_pass unix:${globalConfig.services.fcgiwrap.socketAddress};
- '' + (
- if cfg.location == "/"
- then
- ''
- fastcgi_param PATH_INFO $uri;
- ''
- else
- ''
- fastcgi_split_path_info ^(${location}/)(/?.+)$;
- fastcgi_param PATH_INFO $fastcgi_path_info;
- ''
- ) + (
- if !cfg.allowCrawlers
- then
- ''
- add_header X-Robots-Tag "noindex, follow" always;
- ''
- else ""
- );
+ '' + (if cfg.location == "/" then ''
+ fastcgi_param PATH_INFO $uri;
+ '' else ''
+ fastcgi_split_path_info ^(${location}/)(/?.+)$;
+ fastcgi_param PATH_INFO $fastcgi_path_info;
+ '') + (if !cfg.allowCrawlers then ''
+ add_header X-Robots-Tag "noindex, follow" always;
+ '' else
+ "");
};
};
}));
};
- config =
- let
- vhosts = config.services.nginx.virtualHosts;
- in
- mkIf (any (name: vhosts.${name}.cgit.enable) (attrNames vhosts)) {
- # make the cgitrc manpage available
- environment.systemPackages = [ pkgs.cgit ];
+ config = let vhosts = config.services.nginx.virtualHosts;
+ in mkIf (any (name: vhosts.${name}.cgit.enable) (attrNames vhosts)) {
+ # make the cgitrc manpage available
+ environment.systemPackages = [ pkgs.cgit ];
- services.fcgiwrap.enable = true;
- };
+ services.fcgiwrap.enable = true;
+ };
meta = {
maintainers = with lib.maintainers; [ bsima ]; # afix-space hmenke ];