mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
nixos/cgit: handle list setting type
The cgitrc file allows list of values to be set for some keys as multiple definition lines. This allows setting multiple "css" files to include or multiple "readme" branch and file lookup paths to be set.
This commit is contained in:
parent
7f907528a8
commit
1768115589
@ -6,6 +6,7 @@ let
|
||||
cfgs = config.services.cgit;
|
||||
|
||||
settingType = with types; oneOf [ bool int str ];
|
||||
repeatedSettingType = with types; oneOf [ settingType (listOf settingType) ];
|
||||
|
||||
genAttrs' = names: f: listToAttrs (map f names);
|
||||
|
||||
@ -44,12 +45,20 @@ let
|
||||
toString value
|
||||
}";
|
||||
|
||||
# list value as multiple lines (for "readme" for example)
|
||||
cgitrcEntry = name: value:
|
||||
if isList value then
|
||||
map (cgitrcLine name) value
|
||||
else
|
||||
[ (cgitrcLine name value) ];
|
||||
|
||||
mkCgitrc = cfg: pkgs.writeText "cgitrc" ''
|
||||
# global settings
|
||||
${concatStringsSep "\n" (
|
||||
mapAttrsToList
|
||||
cgitrcLine
|
||||
flatten (mapAttrsToList
|
||||
cgitrcEntry
|
||||
({ virtual-root = cfg.nginx.location; } // cfg.settings)
|
||||
)
|
||||
)
|
||||
}
|
||||
${optionalString (cfg.scanPath != null) (cgitrcLine "scan-path" cfg.scanPath)}
|
||||
@ -125,7 +134,7 @@ in
|
||||
|
||||
settings = mkOption {
|
||||
description = "cgit configuration, see cgitrc(5)";
|
||||
type = types.attrsOf settingType;
|
||||
type = types.attrsOf repeatedSettingType;
|
||||
default = {};
|
||||
example = literalExpression ''
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user