summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-12-01 15:34:37 -0500
committerBen Sima <ben@bsima.me>2022-12-15 12:10:33 -0500
commit06836d877192add566f1e038462c8bbd05041e1b (patch)
treeb0a73b0575253b843a11de2ce4be73d263231e96
parent3362213d8789b0aa0716f6ee8a0caa854a269571 (diff)
Update nixpkgs
-rw-r--r--Biz/Bild/Constants.nix2
-rw-r--r--Biz/Bild/Sources.json10
-rw-r--r--Biz/Cloud.nix1
-rw-r--r--Biz/Cloud/Cgit.nix132
4 files changed, 139 insertions, 6 deletions
diff --git a/Biz/Bild/Constants.nix b/Biz/Bild/Constants.nix
index 161957a..800946d 100644
--- a/Biz/Bild/Constants.nix
+++ b/Biz/Bild/Constants.nix
@@ -1,3 +1,3 @@
{
- ghcCompiler = "ghc923";
+ ghcCompiler = "ghc924";
}
diff --git a/Biz/Bild/Sources.json b/Biz/Bild/Sources.json
index 4da4f45..a63290f 100644
--- a/Biz/Bild/Sources.json
+++ b/Biz/Bild/Sources.json
@@ -86,16 +86,16 @@
"version": "master"
},
"nixpkgs": {
- "branch": "biz",
+ "branch": "master",
"description": "Nix Packages collection",
"homepage": "git://simatime.com/nixpkgs.git",
"name": "nixpkgs",
- "owner": "bsima",
+ "owner": "nixos",
"repo": "nixpkgs",
- "rev": "a876fc5e1c239764fff9ce99bd4dee53c465ace2",
- "sha256": "0n4y8acppkpdgx10mqwyrhgzqizhk7jqmzz1x2kpw9yafbh6bz0k",
+ "rev": "8890f3b893ac6fc61723c4fab26294d4040071f9",
+ "sha256": "0kdnq3xyxqg8c6i9xzxgcb1g6x7shdcihzxmbb1lcrhlpp221d2v",
"type": "tarball",
- "url": "https://github.com/bsima/nixpkgs/archive/a876fc5e1c239764fff9ce99bd4dee53c465ace2.tar.gz",
+ "url": "https://github.com/nixos/nixpkgs/archive/8890f3b893ac6fc61723c4fab26294d4040071f9.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"regex-applicative": {
diff --git a/Biz/Cloud.nix b/Biz/Cloud.nix
index 2bbae36..aaee217 100644
--- a/Biz/Cloud.nix
+++ b/Biz/Cloud.nix
@@ -9,6 +9,7 @@ bild.os {
./Users.nix
./Cloud/Chat.nix
./Cloud/Git.nix
+ ./Cloud/Cgit.nix
./Cloud/Hardware.nix
./Cloud/Mail.nix
./Cloud/Networking.nix
diff --git a/Biz/Cloud/Cgit.nix b/Biz/Cloud/Cgit.nix
new file mode 100644
index 0000000..78eda7b
--- /dev/null
+++ b/Biz/Cloud/Cgit.nix
@@ -0,0 +1,132 @@
+{ config, lib, pkgs, ... }:
+
+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);
+ generate = name: values:
+ pkgs.writeText name (lib.generators.toKeyValue { listsAsDuplicateKeys = true; } values);
+ };
+in
+{
+ options.services.nginx.virtualHosts = mkOption {
+ type = types.attrsOf (types.submodule ({ config, ... }:
+ let
+ cfg = config.cgit;
+
+ # These are the global options for this submodule, but for nicer UX they
+ # are inlined into the freeform settings. Hence they MUST NOT INTERSECT
+ # with any settings from cgitrc!
+ options = {
+ enable = mkEnableOption "cgit";
+
+ location = mkOption {
+ default = "/";
+ type = types.str;
+ description = ''
+ Location to serve cgit on.
+ '';
+ };
+ };
+
+ # Remove the global options for serialization into cgitrc
+ settings = removeAttrs cfg (attrNames options);
+ in
+ {
+ options.cgit = mkOption {
+ type = types.submodule {
+ freeformType = settingsFormat.type;
+ inherit options;
+ config = {
+ css = mkDefault "/cgit.css";
+ logo = mkDefault "/cgit.png";
+ favicon = mkDefault "/favicon.ico";
+ };
+ };
+ default = { };
+ example = literalExample ''
+ {
+ enable = true;
+ virtual-root = "/";
+ source-filter = "''${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py";
+ about-filter = "''${pkgs.cgit}/lib/cgit/filters/about-formatting.sh";
+ cache-size = 1000;
+ scan-path = "/srv/git";
+ include = [
+ (builtins.toFile "cgitrc-extra-1" '''
+ # Anything that has to be in a particular order
+ ''')
+ (builtins.toFile "cgitrc-extra-2" '''
+ # Anything that has to be in a particular order
+ ''')
+ ];
+ }
+ '';
+ description = ''
+ Verbatim contents of the cgit runtime configuration file. Documentation
+ (with cgitrc example file) is available in "man cgitrc". Or online:
+ http://git.zx2c4.com/cgit/tree/cgitrc.5.txt
+ '';
+ };
+
+ 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."@cgit" = {
+ extraConfig = ''
+ include ${pkgs.nginx}/conf/fastcgi_params;
+ 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;
+ ''
+ );
+ };
+ };
+
+ }));
+ };
+
+ 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;
+ };
+
+ meta = {
+ maintainers = with lib.maintainers; [ bsima ]; # afix-space hmenke ];
+ };
+}