nixos/cgit: add package option

schnusch 45f06d97 218c7795

Changed files
+20 -4
nixos
modules
services
networking
tests
+4 -2
nixos/modules/services/networking/cgit.nix
···
options = {
enable = mkEnableOption (mdDoc "cgit");
+
package = mkPackageOptionMD pkgs "cgit" {};
+
nginx.virtualHost = mkOption {
description = mdDoc "VirtualHost to serve cgit on, defaults to the attribute name.";
type = types.str;
···
[ "cgit.css" "cgit.png" "favicon.ico" "robots.txt" ]
(name: nameValuePair "= ${stripLocation cfg}/${name}" {
extraConfig = ''
-
alias ${pkgs.cgit}/cgit/${name};
+
alias ${cfg.package}/cgit/${name};
'';
})
) // {
···
};
"${stripLocation cfg}/" = {
fastcgiParams = {
-
SCRIPT_FILENAME = "${pkgs.cgit}/cgit/cgit.cgi";
+
SCRIPT_FILENAME = "${cfg.package}/cgit/cgit.cgi";
QUERY_STRING = "$args";
HTTP_HOST = "$server_name";
CGIT_CONFIG = mkCgitrc cfg;
+16 -2
nixos/tests/cgit.nix
···
-
import ./make-test-python.nix ({ pkgs, ...} : {
+
import ./make-test-python.nix ({ pkgs, ... }:
+
let
+
robotsTxt = pkgs.writeText "cgit-robots.txt" ''
+
User-agent: *
+
Disallow: /
+
'';
+
in {
name = "cgit";
meta = with pkgs.lib.maintainers; {
maintainers = [ schnusch ];
···
server = { ... }: {
services.cgit."localhost" = {
enable = true;
+
package = pkgs.cgit.overrideAttrs ({ postInstall, ... }: {
+
postInstall = ''
+
${postInstall}
+
cp ${robotsTxt} "$out/cgit/robots.txt"
+
'';
+
});
nginx.location = "/(c)git/";
repos = {
some-repo = {
···
server.wait_for_unit("network.target")
server.wait_for_open_port(80)
-
server.succeed("curl -fsS http://localhost/%28c%29git/robots.txt")
+
server.succeed("curl -fsS http://localhost/%28c%29git/cgit.css")
+
+
server.succeed("curl -fsS http://localhost/%28c%29git/robots.txt | diff -u - ${robotsTxt}")
server.succeed(
"curl -fsS http://localhost/%28c%29git/ | grep -F 'some-repo description'"