From 17da6487bae96d061565d95bb0da054035a416a8 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 21 May 2025 00:32:18 -0700 Subject: [PATCH 01/21] docs: use mdBook for NixOS options This is part of https://github.com/molybdenumsoftware/pr-tracker/issues/250 Co-authored-by: Shahar "Dawn" Or --- flake.nix | 2 +- modules/nixos-manual.nix | 70 +++++++++++++++++++++++++++++ modules/nixos-manual/default.nix | 76 -------------------------------- modules/nixos-manual/manual.md | 9 ---- 4 files changed, 71 insertions(+), 86 deletions(-) create mode 100644 modules/nixos-manual.nix delete mode 100644 modules/nixos-manual/default.nix delete mode 100644 modules/nixos-manual/manual.md diff --git a/flake.nix b/flake.nix index dbc1eef4..7d31c821 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,7 @@ ./modules/formatting.nix ./modules/integration-tests ./modules/nci.nix - ./modules/nixos-manual + ./modules/nixos-manual.nix ./modules/nixos-modules-lib.nix ./modules/private-nixos-modules ./modules/program-docs.nix diff --git a/modules/nixos-manual.nix b/modules/nixos-manual.nix new file mode 100644 index 00000000..58194105 --- /dev/null +++ b/modules/nixos-manual.nix @@ -0,0 +1,70 @@ +{ + lib, + self, + ... +}: +{ + perSystem = + { + self', + system, + pkgs, + ... + }: + let + filterOptions = import ../filterOptions.nix lib; + + configuration = lib.nixosSystem { + modules = [ + self.nixosModules.api + self.nixosModules.fetcher + { + nixpkgs.hostPlatform = system; + } + ]; + }; + + options = filterOptions ( + path: option: lib.any (lib.hasPrefix "${self}/") option.declarations + ) configuration.options; + + optionsDocs = pkgs.buildPackages.nixosOptionsDoc { + inherit options; + variablelistId = "options"; + transformOptions = options: builtins.removeAttrs options [ "declarations" ]; + }; + + optionsMd = + pkgs.runCommand "pr-tracker-nixos-options-html" { nativeBuildInputs = [ pkgs.nixos-render-docs ]; } + '' + nixos-render-docs options commonmark \ + --manpage-urls <(echo "{}") \ + --revision provide-because-required-but-seems-to-be-unused \ + ${optionsDocs.optionsJSON}/share/doc/nixos/options.json $out + ''; + + summaryMd = pkgs.writeTextFile { + name = "SUMMARY.md"; + text = + # markdown + '' + [Options](options.md) + ''; + }; + in + { + packages.nixos-manual = + pkgs.runCommand "pr-tracker-nixos-manual" + { + nativeBuildInputs = [ pkgs.mdbook ]; + } + '' + mkdir src + ln -s ${summaryMd} src/SUMMARY.md + ln -s ${optionsMd} src/options.md + mdbook build --dest-dir $out + ''; + + checks."packages/nixos-modules-manual" = self'.packages.nixos-manual; + }; +} diff --git a/modules/nixos-manual/default.nix b/modules/nixos-manual/default.nix deleted file mode 100644 index 51363dee..00000000 --- a/modules/nixos-manual/default.nix +++ /dev/null @@ -1,76 +0,0 @@ -# https://gitlab.com/rycee/nur-expressions/-/blob/master/doc/default.nix -{ - lib, - inputs, - self, - ... -}: -{ - perSystem = - { - self', - system, - pkgs, - ... - }: - let - inherit (lib) - any - evalModules - hasPrefix - ; - - inherit (builtins) - removeAttrs - ; - - filterOptions = import ../../filterOptions.nix lib; - - configuration = evalModules { - modules = [ - self.nixosModules.api - self.nixosModules.fetcher - { - nixpkgs.hostPlatform = system; - system.stateVersion = "24.05"; - } - ] ++ (import "${inputs.nixpkgs}/nixos/modules/module-list.nix"); - }; - - options = filterOptions ( - path: option: any (hasPrefix "${self}/") option.declarations - ) configuration.options; - - optionsDocs = pkgs.buildPackages.nixosOptionsDoc { - inherit options; - variablelistId = "options"; - transformOptions = options: removeAttrs options [ "declarations" ]; - }; - in - { - packages.nixos-manual = pkgs.stdenv.mkDerivation { - name = "pr-tracker-nixos-modules-manual"; - src = ./.; - nativeBuildInputs = [ pkgs.nixos-render-docs ]; - - buildPhase = '' - mkdir $out - - manpage_urls=$(mktemp) - echo "{}" > $manpage_urls - - substituteInPlace ./manual.md \ - --subst-var-by \ - OPTIONS_JSON \ - ${optionsDocs.optionsJSON}/share/doc/nixos/options.json - - nixos-render-docs manual html \ - --manpage-urls $manpage_urls \ - --revision provide-because-required-but-seems-to-be-unused \ - manual.md $out/index.html - ''; - }; - - checks."packages/nixos-modules-manual" = self'.packages.nixos-manual; - }; -} diff --git a/modules/nixos-manual/manual.md b/modules/nixos-manual/manual.md deleted file mode 100644 index f8f9aea6..00000000 --- a/modules/nixos-manual/manual.md +++ /dev/null @@ -1,9 +0,0 @@ -# pr-tracker NixOS modules manual {#pr-tracker-nixos-modules-manual} - -## Options - -```{=include=} options -id-prefix: opt- -list-id: pr-tracker-nixos-modules-options -source: @OPTIONS_JSON@ -``` From 0271fd295c17073911691e1fc6af5372268e2e24 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 25 May 2025 01:05:33 +0000 Subject: [PATCH 02/21] chore(flake): bump inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'github-graphql-schema': 'github:octokit/graphql-schema/3b88e02665bbf85ce462a4e8e44c9595777f4a1b?narHash=sha256-aFW52fhkF91sLbzE010/JUdyk/ZNzp4rpTHFj6yrFUo%3D' (2025-05-07) → 'github:octokit/graphql-schema/a39eba89e0056a2cd6e87ef054f9748929943aae?narHash=sha256-OsMtRMbtIA12nn1ZMoIbUKDee%2BVgptAOFgaGJe7wMUw%3D' (2025-05-20) • Updated input 'nci': 'github:yusdacra/nix-cargo-integration/f0fba443d429c90ad14fc51aa0d0bab81e83fd40?narHash=sha256-DpZzKTzrowBfpxMYAe5CsfqcN1TsRyCMaqoUpQ8BF5E%3D' (2025-05-17) → 'github:yusdacra/nix-cargo-integration/64209325f09c67cb39d1db0305bc4860734b39af?narHash=sha256-kNsEU5tM11ZAvAU6MI/oZ8unZSat2I%2BXo/ez8aK3SCQ%3D' (2025-05-24) • Updated input 'nci/dream2nix': 'github:nix-community/dream2nix/8ce6284ff58208ed8961681276f82c2f8f978ef4?narHash=sha256-n5CwhmqKxifuD4Sq4WuRP/h5LO6f23cGnSAuJemnd/4%3D' (2024-12-25) → 'github:nix-community/dream2nix/6fd6d9188f32efd1e1656b3c3e63a67f9df7b636?narHash=sha256-qZWuEdxmPx818qR61t3mMozJOvZSmTRUDPU4L3JeGgE%3D' (2025-05-19) • Updated input 'nci/rust-overlay': 'github:oxalica/rust-overlay/f44db7d7cea4528288780c6347756173a8248225?narHash=sha256-veyXchTz6eWwvuW5X49UluHkheHkFcqHJSwGuKBhrmQ%3D' (2025-05-17) → 'github:oxalica/rust-overlay/2221d8d53c128beb69346fa3ab36da3f19bb1691?narHash=sha256-rwFiLLNCwkj9bqePtH1sMqzs1xmohE0Ojq249piMzF4%3D' (2025-05-24) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/12a55407652e04dcf2309436eb06fef0d3713ef3?narHash=sha256-N4cp0asTsJCnRMFZ/k19V9akkxb7J/opG%2BK%2BjU57JGc%3D' (2025-05-16) → 'github:NixOS/nixpkgs/fe51d34885f7b5e3e7b59572796e1bcb427eccb1?narHash=sha256-qmmFCrfBwSHoWw7cVK4Aj%2Bfns%2Bc54EBP8cGqp/yK410%3D' (2025-05-22) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/ab0378b61b0d85e73a8ab05d5c6029b5bd58c9fb?narHash=sha256-bo1ptiFoNqm6m1B2iAhJmWCBmqveLVvxom6xKmtuzjg%3D' (2025-05-17) → 'github:numtide/treefmt-nix/020cb423808365fa3f10ff4cb8c0a25df35065a3?narHash=sha256-XgxghfND8TDypxsMTPU2GQdtBEsHTEc3qWE6RVEk8O0%3D' (2025-05-22) --- flake.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index 42bb845e..42b1dfaf 100644 --- a/flake.lock +++ b/flake.lock @@ -47,11 +47,11 @@ "pyproject-nix": "pyproject-nix" }, "locked": { - "lastModified": 1735160684, - "narHash": "sha256-n5CwhmqKxifuD4Sq4WuRP/h5LO6f23cGnSAuJemnd/4=", + "lastModified": 1747658429, + "narHash": "sha256-qZWuEdxmPx818qR61t3mMozJOvZSmTRUDPU4L3JeGgE=", "owner": "nix-community", "repo": "dream2nix", - "rev": "8ce6284ff58208ed8961681276f82c2f8f978ef4", + "rev": "6fd6d9188f32efd1e1656b3c3e63a67f9df7b636", "type": "github" }, "original": { @@ -137,11 +137,11 @@ "github-graphql-schema": { "flake": false, "locked": { - "lastModified": 1746607928, - "narHash": "sha256-aFW52fhkF91sLbzE010/JUdyk/ZNzp4rpTHFj6yrFUo=", + "lastModified": 1747721806, + "narHash": "sha256-OsMtRMbtIA12nn1ZMoIbUKDee+VgptAOFgaGJe7wMUw=", "owner": "octokit", "repo": "graphql-schema", - "rev": "3b88e02665bbf85ce462a4e8e44c9595777f4a1b", + "rev": "a39eba89e0056a2cd6e87ef054f9748929943aae", "type": "github" }, "original": { @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1747462581, - "narHash": "sha256-DpZzKTzrowBfpxMYAe5CsfqcN1TsRyCMaqoUpQ8BF5E=", + "lastModified": 1748067367, + "narHash": "sha256-kNsEU5tM11ZAvAU6MI/oZ8unZSat2I+Xo/ez8aK3SCQ=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "f0fba443d429c90ad14fc51aa0d0bab81e83fd40", + "rev": "64209325f09c67cb39d1db0305bc4860734b39af", "type": "github" }, "original": { @@ -219,11 +219,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1747426788, - "narHash": "sha256-N4cp0asTsJCnRMFZ/k19V9akkxb7J/opG+K+jU57JGc=", + "lastModified": 1747958103, + "narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "12a55407652e04dcf2309436eb06fef0d3713ef3", + "rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1", "type": "github" }, "original": { @@ -316,11 +316,11 @@ ] }, "locked": { - "lastModified": 1747449297, - "narHash": "sha256-veyXchTz6eWwvuW5X49UluHkheHkFcqHJSwGuKBhrmQ=", + "lastModified": 1748054080, + "narHash": "sha256-rwFiLLNCwkj9bqePtH1sMqzs1xmohE0Ojq249piMzF4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "f44db7d7cea4528288780c6347756173a8248225", + "rev": "2221d8d53c128beb69346fa3ab36da3f19bb1691", "type": "github" }, "original": { @@ -390,11 +390,11 @@ ] }, "locked": { - "lastModified": 1747469671, - "narHash": "sha256-bo1ptiFoNqm6m1B2iAhJmWCBmqveLVvxom6xKmtuzjg=", + "lastModified": 1747912973, + "narHash": "sha256-XgxghfND8TDypxsMTPU2GQdtBEsHTEc3qWE6RVEk8O0=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "ab0378b61b0d85e73a8ab05d5c6029b5bd58c9fb", + "rev": "020cb423808365fa3f10ff4cb8c0a25df35065a3", "type": "github" }, "original": { From bbd05cc54c30824663c9061aa8ddc568081e8387 Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Tue, 27 May 2025 16:04:22 +0700 Subject: [PATCH 03/21] chore(flake): inline a few nix bindings Seems easier to read --- modules/api/nixos-module.nix | 34 +++++++++++---------------- modules/fetcher/nixos-module.nix | 40 ++++++++++++++------------------ 2 files changed, 31 insertions(+), 43 deletions(-) diff --git a/modules/api/nixos-module.nix b/modules/api/nixos-module.nix index f3a47bb3..886b102e 100644 --- a/modules/api/nixos-module.nix +++ b/modules/api/nixos-module.nix @@ -71,26 +71,20 @@ ] ++ lib.optional cfg.db.isLocal "postgresql.service"; systemd.services.pr-tracker-api.bindsTo = lib.optional cfg.db.isLocal "postgresql.service"; - systemd.services.pr-tracker-api.script = - let - databaseUrl = "postgresql://?${attrsToURLParams cfg.db.urlParams}"; - - passwordFile = lib.optional (cfg.db.passwordFile != null) '' - PASSWORD=$(${lib.getExe pkgs.urlencode} --encode-set component < ${cfg.db.passwordFile}) - PR_TRACKER_API_DATABASE_URL="$PR_TRACKER_API_DATABASE_URL&password=$PASSWORD" - ''; - in - lib.concatStringsSep "\n" ( - [ - "export PR_TRACKER_API_DATABASE_URL=${lib.escapeShellArg databaseUrl}" - "export PR_TRACKER_API_PORT=${lib.escapeShellArg (toString cfg.port)}" - ] - ++ (lib.optional ( - cfg.tracingFilter != null - ) "export PR_TRACKER_TRACING_FILTER=${lib.escapeShellArg cfg.tracingFilter}") - ++ passwordFile - ++ [ "exec ${lib.getExe cfg.package}" ] - ); + systemd.services.pr-tracker-api.script = lib.concatStringsSep "\n" ( + [ + "export PR_TRACKER_API_DATABASE_URL=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" + "export PR_TRACKER_API_PORT=${lib.escapeShellArg (toString cfg.port)}" + ] + ++ (lib.optional ( + cfg.tracingFilter != null + ) "export PR_TRACKER_TRACING_FILTER=${lib.escapeShellArg cfg.tracingFilter}") + ++ lib.optional (cfg.db.passwordFile != null) '' + PASSWORD=$(${lib.getExe pkgs.urlencode} --encode-set component < ${cfg.db.passwordFile}) + PR_TRACKER_API_DATABASE_URL="$PR_TRACKER_API_DATABASE_URL&password=$PASSWORD" + '' + ++ [ "exec ${lib.getExe cfg.package}" ] + ); systemd.services.pr-tracker-api.serviceConfig.User = cfg.user; systemd.services.pr-tracker-api.serviceConfig.Group = cfg.group; systemd.services.pr-tracker-api.serviceConfig.Type = "notify"; diff --git a/modules/fetcher/nixos-module.nix b/modules/fetcher/nixos-module.nix index 6aa9c6fb..649aad01 100644 --- a/modules/fetcher/nixos-module.nix +++ b/modules/fetcher/nixos-module.nix @@ -94,29 +94,23 @@ "network.target" ] ++ lib.optional cfg.db.isLocal "postgresql.service"; systemd.services.pr-tracker-fetcher.requires = lib.optional cfg.db.isLocal "postgresql.service"; - systemd.services.pr-tracker-fetcher.script = - let - databaseUrl = "postgresql://?${attrsToURLParams cfg.db.urlParams}"; - - passwordFile = lib.optional (cfg.db.passwordFile != null) '' - PASSWORD=$(${lib.getExe pkgs.urlencode} --encode-set component < ${cfg.db.passwordFile}) - PR_TRACKER_FETCHER_DATABASE_URL="$PR_TRACKER_FETCHER_DATABASE_URL&password=$PASSWORD" - ''; - in - builtins.concatStringsSep "\n" ( - [ - "export PR_TRACKER_FETCHER_DATABASE_URL=${lib.escapeShellArg databaseUrl}" - "export PR_TRACKER_FETCHER_GITHUB_REPO_OWNER=${lib.escapeShellArg cfg.repo.owner}" - "export PR_TRACKER_FETCHER_GITHUB_REPO_NAME=${lib.escapeShellArg cfg.repo.name}" - "export PR_TRACKER_FETCHER_BRANCH_PATTERNS=${lib.escapeShellArg (builtins.toJSON cfg.branchPatterns)}" - "export PR_TRACKER_FETCHER_GITHUB_TOKEN=$(< ${cfg.githubApiTokenFile})" - # CACHE_DIRECTORY is set by systemd based on the CacheDirectory setting. - # See https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#RuntimeDirectory= - "export PR_TRACKER_FETCHER_CACHE_DIR=$CACHE_DIRECTORY" - ] - ++ passwordFile - ++ [ "exec ${lib.getExe cfg.package}" ] - ); + systemd.services.pr-tracker-fetcher.script = builtins.concatStringsSep "\n" ( + [ + "export PR_TRACKER_FETCHER_DATABASE_URL=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" + "export PR_TRACKER_FETCHER_GITHUB_REPO_OWNER=${lib.escapeShellArg cfg.repo.owner}" + "export PR_TRACKER_FETCHER_GITHUB_REPO_NAME=${lib.escapeShellArg cfg.repo.name}" + "export PR_TRACKER_FETCHER_BRANCH_PATTERNS=${lib.escapeShellArg (builtins.toJSON cfg.branchPatterns)}" + "export PR_TRACKER_FETCHER_GITHUB_TOKEN=$(< ${cfg.githubApiTokenFile})" + # CACHE_DIRECTORY is set by systemd based on the CacheDirectory setting. + # See https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#RuntimeDirectory= + "export PR_TRACKER_FETCHER_CACHE_DIR=$CACHE_DIRECTORY" + ] + ++ lib.optional (cfg.db.passwordFile != null) '' + PASSWORD=$(${lib.getExe pkgs.urlencode} --encode-set component < ${cfg.db.passwordFile}) + PR_TRACKER_FETCHER_DATABASE_URL="$PR_TRACKER_FETCHER_DATABASE_URL&password=$PASSWORD" + '' + ++ [ "exec ${lib.getExe cfg.package}" ] + ); systemd.services.pr-tracker-fetcher.serviceConfig.User = cfg.user; systemd.services.pr-tracker-fetcher.serviceConfig.Group = cfg.group; From 8f4745c7f2b5cf1a78ee4124fb978961f747405f Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Tue, 27 May 2025 16:05:51 +0700 Subject: [PATCH 04/21] chore(flake): use lib.concatLines in a couple of places --- modules/api/nixos-module.nix | 2 +- modules/fetcher/nixos-module.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/api/nixos-module.nix b/modules/api/nixos-module.nix index 886b102e..9a833cae 100644 --- a/modules/api/nixos-module.nix +++ b/modules/api/nixos-module.nix @@ -71,7 +71,7 @@ ] ++ lib.optional cfg.db.isLocal "postgresql.service"; systemd.services.pr-tracker-api.bindsTo = lib.optional cfg.db.isLocal "postgresql.service"; - systemd.services.pr-tracker-api.script = lib.concatStringsSep "\n" ( + systemd.services.pr-tracker-api.script = lib.concatLines ( [ "export PR_TRACKER_API_DATABASE_URL=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" "export PR_TRACKER_API_PORT=${lib.escapeShellArg (toString cfg.port)}" diff --git a/modules/fetcher/nixos-module.nix b/modules/fetcher/nixos-module.nix index 649aad01..012328d6 100644 --- a/modules/fetcher/nixos-module.nix +++ b/modules/fetcher/nixos-module.nix @@ -94,7 +94,7 @@ "network.target" ] ++ lib.optional cfg.db.isLocal "postgresql.service"; systemd.services.pr-tracker-fetcher.requires = lib.optional cfg.db.isLocal "postgresql.service"; - systemd.services.pr-tracker-fetcher.script = builtins.concatStringsSep "\n" ( + systemd.services.pr-tracker-fetcher.script = lib.concatLines ( [ "export PR_TRACKER_FETCHER_DATABASE_URL=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" "export PR_TRACKER_FETCHER_GITHUB_REPO_OWNER=${lib.escapeShellArg cfg.repo.owner}" From 0a05b8d3fb870cdd6c3b44f065822a7582a0d7bd Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Tue, 27 May 2025 16:56:47 +0700 Subject: [PATCH 05/21] refactor: generate Environment (configuration) structs using Nix --- crates/DATABASE_URL.md | 1 - crates/api-config/PORT.md | 1 - crates/api-config/TRACING_FILTER.md | 1 - crates/api-config/src/lib.rs | 17 +---- crates/fetcher-config/BRANCH_PATTERNS.md | 6 -- crates/fetcher-config/GITHUB_REPO_NAME.md | 1 - crates/fetcher-config/GITHUB_REPO_OWNER.md | 1 - crates/fetcher-config/GITHUB_TOKEN.md | 1 - crates/fetcher-config/src/lib.rs | 26 +------- modules/api/default.nix | 46 +++++++++++--- modules/api/nixos-module.nix | 17 ++--- modules/fetcher/default.nix | 72 +++++++++++++++++++--- modules/fetcher/nixos-module.nix | 24 ++++---- modules/nixos-modules-lib.nix | 4 +- modules/program-docs.nix | 5 +- modules/util.nix | 42 +++++++++++++ 16 files changed, 170 insertions(+), 95 deletions(-) delete mode 100644 crates/DATABASE_URL.md delete mode 100644 crates/api-config/PORT.md delete mode 100644 crates/api-config/TRACING_FILTER.md delete mode 100644 crates/fetcher-config/BRANCH_PATTERNS.md delete mode 100644 crates/fetcher-config/GITHUB_REPO_NAME.md delete mode 100644 crates/fetcher-config/GITHUB_REPO_OWNER.md delete mode 100644 crates/fetcher-config/GITHUB_TOKEN.md diff --git a/crates/DATABASE_URL.md b/crates/DATABASE_URL.md deleted file mode 100644 index d784f4c4..00000000 --- a/crates/DATABASE_URL.md +++ /dev/null @@ -1 +0,0 @@ -[PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS). diff --git a/crates/api-config/PORT.md b/crates/api-config/PORT.md deleted file mode 100644 index f96f498d..00000000 --- a/crates/api-config/PORT.md +++ /dev/null @@ -1 +0,0 @@ -Port to listen on. diff --git a/crates/api-config/TRACING_FILTER.md b/crates/api-config/TRACING_FILTER.md deleted file mode 100644 index 0ba8f0eb..00000000 --- a/crates/api-config/TRACING_FILTER.md +++ /dev/null @@ -1 +0,0 @@ -Expected to deserialize into an [`EnvFilter`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html). diff --git a/crates/api-config/src/lib.rs b/crates/api-config/src/lib.rs index 5f462697..81438113 100644 --- a/crates/api-config/src/lib.rs +++ b/crates/api-config/src/lib.rs @@ -7,22 +7,7 @@ use serde_with::serde_as; use tracing_subscriber::EnvFilter; mod environment { - use super::TracingFilter; - use confique::Config; - - /// See documentation for each field. - #[derive(Debug, Config)] - pub struct Environment { - #[doc = include_str!("../../DATABASE_URL.md")] - #[config(env = "PR_TRACKER_API_DATABASE_URL")] - pub PR_TRACKER_API_DATABASE_URL: String, - #[config(env = "PR_TRACKER_API_PORT")] - #[doc = include_str!("../PORT.md")] - pub PR_TRACKER_API_PORT: u16, - #[config(env = "PR_TRACKER_TRACING_FILTER")] - #[doc = include_str!("../TRACING_FILTER.md")] - pub PR_TRACKER_TRACING_FILTER: Option, - } + include!(env!("api_config_snippet")); } #[serde_as] diff --git a/crates/fetcher-config/BRANCH_PATTERNS.md b/crates/fetcher-config/BRANCH_PATTERNS.md deleted file mode 100644 index 36541efc..00000000 --- a/crates/fetcher-config/BRANCH_PATTERNS.md +++ /dev/null @@ -1,6 +0,0 @@ -JSON array of strings representing branch patterns to track. - -- `?` matches a single occurrence of any character. -- `*` matches zero or more occurrences of any character. - -No escape characters. diff --git a/crates/fetcher-config/GITHUB_REPO_NAME.md b/crates/fetcher-config/GITHUB_REPO_NAME.md deleted file mode 100644 index 89b6f672..00000000 --- a/crates/fetcher-config/GITHUB_REPO_NAME.md +++ /dev/null @@ -1 +0,0 @@ -GitHub repository name. diff --git a/crates/fetcher-config/GITHUB_REPO_OWNER.md b/crates/fetcher-config/GITHUB_REPO_OWNER.md deleted file mode 100644 index 7f6cf37c..00000000 --- a/crates/fetcher-config/GITHUB_REPO_OWNER.md +++ /dev/null @@ -1 +0,0 @@ -GitHub repository owner. diff --git a/crates/fetcher-config/GITHUB_TOKEN.md b/crates/fetcher-config/GITHUB_TOKEN.md deleted file mode 100644 index f9d0da10..00000000 --- a/crates/fetcher-config/GITHUB_TOKEN.md +++ /dev/null @@ -1 +0,0 @@ -GitHub API token with read access to the repository's pull requests. diff --git a/crates/fetcher-config/src/lib.rs b/crates/fetcher-config/src/lib.rs index 8bccdfcc..a9b69640 100644 --- a/crates/fetcher-config/src/lib.rs +++ b/crates/fetcher-config/src/lib.rs @@ -3,29 +3,5 @@ pub use environment::Environment; mod environment { - use camino::Utf8PathBuf; - use confique::Config; - - /// See documentation for each field. - #[derive(Debug, Config)] - pub struct Environment { - #[doc = include_str!("../../DATABASE_URL.md")] - #[config(env = "PR_TRACKER_FETCHER_DATABASE_URL")] - pub PR_TRACKER_FETCHER_DATABASE_URL: String, - #[config(env = "PR_TRACKER_FETCHER_GITHUB_TOKEN")] - #[doc = include_str!("../GITHUB_TOKEN.md")] - pub PR_TRACKER_FETCHER_GITHUB_TOKEN: String, - #[config(env = "PR_TRACKER_FETCHER_GITHUB_REPO_OWNER")] - #[doc = include_str!("../GITHUB_REPO_OWNER.md")] - pub PR_TRACKER_FETCHER_GITHUB_REPO_OWNER: String, - #[config(env = "PR_TRACKER_FETCHER_GITHUB_REPO_NAME")] - #[doc = include_str!("../GITHUB_REPO_NAME.md")] - pub PR_TRACKER_FETCHER_GITHUB_REPO_NAME: String, - /// Cache directory (for repository clone). - #[config(env = "PR_TRACKER_FETCHER_CACHE_DIR")] - pub PR_TRACKER_FETCHER_CACHE_DIR: Utf8PathBuf, - #[config(env = "PR_TRACKER_FETCHER_BRANCH_PATTERNS")] - #[doc = include_str!("../BRANCH_PATTERNS.md")] - pub PR_TRACKER_FETCHER_BRANCH_PATTERNS: String, - } + include!(env!("fetcher_config_snippet")); } diff --git a/modules/api/default.nix b/modules/api/default.nix index b269d281..c464652e 100644 --- a/modules/api/default.nix +++ b/modules/api/default.nix @@ -1,23 +1,55 @@ -{ lib, ... }: +{ + lib, + api, + psqlConnectionUriMdLink, + ... +}: { imports = [ ./nixos-module.nix ]; + _module.args.api.environmentVariables = lib.mapAttrs (name: v: v // { inherit name; }) { + PR_TRACKER_API_DATABASE_URL = { + description = # markdown + "${psqlConnectionUriMdLink}."; + rustType = "::std::string::String"; + }; + PR_TRACKER_API_PORT = { + description = + # markdown + "Port to listen on."; + rustType = "::core::primitive::u16"; + }; + PR_TRACKER_TRACING_FILTER = { + description = + # markdown + "Expected to deserialize into an [`EnvFilter`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html)."; + # Note: ideally we'd use `::core::option::Option`, but cannot because + # confique's derive macro seems not to support it. + rustType = "Option"; + }; + }; + perSystem = { self', config, + writeEnvironmentStructFile, ... }: { nci = { crates = { - pr-tracker-api.drvConfig.mkDerivation.meta.mainProgram = "pr-tracker-api"; - pr-tracker-api-config.includeInProjectDocs = true; + pr-tracker-api.drvConfig = { + mkDerivation.meta.mainProgram = "pr-tracker-api"; + env = { + inherit (config.nci.crates.pr-tracker-api-config.drvConfig.env) api_config_snippet; + }; + }; + pr-tracker-api-config = { + drvConfig.env.api_config_snippet = writeEnvironmentStructFile "api" api.environmentVariables; + includeInProjectDocs = true; + }; }; - projects.default.fileset = lib.fileset.unions [ - ../../crates/api-config/PORT.md - ../../crates/api-config/TRACING_FILTER.md - ]; }; packages.api = config.nci.outputs.pr-tracker-api.packages.release; checks = { diff --git a/modules/api/nixos-module.nix b/modules/api/nixos-module.nix index 9a833cae..2e97c0c8 100644 --- a/modules/api/nixos-module.nix +++ b/modules/api/nixos-module.nix @@ -2,6 +2,7 @@ mkNixosModuleLib, moduleLocation, privateNixosModules, + api, ... }: { @@ -45,12 +46,12 @@ options.services.pr-tracker.api.port = lib.mkOption { type = lib.types.port; - description = builtins.readFile ../../crates/api-config/PORT.md; + inherit (api.environmentVariables.PR_TRACKER_API_PORT) description; }; options.services.pr-tracker.api.tracingFilter = lib.mkOption { type = lib.types.nullOr lib.types.str; - description = builtins.readFile ../../crates/api-config/TRACING_FILTER.md; + inherit (api.environmentVariables.PR_TRACKER_TRACING_FILTER) description; default = null; }; @@ -73,15 +74,15 @@ systemd.services.pr-tracker-api.script = lib.concatLines ( [ - "export PR_TRACKER_API_DATABASE_URL=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" - "export PR_TRACKER_API_PORT=${lib.escapeShellArg (toString cfg.port)}" + "export ${api.environmentVariables.PR_TRACKER_API_DATABASE_URL.name}=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" + "export ${api.environmentVariables.PR_TRACKER_API_PORT.name}=${lib.escapeShellArg (toString cfg.port)}" ] - ++ (lib.optional ( - cfg.tracingFilter != null - ) "export PR_TRACKER_TRACING_FILTER=${lib.escapeShellArg cfg.tracingFilter}") + ++ (lib.optional (cfg.tracingFilter != null) + "export ${api.environmentVariables.PR_TRACKER_TRACING_FILTER.name}=${lib.escapeShellArg cfg.tracingFilter}" + ) ++ lib.optional (cfg.db.passwordFile != null) '' PASSWORD=$(${lib.getExe pkgs.urlencode} --encode-set component < ${cfg.db.passwordFile}) - PR_TRACKER_API_DATABASE_URL="$PR_TRACKER_API_DATABASE_URL&password=$PASSWORD" + ${api.environmentVariables.PR_TRACKER_API_DATABASE_URL.name}+="&password=$PASSWORD" '' ++ [ "exec ${lib.getExe cfg.package}" ] ); diff --git a/modules/fetcher/default.nix b/modules/fetcher/default.nix index dfc257f7..e6ea708a 100644 --- a/modules/fetcher/default.nix +++ b/modules/fetcher/default.nix @@ -1,13 +1,63 @@ -{ inputs, ... }: +{ + lib, + inputs, + fetcher, + psqlConnectionUriMdLink, + ... +}: { imports = [ ./nixos-module.nix ]; + _module.args.fetcher.environmentVariables = lib.mapAttrs (name: v: v // { inherit name; }) { + PR_TRACKER_FETCHER_DATABASE_URL = { + description = "${psqlConnectionUriMdLink}."; + rustType = "::std::string::String"; + }; + PR_TRACKER_FETCHER_GITHUB_TOKEN = { + description = + # markdown + "GitHub API token with read access to the repository's pull requests."; + rustType = "::std::string::String"; + }; + PR_TRACKER_FETCHER_GITHUB_REPO_OWNER = { + description = + # markdown + "GitHub repository owner."; + rustType = "::std::string::String"; + }; + PR_TRACKER_FETCHER_GITHUB_REPO_NAME = { + description = + # markdown + "GitHub repository name."; + rustType = "::std::string::String"; + }; + PR_TRACKER_FETCHER_CACHE_DIR = { + description = + # markdown + "Cache directory (for repository clone)."; + rustType = "::camino::Utf8PathBuf"; + }; + PR_TRACKER_FETCHER_BRANCH_PATTERNS = { + description = + # markdown + '' + JSON array of strings representing branch patterns to track. + + - `?` matches a single occurrence of any character. + - `*` matches zero or more occurrences of any character. + + No escape characters. + ''; + rustType = "::std::string::String"; + }; + }; + perSystem = { self', config, pkgs, - lib, + writeEnvironmentStructFile, ... }: { @@ -17,16 +67,18 @@ GITHUB_GRAPHQL_SCHEMA = "${inputs.github-graphql-schema}/schema.graphql"; GIT = lib.getExe pkgs.git; }; - fileset = lib.fileset.unions [ - ../../crates/fetcher-config/BRANCH_PATTERNS.md - ../../crates/fetcher-config/GITHUB_TOKEN.md - ../../crates/fetcher-config/GITHUB_REPO_OWNER.md - ../../crates/fetcher-config/GITHUB_REPO_NAME.md - ]; }; crates = { - pr-tracker-fetcher.drvConfig.mkDerivation.meta.mainProgram = "pr-tracker-fetcher"; - pr-tracker-fetcher-config.includeInProjectDocs = true; + pr-tracker-fetcher.drvConfig = { + mkDerivation.meta.mainProgram = "pr-tracker-fetcher"; + env = { + inherit (config.nci.crates.pr-tracker-fetcher-config.drvConfig.env) fetcher_config_snippet; + }; + }; + pr-tracker-fetcher-config = { + drvConfig.env.fetcher_config_snippet = writeEnvironmentStructFile "fetcher" fetcher.environmentVariables; + includeInProjectDocs = true; + }; }; }; diff --git a/modules/fetcher/nixos-module.nix b/modules/fetcher/nixos-module.nix index 012328d6..bec5b2f6 100644 --- a/modules/fetcher/nixos-module.nix +++ b/modules/fetcher/nixos-module.nix @@ -2,6 +2,7 @@ mkNixosModuleLib, moduleLocation, privateNixosModules, + fetcher, ... }: { @@ -45,7 +46,7 @@ options.services.pr-tracker.fetcher.branchPatterns = lib.mkOption { type = lib.types.listOf lib.types.str; - description = builtins.readFile ../../crates/fetcher-config/BRANCH_PATTERNS.md; + inherit (fetcher.environmentVariables.PR_TRACKER_FETCHER_BRANCH_PATTERNS) description; example = [ "release-*" ]; }; @@ -53,20 +54,19 @@ options.services.pr-tracker.fetcher.githubApiTokenFile = lib.mkOption { type = lib.types.path; - description = - "Path to a file containing a " + builtins.readFile ../../crates/fetcher-config/GITHUB_TOKEN.md; + description = "Path to a file containing a ${fetcher.environmentVariables.PR_TRACKER_FETCHER_GITHUB_TOKEN.description}"; example = "/run/secrets/github-api.token"; }; options.services.pr-tracker.fetcher.repo.owner = lib.mkOption { type = lib.types.str; - description = builtins.readFile ../../crates/fetcher-config/GITHUB_REPO_OWNER.md; + inherit (fetcher.environmentVariables.PR_TRACKER_FETCHER_GITHUB_REPO_OWNER) description; example = "NixOS"; }; options.services.pr-tracker.fetcher.repo.name = lib.mkOption { type = lib.types.str; - description = builtins.readFile ../../crates/fetcher-config/GITHUB_REPO_NAME.md; + inherit (fetcher.environmentVariables.PR_TRACKER_FETCHER_GITHUB_REPO_NAME) description; example = "nixpkgs"; }; @@ -96,18 +96,18 @@ systemd.services.pr-tracker-fetcher.requires = lib.optional cfg.db.isLocal "postgresql.service"; systemd.services.pr-tracker-fetcher.script = lib.concatLines ( [ - "export PR_TRACKER_FETCHER_DATABASE_URL=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" - "export PR_TRACKER_FETCHER_GITHUB_REPO_OWNER=${lib.escapeShellArg cfg.repo.owner}" - "export PR_TRACKER_FETCHER_GITHUB_REPO_NAME=${lib.escapeShellArg cfg.repo.name}" - "export PR_TRACKER_FETCHER_BRANCH_PATTERNS=${lib.escapeShellArg (builtins.toJSON cfg.branchPatterns)}" - "export PR_TRACKER_FETCHER_GITHUB_TOKEN=$(< ${cfg.githubApiTokenFile})" + "export ${fetcher.environmentVariables.PR_TRACKER_FETCHER_DATABASE_URL.name}=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" + "export ${fetcher.environmentVariables.PR_TRACKER_FETCHER_GITHUB_REPO_OWNER.name}=${lib.escapeShellArg cfg.repo.owner}" + "export ${fetcher.environmentVariables.PR_TRACKER_FETCHER_GITHUB_REPO_NAME.name}=${lib.escapeShellArg cfg.repo.name}" + "export ${fetcher.environmentVariables.PR_TRACKER_FETCHER_BRANCH_PATTERNS.name}=${lib.escapeShellArg (builtins.toJSON cfg.branchPatterns)}" + "export ${fetcher.environmentVariables.PR_TRACKER_FETCHER_GITHUB_TOKEN.name}=$(< ${cfg.githubApiTokenFile})" # CACHE_DIRECTORY is set by systemd based on the CacheDirectory setting. # See https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#RuntimeDirectory= - "export PR_TRACKER_FETCHER_CACHE_DIR=$CACHE_DIRECTORY" + "export ${fetcher.environmentVariables.PR_TRACKER_FETCHER_CACHE_DIR.name}=$CACHE_DIRECTORY" ] ++ lib.optional (cfg.db.passwordFile != null) '' PASSWORD=$(${lib.getExe pkgs.urlencode} --encode-set component < ${cfg.db.passwordFile}) - PR_TRACKER_FETCHER_DATABASE_URL="$PR_TRACKER_FETCHER_DATABASE_URL&password=$PASSWORD" + ${fetcher.environmentVariables.PR_TRACKER_FETCHER_DATABASE_URL.name}+="&password=$PASSWORD" '' ++ [ "exec ${lib.getExe cfg.package}" ] ); diff --git a/modules/nixos-modules-lib.nix b/modules/nixos-modules-lib.nix index afa6fbb4..f87af170 100644 --- a/modules/nixos-modules-lib.nix +++ b/modules/nixos-modules-lib.nix @@ -1,6 +1,7 @@ { lib, withSystem, + psqlConnectionUriMdLink, ... }: { @@ -22,7 +23,8 @@ db.urlParams = mkOption { type = types.nullOr (types.attrsOf types.str); description = '' - URL parameters from which to compose the ${builtins.readFile ../crates/DATABASE_URL.md} + URL parameters from which to compose the ${psqlConnectionUriMdLink}. + Required unless {option}`${options.services.pr-tracker.db.createLocally}` is true. ''; example = { diff --git a/modules/program-docs.nix b/modules/program-docs.nix index e0b455a3..fffa3576 100644 --- a/modules/program-docs.nix +++ b/modules/program-docs.nix @@ -4,9 +4,6 @@ { packages.program-docs = config.nci.outputs.default.docs; checks."packages/program-docs" = config.packages.program-docs; - nci.projects.default = { - fileset = ../crates/DATABASE_URL.md; - includeInProjectDocs = false; - }; + nci.projects.default.includeInProjectDocs = false; }; } diff --git a/modules/util.nix b/modules/util.nix index f8fb8a33..40660c73 100644 --- a/modules/util.nix +++ b/modules/util.nix @@ -1,7 +1,49 @@ +{ lib, prefixLines, ... }: { + _module.args = { + psqlConnectionUriMdLink = + # markdown + "[PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS)"; + + prefixLines = + prefix: lines: + lib.pipe lines [ + (lib.splitString "\n") + (map (line: prefix + line)) + (lib.concatStringsSep "\n") + ]; + }; + perSystem = { pkgs, ... }: { + _module.args.writeEnvironmentStructFile = + crateName: environmentVariables: + let + fields = lib.pipe environmentVariables [ + (lib.mapAttrsToList ( + envName: envSpec: '' + ${prefixLines "/// " envSpec.description} + #[config(env = "${envName}")] + pub ${envName}: ${envSpec.rustType},'' + )) + (lib.concatStringsSep "\n") + ]; + in + + pkgs.writeTextFile { + name = "${crateName}-env-struct.rs"; + text = + # rust + '' + /// See documentation for each field. + #[derive(::std::fmt::Debug, ::confique::Config)] + pub struct Environment { + ${prefixLines " " fields} + } + ''; + }; + nci.projects.default.fileset = ../crates/util/migrations; treefmt.settings.global.excludes = [ "crates/util/migrations/*" ]; devshells.default.commands = [ From 904db604929dd10b721a6962d702e576059e70cf Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Wed, 28 May 2025 12:12:43 +0700 Subject: [PATCH 06/21] =?UTF-8?q?ci:=20rm=20magic-nix-cache=20=F0=9F=98=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #237 --- .github/workflows/check.yml | 1 - .github/workflows/docs.yml | 1 - .github/workflows/release.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 40835e35..a14c8ea9 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -8,5 +8,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - run: nix flake check diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6be46bc0..d0a80cde 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -19,7 +19,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - run: | nix build .#program-docs mkdir docs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 19b9253d..10d7637e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,6 @@ jobs: with: extra-conf: | experimental-features = no-url-literals pipe-operators - - uses: DeterminateSystems/magic-nix-cache-action@main - uses: navikt/github-app-token-generator@v1 id: get-token with: From f233e0f2f525d2a7c28273882ee12a20c92b74c1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 1 Jun 2025 01:12:43 +0000 Subject: [PATCH 07/21] chore(flake): bump inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nci': 'github:yusdacra/nix-cargo-integration/64209325f09c67cb39d1db0305bc4860734b39af?narHash=sha256-kNsEU5tM11ZAvAU6MI/oZ8unZSat2I%2BXo/ez8aK3SCQ%3D' (2025-05-24) → 'github:yusdacra/nix-cargo-integration/bdbee15a80d1f6806c2d89509087748650dfbaca?narHash=sha256-VztU6Ffc9PCPxMe/QtzRqJFc/MJss5yYNeynnXeTmq0%3D' (2025-05-31) • Updated input 'nci/rust-overlay': 'github:oxalica/rust-overlay/2221d8d53c128beb69346fa3ab36da3f19bb1691?narHash=sha256-rwFiLLNCwkj9bqePtH1sMqzs1xmohE0Ojq249piMzF4%3D' (2025-05-24) → 'github:oxalica/rust-overlay/fc82ce758cc5df6a6d5d24e75710321cdbdc787a?narHash=sha256-F%2BnGITu6D7RswJlm8qCuU1PCuOSgDeAqaDKWW1n1jmQ%3D' (2025-05-31) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/fe51d34885f7b5e3e7b59572796e1bcb427eccb1?narHash=sha256-qmmFCrfBwSHoWw7cVK4Aj%2Bfns%2Bc54EBP8cGqp/yK410%3D' (2025-05-22) → 'github:NixOS/nixpkgs/59138c7667b7970d205d6a05a8bfa2d78caa3643?narHash=sha256-7gGa49iB9nCnFk4h/g9zwjlQAyjtpgcFkODjcOQS0Es%3D' (2025-05-31) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/020cb423808365fa3f10ff4cb8c0a25df35065a3?narHash=sha256-XgxghfND8TDypxsMTPU2GQdtBEsHTEc3qWE6RVEk8O0%3D' (2025-05-22) → 'github:numtide/treefmt-nix/1f3f7b784643d488ba4bf315638b2b0a4c5fb007?narHash=sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8%3D' (2025-05-26) --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 42b1dfaf..dd047d86 100644 --- a/flake.lock +++ b/flake.lock @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1748067367, - "narHash": "sha256-kNsEU5tM11ZAvAU6MI/oZ8unZSat2I+Xo/ez8aK3SCQ=", + "lastModified": 1748672194, + "narHash": "sha256-VztU6Ffc9PCPxMe/QtzRqJFc/MJss5yYNeynnXeTmq0=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "64209325f09c67cb39d1db0305bc4860734b39af", + "rev": "bdbee15a80d1f6806c2d89509087748650dfbaca", "type": "github" }, "original": { @@ -219,11 +219,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1747958103, - "narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=", + "lastModified": 1748662220, + "narHash": "sha256-7gGa49iB9nCnFk4h/g9zwjlQAyjtpgcFkODjcOQS0Es=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1", + "rev": "59138c7667b7970d205d6a05a8bfa2d78caa3643", "type": "github" }, "original": { @@ -316,11 +316,11 @@ ] }, "locked": { - "lastModified": 1748054080, - "narHash": "sha256-rwFiLLNCwkj9bqePtH1sMqzs1xmohE0Ojq249piMzF4=", + "lastModified": 1748658947, + "narHash": "sha256-F+nGITu6D7RswJlm8qCuU1PCuOSgDeAqaDKWW1n1jmQ=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2221d8d53c128beb69346fa3ab36da3f19bb1691", + "rev": "fc82ce758cc5df6a6d5d24e75710321cdbdc787a", "type": "github" }, "original": { @@ -390,11 +390,11 @@ ] }, "locked": { - "lastModified": 1747912973, - "narHash": "sha256-XgxghfND8TDypxsMTPU2GQdtBEsHTEc3qWE6RVEk8O0=", + "lastModified": 1748243702, + "narHash": "sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "020cb423808365fa3f10ff4cb8c0a25df35065a3", + "rev": "1f3f7b784643d488ba4bf315638b2b0a4c5fb007", "type": "github" }, "original": { From 5939a01138821bf35222e2324f5154d120c11aa5 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Tue, 3 Jun 2025 23:15:03 -0700 Subject: [PATCH 08/21] docs: unified manual This completes https://github.com/molybdenumsoftware/pr-tracker/issues/250. Co-authored-by: Shahar "Dawn" Or --- .github/workflows/docs.yml | 9 +-- README.md | 6 +- flake.nix | 3 +- modules/api/default.nix | 24 ++++++-- modules/fetcher/default.nix | 18 ++++-- modules/manual.nix | 120 ++++++++++++++++++++++++++++++++++++ modules/nixos-manual.nix | 70 --------------------- modules/program-docs.nix | 9 --- modules/util.nix | 11 ++++ 9 files changed, 170 insertions(+), 100 deletions(-) create mode 100644 modules/manual.nix delete mode 100644 modules/nixos-manual.nix delete mode 100644 modules/program-docs.nix diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d0a80cde..c9bb121d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -19,14 +19,9 @@ jobs: steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - - run: | - nix build .#program-docs - mkdir docs - cp -r result docs/programs - nix build .#nixos-manual - cp -r result docs/nixos-modules + - run: nix build .#manual - uses: actions/upload-pages-artifact@v3 with: - path: docs + path: result - if: github.ref == 'refs/heads/main' uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index 35763ccd..a3975eae 100644 --- a/README.md +++ b/README.md @@ -30,19 +30,19 @@ Two programs are provided: Intended to be periodically executed. Takes no arguments. -Expects [configuration via environment](https://molybdenumsoftware.github.io/pr-tracker/programs/pr_tracker_fetcher_config/struct.Environment.html). +Expects [configuration via environment](https://molybdenumsoftware.github.io/pr-tracker/fetcher.html). ## pr-tracker-api Takes no arguments. -Expects [configuration via environment](https://molybdenumsoftware.github.io/pr-tracker/programs/pr_tracker_api_config/struct.Environment.html). +Expects [configuration via environment](https://molybdenumsoftware.github.io/pr-tracker/api.html). - `/openapi.json` - `/` redirects to API documentation ## NixOS modules -[Manual](https://molybdenumsoftware.github.io/pr-tracker/nixos-modules) +[Manual](https://molybdenumsoftware.github.io/pr-tracker/nixos.html) ## Versioning diff --git a/flake.nix b/flake.nix index 7d31c821..e93eb126 100644 --- a/flake.nix +++ b/flake.nix @@ -34,11 +34,10 @@ ./modules/filter-options.nix ./modules/formatting.nix ./modules/integration-tests + ./modules/manual.nix ./modules/nci.nix - ./modules/nixos-manual.nix ./modules/nixos-modules-lib.nix ./modules/private-nixos-modules - ./modules/program-docs.nix ./modules/release ./modules/store.nix ./modules/util.nix diff --git a/modules/api/default.nix b/modules/api/default.nix index c464652e..6bf5607c 100644 --- a/modules/api/default.nix +++ b/modules/api/default.nix @@ -2,6 +2,7 @@ lib, api, psqlConnectionUriMdLink, + environmentVariablesToMarkdown, ... }: { @@ -22,7 +23,10 @@ PR_TRACKER_TRACING_FILTER = { description = # markdown - "Expected to deserialize into an [`EnvFilter`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html)."; + '' + Optional. + Expected to deserialize into an [`EnvFilter`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html). + ''; # Note: ideally we'd use `::core::option::Option`, but cannot because # confique's derive macro seems not to support it. rustType = "Option"; @@ -31,12 +35,25 @@ perSystem = { + pkgs, self', config, writeEnvironmentStructFile, ... }: { + chapters.api = { + title = "API"; + drv = pkgs.writeTextFile { + name = "api.md"; + text = '' + ## Environment Variables + + ${environmentVariablesToMarkdown api.environmentVariables} + ''; + }; + }; + nci = { crates = { pr-tracker-api.drvConfig = { @@ -45,10 +62,7 @@ inherit (config.nci.crates.pr-tracker-api-config.drvConfig.env) api_config_snippet; }; }; - pr-tracker-api-config = { - drvConfig.env.api_config_snippet = writeEnvironmentStructFile "api" api.environmentVariables; - includeInProjectDocs = true; - }; + pr-tracker-api-config.drvConfig.env.api_config_snippet = writeEnvironmentStructFile "api" api.environmentVariables; }; }; packages.api = config.nci.outputs.pr-tracker-api.packages.release; diff --git a/modules/fetcher/default.nix b/modules/fetcher/default.nix index e6ea708a..97cabce1 100644 --- a/modules/fetcher/default.nix +++ b/modules/fetcher/default.nix @@ -3,6 +3,7 @@ inputs, fetcher, psqlConnectionUriMdLink, + environmentVariablesToMarkdown, ... }: { @@ -61,6 +62,18 @@ ... }: { + chapters.fetcher = { + title = "Fetcher"; + drv = pkgs.writeTextFile { + name = "fetcher.md"; + text = '' + ## Environment Variables + + ${environmentVariablesToMarkdown fetcher.environmentVariables} + ''; + }; + }; + nci = { projects.default = { drvConfig.env = { @@ -75,10 +88,7 @@ inherit (config.nci.crates.pr-tracker-fetcher-config.drvConfig.env) fetcher_config_snippet; }; }; - pr-tracker-fetcher-config = { - drvConfig.env.fetcher_config_snippet = writeEnvironmentStructFile "fetcher" fetcher.environmentVariables; - includeInProjectDocs = true; - }; + pr-tracker-fetcher-config.drvConfig.env.fetcher_config_snippet = writeEnvironmentStructFile "fetcher" fetcher.environmentVariables; }; }; diff --git a/modules/manual.nix b/modules/manual.nix new file mode 100644 index 00000000..a27917c4 --- /dev/null +++ b/modules/manual.nix @@ -0,0 +1,120 @@ +{ + lib, + self, + ... +}: +{ + perSystem = + psArgs@{ + self', + system, + pkgs, + ... + }: + let + filterOptions = import ../filterOptions.nix lib; + + configuration = lib.nixosSystem { + modules = [ + self.nixosModules.api + self.nixosModules.fetcher + { + nixpkgs.hostPlatform = system; + } + ]; + }; + + options = filterOptions ( + path: option: lib.any (lib.hasPrefix "${self}/") option.declarations + ) configuration.options; + + optionsDocs = pkgs.buildPackages.nixosOptionsDoc { + inherit options; + variablelistId = "options"; + transformOptions = options: builtins.removeAttrs options [ "declarations" ]; + }; + + optionsMd = + pkgs.runCommand "pr-tracker-nixos-options-html" { nativeBuildInputs = [ pkgs.nixos-render-docs ]; } + '' + nixos-render-docs options commonmark \ + --manpage-urls <(echo "{}") \ + --revision provide-because-required-but-seems-to-be-unused \ + ${optionsDocs.optionsJSON}/share/doc/nixos/options.json $out + ''; + + summaryMd = pkgs.writeTextFile { + name = "SUMMARY.md"; + text = + # markdown + '' + - ${mkChapterLink psArgs.config.chapters.nixos} + + # Programs + + - ${mkChapterLink psArgs.config.chapters.api} + - ${mkChapterLink psArgs.config.chapters.fetcher} + ''; + }; + + mkChapterLink = { title, basename, ... }: "[${title}](${basename}.md)"; + in + { + options = { + chapters = lib.mkOption { + type = lib.types.lazyAttrsOf ( + lib.types.submodule ( + { name, ... }: + { + options = { + title = lib.mkOption { + type = lib.types.str; + }; + + basename = lib.mkOption { + type = lib.types.str; + default = name; + }; + + drv = lib.mkOption { + type = lib.types.package; + }; + }; + } + ) + ); + }; + }; + config = { + chapters = { + nixos = { + title = "NixOS"; + drv = optionsMd; + }; + }; + + packages.manual = + pkgs.runCommand "pr-tracker-nixos-manual" + { + nativeBuildInputs = [ + pkgs.mdbook + pkgs.coreutils + ]; + } + '' + mkdir src + + ln -s ${summaryMd} src/SUMMARY.md + + ${lib.pipe psArgs.config.chapters [ + (lib.mapAttrsToList (name: chapter: "ln -s ${chapter.drv} src/${chapter.basename}.md")) + lib.concatLines + ]} + + mdbook build --dest-dir $out + ''; + + checks."packages/manual" = self'.packages.manual; + }; + }; +} diff --git a/modules/nixos-manual.nix b/modules/nixos-manual.nix deleted file mode 100644 index 58194105..00000000 --- a/modules/nixos-manual.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ - lib, - self, - ... -}: -{ - perSystem = - { - self', - system, - pkgs, - ... - }: - let - filterOptions = import ../filterOptions.nix lib; - - configuration = lib.nixosSystem { - modules = [ - self.nixosModules.api - self.nixosModules.fetcher - { - nixpkgs.hostPlatform = system; - } - ]; - }; - - options = filterOptions ( - path: option: lib.any (lib.hasPrefix "${self}/") option.declarations - ) configuration.options; - - optionsDocs = pkgs.buildPackages.nixosOptionsDoc { - inherit options; - variablelistId = "options"; - transformOptions = options: builtins.removeAttrs options [ "declarations" ]; - }; - - optionsMd = - pkgs.runCommand "pr-tracker-nixos-options-html" { nativeBuildInputs = [ pkgs.nixos-render-docs ]; } - '' - nixos-render-docs options commonmark \ - --manpage-urls <(echo "{}") \ - --revision provide-because-required-but-seems-to-be-unused \ - ${optionsDocs.optionsJSON}/share/doc/nixos/options.json $out - ''; - - summaryMd = pkgs.writeTextFile { - name = "SUMMARY.md"; - text = - # markdown - '' - [Options](options.md) - ''; - }; - in - { - packages.nixos-manual = - pkgs.runCommand "pr-tracker-nixos-manual" - { - nativeBuildInputs = [ pkgs.mdbook ]; - } - '' - mkdir src - ln -s ${summaryMd} src/SUMMARY.md - ln -s ${optionsMd} src/options.md - mdbook build --dest-dir $out - ''; - - checks."packages/nixos-modules-manual" = self'.packages.nixos-manual; - }; -} diff --git a/modules/program-docs.nix b/modules/program-docs.nix deleted file mode 100644 index fffa3576..00000000 --- a/modules/program-docs.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - perSystem = - { config, ... }: - { - packages.program-docs = config.nci.outputs.default.docs; - checks."packages/program-docs" = config.packages.program-docs; - nci.projects.default.includeInProjectDocs = false; - }; -} diff --git a/modules/util.nix b/modules/util.nix index 40660c73..8f7dc71f 100644 --- a/modules/util.nix +++ b/modules/util.nix @@ -12,6 +12,17 @@ (map (line: prefix + line)) (lib.concatStringsSep "\n") ]; + + environmentVariablesToMarkdown = variables: '' + | Name | Description | + |------|-------------| + ${lib.pipe variables [ + (lib.mapAttrsToList ( + name: envVar: "| `${name}` | ${lib.strings.replaceStrings [ "\n" ] [ "
" ] envVar.description} |" + )) + lib.concatLines + ]} + ''; }; perSystem = From f9712a58ade184c694e975a70e5edda9e2727fa4 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 4 Jun 2025 14:24:37 +0700 Subject: [PATCH 09/21] refactor: remove api-config and fetcher-config crates Co-authored-by: Shahar "Dawn" Or --- Cargo.lock | 23 +------------------ crates/api-config/Cargo.toml | 15 ------------ crates/api/Cargo.toml | 2 +- .../src/lib.rs => api/src/config.rs} | 5 +--- crates/api/src/main.rs | 4 +++- crates/fetcher-config/Cargo.toml | 13 ----------- crates/fetcher-config/src/lib.rs | 7 ------ crates/fetcher/Cargo.toml | 1 - crates/fetcher/src/config.rs | 3 +++ crates/fetcher/src/main.rs | 4 +++- modules/api/default.nix | 7 ++---- modules/fetcher/default.nix | 5 +--- 12 files changed, 15 insertions(+), 74 deletions(-) delete mode 100644 crates/api-config/Cargo.toml rename crates/{api-config/src/lib.rs => api/src/config.rs} (83%) delete mode 100644 crates/fetcher-config/Cargo.toml delete mode 100644 crates/fetcher-config/src/lib.rs create mode 100644 crates/fetcher/src/config.rs diff --git a/Cargo.lock b/Cargo.lock index 0e1b9029..5fec910d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2934,10 +2934,10 @@ dependencies = [ "getset", "poem", "poem-openapi", - "pr-tracker-api-config", "pr-tracker-store", "sd-notify", "serde", + "serde_with", "sqlx", "tempfile", "thiserror 1.0.69", @@ -2946,17 +2946,6 @@ dependencies = [ "util", ] -[[package]] -name = "pr-tracker-api-config" -version = "7.2.0" -dependencies = [ - "camino", - "confique", - "serde", - "serde_with", - "tracing-subscriber", -] - [[package]] name = "pr-tracker-fetcher" version = "7.2.0" @@ -2973,7 +2962,6 @@ dependencies = [ "itertools", "log", "once_cell", - "pr-tracker-fetcher-config", "pr-tracker-store", "reqwest", "serde", @@ -2985,15 +2973,6 @@ dependencies = [ "wildmatch", ] -[[package]] -name = "pr-tracker-fetcher-config" -version = "7.2.0" -dependencies = [ - "camino", - "confique", - "serde", -] - [[package]] name = "pr-tracker-store" version = "7.2.0" diff --git a/crates/api-config/Cargo.toml b/crates/api-config/Cargo.toml deleted file mode 100644 index f741323b..00000000 --- a/crates/api-config/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[dependencies] -camino.workspace = true -confique.workspace = true -serde.workspace = true -serde_with.workspace = true -tracing-subscriber.workspace = true - -[package] -name = "pr-tracker-api-config" -publish = false -authors.workspace = true -edition.workspace = true -license.workspace = true -repository.workspace = true -version.workspace = true diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index 14823922..be8f379c 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -2,13 +2,13 @@ camino = "*" poem = {features = ["requestid", "test"], version = "*"} poem-openapi = {features = ["swagger-ui"], version = "*"} -pr-tracker-api-config = {path = "../api-config"} sqlx = {default-features = false, features = ["macros", "migrate"], version = "*"} tokio = "*" anyhow.workspace = true confique.workspace = true pr-tracker-store.workspace = true serde.workspace = true +serde_with.workspace = true thiserror.workspace = true tracing-subscriber.workspace = true util.workspace = true diff --git a/crates/api-config/src/lib.rs b/crates/api/src/config.rs similarity index 83% rename from crates/api-config/src/lib.rs rename to crates/api/src/config.rs index 81438113..4ba05f23 100644 --- a/crates/api-config/src/lib.rs +++ b/crates/api/src/config.rs @@ -1,14 +1,11 @@ #![allow(non_snake_case, clippy::struct_field_names)] -pub use environment::Environment; use serde::Deserialize; use serde_with::DisplayFromStr; use serde_with::serde_as; use tracing_subscriber::EnvFilter; -mod environment { - include!(env!("api_config_snippet")); -} +include!(env!("api_config_snippet")); #[serde_as] #[derive(Deserialize, Debug)] diff --git a/crates/api/src/main.rs b/crates/api/src/main.rs index 937ae700..cb3ada14 100644 --- a/crates/api/src/main.rs +++ b/crates/api/src/main.rs @@ -1,13 +1,15 @@ #![warn(clippy::pedantic)] +mod config; + use anyhow::Context; +use config::Environment; use confique::Config; use poem::{ Server, listener::{Listener, TcpListener}, }; use pr_tracker_api::endpoint; -use pr_tracker_api_config::Environment; #[tokio::main] async fn main() { diff --git a/crates/fetcher-config/Cargo.toml b/crates/fetcher-config/Cargo.toml deleted file mode 100644 index d87db030..00000000 --- a/crates/fetcher-config/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[dependencies] -camino.workspace = true -confique.workspace = true -serde.workspace = true - -[package] -name = "pr-tracker-fetcher-config" -publish = false -authors.workspace = true -edition.workspace = true -license.workspace = true -repository.workspace = true -version.workspace = true diff --git a/crates/fetcher-config/src/lib.rs b/crates/fetcher-config/src/lib.rs deleted file mode 100644 index a9b69640..00000000 --- a/crates/fetcher-config/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(non_snake_case, clippy::struct_field_names)] - -pub use environment::Environment; - -mod environment { - include!(env!("fetcher_config_snippet")); -} diff --git a/crates/fetcher/Cargo.toml b/crates/fetcher/Cargo.toml index 01313fe8..2c5a9ddd 100644 --- a/crates/fetcher/Cargo.toml +++ b/crates/fetcher/Cargo.toml @@ -4,7 +4,6 @@ env_logger = "*" graphql_client = {default-features = false, features = ["graphql_query_derive", "reqwest-rustls"], version = "*"} itertools = "*" log = "*" -pr-tracker-fetcher-config = {path = "../fetcher-config"} # Pinned for compatibility with graphql-client. # We can unpin once this is released: reqwest = {default-features = false, features = ["rustls-tls"], version = "^0.11"} diff --git a/crates/fetcher/src/config.rs b/crates/fetcher/src/config.rs new file mode 100644 index 00000000..72a43e93 --- /dev/null +++ b/crates/fetcher/src/config.rs @@ -0,0 +1,3 @@ +#![allow(non_snake_case, clippy::struct_field_names)] + +include!(env!("fetcher_config_snippet")); diff --git a/crates/fetcher/src/main.rs b/crates/fetcher/src/main.rs index 10afa775..aaafc807 100644 --- a/crates/fetcher/src/main.rs +++ b/crates/fetcher/src/main.rs @@ -1,9 +1,11 @@ #![warn(clippy::pedantic)] +mod config; + use anyhow::{Context, ensure}; +use config::Environment; use confique::Config; use pr_tracker_fetcher::{github::GitHubGraphqlClient, run}; -use pr_tracker_fetcher_config::Environment; use pr_tracker_store::PgConnection; use sqlx_core::connection::Connection; use wildmatch::WildMatch; diff --git a/modules/api/default.nix b/modules/api/default.nix index 6bf5607c..b5ad8054 100644 --- a/modules/api/default.nix +++ b/modules/api/default.nix @@ -29,7 +29,7 @@ ''; # Note: ideally we'd use `::core::option::Option`, but cannot because # confique's derive macro seems not to support it. - rustType = "Option"; + rustType = "Option"; }; }; @@ -58,11 +58,8 @@ crates = { pr-tracker-api.drvConfig = { mkDerivation.meta.mainProgram = "pr-tracker-api"; - env = { - inherit (config.nci.crates.pr-tracker-api-config.drvConfig.env) api_config_snippet; - }; + env.api_config_snippet = writeEnvironmentStructFile "api" api.environmentVariables; }; - pr-tracker-api-config.drvConfig.env.api_config_snippet = writeEnvironmentStructFile "api" api.environmentVariables; }; }; packages.api = config.nci.outputs.pr-tracker-api.packages.release; diff --git a/modules/fetcher/default.nix b/modules/fetcher/default.nix index 97cabce1..650fd994 100644 --- a/modules/fetcher/default.nix +++ b/modules/fetcher/default.nix @@ -84,11 +84,8 @@ crates = { pr-tracker-fetcher.drvConfig = { mkDerivation.meta.mainProgram = "pr-tracker-fetcher"; - env = { - inherit (config.nci.crates.pr-tracker-fetcher-config.drvConfig.env) fetcher_config_snippet; - }; + env.fetcher_config_snippet = writeEnvironmentStructFile "fetcher" fetcher.environmentVariables; }; - pr-tracker-fetcher-config.drvConfig.env.fetcher_config_snippet = writeEnvironmentStructFile "fetcher" fetcher.environmentVariables; }; }; From 25efc816d9a3bed410019cf2c3f58fa7acaad2d2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 15 Jun 2025 01:08:10 +0000 Subject: [PATCH 10/21] chore(flake): bump inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'flake-parts': 'github:hercules-ci/flake-parts/c621e8422220273271f52058f618c94e405bb0f5?narHash=sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY%3D' (2025-04-01) → 'github:hercules-ci/flake-parts/9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569?narHash=sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98%3D' (2025-06-08) • Updated input 'git-hooks-nix': 'github:cachix/git-hooks.nix/80479b6ec16fefd9c1db3ea13aeb038c60530f46?narHash=sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo%2BbnXU9D9k%3D' (2025-05-16) → 'github:cachix/git-hooks.nix/623c56286de5a3193aa38891a6991b28f9bab056?narHash=sha256-WUaIlOlPLyPgz9be7fqWJA5iG6rHcGRtLERSCfUDne4%3D' (2025-06-11) • Updated input 'nci': 'github:yusdacra/nix-cargo-integration/bdbee15a80d1f6806c2d89509087748650dfbaca?narHash=sha256-VztU6Ffc9PCPxMe/QtzRqJFc/MJss5yYNeynnXeTmq0%3D' (2025-05-31) → 'github:yusdacra/nix-cargo-integration/277091f33a983df647b72b14af479becf1284702?narHash=sha256-AAs/2mZreHJvLaiABWIM542XCHGHXVXt6adoZMh4Dn0%3D' (2025-06-14) • Updated input 'nci/dream2nix': 'github:nix-community/dream2nix/6fd6d9188f32efd1e1656b3c3e63a67f9df7b636?narHash=sha256-qZWuEdxmPx818qR61t3mMozJOvZSmTRUDPU4L3JeGgE%3D' (2025-05-19) → 'github:nix-community/dream2nix/338bfd0b0940cb94c4fd11219e3694580779bd8e?narHash=sha256-LC5BiVO%2BXpsuSWr6mYhOzP3g2wucTQwTfEzt8Ol2Nrg%3D' (2025-06-13) • Updated input 'nci/rust-overlay': 'github:oxalica/rust-overlay/fc82ce758cc5df6a6d5d24e75710321cdbdc787a?narHash=sha256-F%2BnGITu6D7RswJlm8qCuU1PCuOSgDeAqaDKWW1n1jmQ%3D' (2025-05-31) → 'github:oxalica/rust-overlay/2ff6d56a67d75559f7b5d9edf9aa1fcf8e15f461?narHash=sha256-oWO5KAIjhclLwYJp7kJiNbNqCcZo8ZLuKQEJd9WL6r4%3D' (2025-06-14) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/59138c7667b7970d205d6a05a8bfa2d78caa3643?narHash=sha256-7gGa49iB9nCnFk4h/g9zwjlQAyjtpgcFkODjcOQS0Es%3D' (2025-05-31) → 'github:NixOS/nixpkgs/6afe187897bef7933475e6af374c893f4c84a293?narHash=sha256-K9yBph93OLTNw02Q6e9CYFGrUhvEXnh45vrZqIRWfvQ%3D' (2025-06-14) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/1f3f7b784643d488ba4bf315638b2b0a4c5fb007?narHash=sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8%3D' (2025-05-26) → 'github:numtide/treefmt-nix/a05be418a1af1198ca0f63facb13c985db4cb3c5?narHash=sha256-eEy8cuS0mZ2j/r/FE0/LYBSBcIs/MKOIVakwHVuqTfk%3D' (2025-06-06) --- flake.lock | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/flake.lock b/flake.lock index dd047d86..399435f5 100644 --- a/flake.lock +++ b/flake.lock @@ -47,11 +47,11 @@ "pyproject-nix": "pyproject-nix" }, "locked": { - "lastModified": 1747658429, - "narHash": "sha256-qZWuEdxmPx818qR61t3mMozJOvZSmTRUDPU4L3JeGgE=", + "lastModified": 1749815366, + "narHash": "sha256-LC5BiVO+XpsuSWr6mYhOzP3g2wucTQwTfEzt8Ol2Nrg=", "owner": "nix-community", "repo": "dream2nix", - "rev": "6fd6d9188f32efd1e1656b3c3e63a67f9df7b636", + "rev": "338bfd0b0940cb94c4fd11219e3694580779bd8e", "type": "github" }, "original": { @@ -99,11 +99,11 @@ ] }, "locked": { - "lastModified": 1743550720, - "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "lastModified": 1749398372, + "narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569", "type": "github" }, "original": { @@ -121,11 +121,11 @@ ] }, "locked": { - "lastModified": 1747372754, - "narHash": "sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo+bnXU9D9k=", + "lastModified": 1749636823, + "narHash": "sha256-WUaIlOlPLyPgz9be7fqWJA5iG6rHcGRtLERSCfUDne4=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46", + "rev": "623c56286de5a3193aa38891a6991b28f9bab056", "type": "github" }, "original": { @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1748672194, - "narHash": "sha256-VztU6Ffc9PCPxMe/QtzRqJFc/MJss5yYNeynnXeTmq0=", + "lastModified": 1749881821, + "narHash": "sha256-AAs/2mZreHJvLaiABWIM542XCHGHXVXt6adoZMh4Dn0=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "bdbee15a80d1f6806c2d89509087748650dfbaca", + "rev": "277091f33a983df647b72b14af479becf1284702", "type": "github" }, "original": { @@ -219,11 +219,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1748662220, - "narHash": "sha256-7gGa49iB9nCnFk4h/g9zwjlQAyjtpgcFkODjcOQS0Es=", + "lastModified": 1749871736, + "narHash": "sha256-K9yBph93OLTNw02Q6e9CYFGrUhvEXnh45vrZqIRWfvQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "59138c7667b7970d205d6a05a8bfa2d78caa3643", + "rev": "6afe187897bef7933475e6af374c893f4c84a293", "type": "github" }, "original": { @@ -316,11 +316,11 @@ ] }, "locked": { - "lastModified": 1748658947, - "narHash": "sha256-F+nGITu6D7RswJlm8qCuU1PCuOSgDeAqaDKWW1n1jmQ=", + "lastModified": 1749868581, + "narHash": "sha256-oWO5KAIjhclLwYJp7kJiNbNqCcZo8ZLuKQEJd9WL6r4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "fc82ce758cc5df6a6d5d24e75710321cdbdc787a", + "rev": "2ff6d56a67d75559f7b5d9edf9aa1fcf8e15f461", "type": "github" }, "original": { @@ -390,11 +390,11 @@ ] }, "locked": { - "lastModified": 1748243702, - "narHash": "sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8=", + "lastModified": 1749194973, + "narHash": "sha256-eEy8cuS0mZ2j/r/FE0/LYBSBcIs/MKOIVakwHVuqTfk=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "1f3f7b784643d488ba4bf315638b2b0a4c5fb007", + "rev": "a05be418a1af1198ca0f63facb13c985db4cb3c5", "type": "github" }, "original": { From 8950febe91e5d725c57acb14e6d52fb159253be1 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Mon, 7 Jul 2025 23:48:12 -0700 Subject: [PATCH 11/21] =?UTF-8?q?Revert=20"ci:=20rm=20magic-nix-cache=20?= =?UTF-8?q?=F0=9F=98=A2"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 904db604929dd10b721a6962d702e576059e70cf. Co-authored-by: Shahar "Dawn" Or --- .github/workflows/check.yml | 1 + .github/workflows/docs.yml | 1 + .github/workflows/release.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a14c8ea9..40835e35 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -8,4 +8,5 @@ jobs: steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main - run: nix flake check diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c9bb121d..0c3a882e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -19,6 +19,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main - run: nix build .#manual - uses: actions/upload-pages-artifact@v3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10d7637e..19b9253d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,7 @@ jobs: with: extra-conf: | experimental-features = no-url-literals pipe-operators + - uses: DeterminateSystems/magic-nix-cache-action@main - uses: navikt/github-app-token-generator@v1 id: get-token with: From 179e1f0bf2f89a2ad91ff3374b11f056b4b2d46a Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Tue, 8 Jul 2025 19:37:45 +0700 Subject: [PATCH 12/21] chore(flake): postgresql.service -> postgresql.target https://github.com/NixOS/nixpkgs/commit/41c5662cbec9930b337a895c7cb010948d9766a9 --- flake.lock | 42 ++++++++++++++-------------- modules/api/nixos-module.nix | 4 +-- modules/fetcher/nixos-module.nix | 4 +-- modules/private-nixos-modules/db.nix | 6 ++-- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/flake.lock b/flake.lock index 399435f5..ba21a541 100644 --- a/flake.lock +++ b/flake.lock @@ -47,11 +47,11 @@ "pyproject-nix": "pyproject-nix" }, "locked": { - "lastModified": 1749815366, - "narHash": "sha256-LC5BiVO+XpsuSWr6mYhOzP3g2wucTQwTfEzt8Ol2Nrg=", + "lastModified": 1750272463, + "narHash": "sha256-udleaLnEHK3A5RZVCEQnE6Zeww6yq03NUcqJ/TcUQVc=", "owner": "nix-community", "repo": "dream2nix", - "rev": "338bfd0b0940cb94c4fd11219e3694580779bd8e", + "rev": "bd83ed026b859acb34c52c3fdc15631c8766af8e", "type": "github" }, "original": { @@ -99,11 +99,11 @@ ] }, "locked": { - "lastModified": 1749398372, - "narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=", + "lastModified": 1751413152, + "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569", + "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", "type": "github" }, "original": { @@ -121,11 +121,11 @@ ] }, "locked": { - "lastModified": 1749636823, - "narHash": "sha256-WUaIlOlPLyPgz9be7fqWJA5iG6rHcGRtLERSCfUDne4=", + "lastModified": 1750779888, + "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "623c56286de5a3193aa38891a6991b28f9bab056", + "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", "type": "github" }, "original": { @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1749881821, - "narHash": "sha256-AAs/2mZreHJvLaiABWIM542XCHGHXVXt6adoZMh4Dn0=", + "lastModified": 1751955571, + "narHash": "sha256-485V8thsEj1FhyQpOuePxavYNb51oR3GV5j/d3yEhkw=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "277091f33a983df647b72b14af479becf1284702", + "rev": "588b1ab2f2a43d61648fb82dfa3b63523440fc33", "type": "github" }, "original": { @@ -219,11 +219,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1749871736, - "narHash": "sha256-K9yBph93OLTNw02Q6e9CYFGrUhvEXnh45vrZqIRWfvQ=", + "lastModified": 1751852175, + "narHash": "sha256-+MLlfTCCOvz4K6AcSPbaPiFM9MYi7fA2Wr1ibmRwIlM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6afe187897bef7933475e6af374c893f4c84a293", + "rev": "2defa37146df235ef62f566cde69930a86f14df1", "type": "github" }, "original": { @@ -316,11 +316,11 @@ ] }, "locked": { - "lastModified": 1749868581, - "narHash": "sha256-oWO5KAIjhclLwYJp7kJiNbNqCcZo8ZLuKQEJd9WL6r4=", + "lastModified": 1751942411, + "narHash": "sha256-01uMHCt2U9tP4f24DGch145tT8YQppLY5TC9mWK7O0A=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2ff6d56a67d75559f7b5d9edf9aa1fcf8e15f461", + "rev": "c587235f892930a61c9e415f0d9792a1b27a41a2", "type": "github" }, "original": { @@ -390,11 +390,11 @@ ] }, "locked": { - "lastModified": 1749194973, - "narHash": "sha256-eEy8cuS0mZ2j/r/FE0/LYBSBcIs/MKOIVakwHVuqTfk=", + "lastModified": 1750931469, + "narHash": "sha256-0IEdQB1nS+uViQw4k3VGUXntjkDp7aAlqcxdewb/hAc=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "a05be418a1af1198ca0f63facb13c985db4cb3c5", + "rev": "ac8e6f32e11e9c7f153823abc3ab007f2a65d3e1", "type": "github" }, "original": { diff --git a/modules/api/nixos-module.nix b/modules/api/nixos-module.nix index 2e97c0c8..e4a1ff1d 100644 --- a/modules/api/nixos-module.nix +++ b/modules/api/nixos-module.nix @@ -69,8 +69,8 @@ systemd.services.pr-tracker-api.wantedBy = [ "multi-user.target" ]; systemd.services.pr-tracker-api.after = [ "network.target" - ] ++ lib.optional cfg.db.isLocal "postgresql.service"; - systemd.services.pr-tracker-api.bindsTo = lib.optional cfg.db.isLocal "postgresql.service"; + ] ++ lib.optional cfg.db.isLocal "postgresql.target"; + systemd.services.pr-tracker-api.bindsTo = lib.optional cfg.db.isLocal "postgresql.target"; systemd.services.pr-tracker-api.script = lib.concatLines ( [ diff --git a/modules/fetcher/nixos-module.nix b/modules/fetcher/nixos-module.nix index bec5b2f6..d337a408 100644 --- a/modules/fetcher/nixos-module.nix +++ b/modules/fetcher/nixos-module.nix @@ -92,8 +92,8 @@ systemd.services.pr-tracker-fetcher.description = "pr-tracker-fetcher"; systemd.services.pr-tracker-fetcher.after = [ "network.target" - ] ++ lib.optional cfg.db.isLocal "postgresql.service"; - systemd.services.pr-tracker-fetcher.requires = lib.optional cfg.db.isLocal "postgresql.service"; + ] ++ lib.optional cfg.db.isLocal "postgresql.target"; + systemd.services.pr-tracker-fetcher.requires = lib.optional cfg.db.isLocal "postgresql.target"; systemd.services.pr-tracker-fetcher.script = lib.concatLines ( [ "export ${fetcher.environmentVariables.PR_TRACKER_FETCHER_DATABASE_URL.name}=${lib.escapeShellArg "postgresql://?${attrsToURLParams cfg.db.urlParams}"}" diff --git a/modules/private-nixos-modules/db.nix b/modules/private-nixos-modules/db.nix index 863d0741..a898cc26 100644 --- a/modules/private-nixos-modules/db.nix +++ b/modules/private-nixos-modules/db.nix @@ -95,9 +95,9 @@ { config = mkIf (cfg.db.createLocally && hasAttr program cfg && programCfg.enable) { services.postgresql.ensureUsers = [ { name = programCfg.user; } ]; - systemd.services.postgresql.postStart = lib.mkAfter '' - $PSQL '${cfg.db.name}' -c 'GRANT "${cfg.db.name}" TO "${programCfg.user}"' - $PSQL '${cfg.db.name}' -c 'ALTER DEFAULT PRIVILEGES FOR ROLE "${programCfg.user}" IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO "${cfg.db.name}"' + systemd.services.postgresql-setup.postStart = '' + psql '${cfg.db.name}' -c 'GRANT "${cfg.db.name}" TO "${programCfg.user}"' + psql '${cfg.db.name}' -c 'ALTER DEFAULT PRIVILEGES FOR ROLE "${programCfg.user}" IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO "${cfg.db.name}"' ''; }; } From 13829004bcb9532c0321a8683de1813b9f3e8dd2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 13 Jul 2025 01:10:10 +0000 Subject: [PATCH 13/21] chore(flake): bump inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nci': 'github:yusdacra/nix-cargo-integration/588b1ab2f2a43d61648fb82dfa3b63523440fc33?narHash=sha256-485V8thsEj1FhyQpOuePxavYNb51oR3GV5j/d3yEhkw%3D' (2025-07-08) → 'github:yusdacra/nix-cargo-integration/818331cdfddd9828002ccd3e5e6efb776aac2040?narHash=sha256-s8UxdemcZmXOHJ0jGZGFr6sqEIM6LwnFNSY1yq0KnBw%3D' (2025-07-12) • Updated input 'nci/rust-overlay': 'github:oxalica/rust-overlay/c587235f892930a61c9e415f0d9792a1b27a41a2?narHash=sha256-01uMHCt2U9tP4f24DGch145tT8YQppLY5TC9mWK7O0A%3D' (2025-07-08) → 'github:oxalica/rust-overlay/678296525a4cce249c608749b171d0b2ceb8b2ff?narHash=sha256-f2PMqtf61mWAM11QoIfGv3hjD2AsJrij4FCzftepuaE%3D' (2025-07-12) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/2defa37146df235ef62f566cde69930a86f14df1?narHash=sha256-%2BMLlfTCCOvz4K6AcSPbaPiFM9MYi7fA2Wr1ibmRwIlM%3D' (2025-07-07) → 'github:NixOS/nixpkgs/2a2130494ad647f953593c4e84ea4df839fbd68c?narHash=sha256-Q82Ms%2BFQmgOBkdoSVm%2BFBpuFoeUAffNerR5yVV7SgT8%3D' (2025-07-08) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/ac8e6f32e11e9c7f153823abc3ab007f2a65d3e1?narHash=sha256-0IEdQB1nS%2BuViQw4k3VGUXntjkDp7aAlqcxdewb/hAc%3D' (2025-06-26) → 'github:numtide/treefmt-nix/c9d477b5d5bd7f26adddd3f96cfd6a904768d4f9?narHash=sha256-19m7P4O/Aw/6%2BCzncWMAJu89JaKeMh3aMle1CNQSIwM%3D' (2025-07-09) --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index ba21a541..2945dac9 100644 --- a/flake.lock +++ b/flake.lock @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1751955571, - "narHash": "sha256-485V8thsEj1FhyQpOuePxavYNb51oR3GV5j/d3yEhkw=", + "lastModified": 1752301087, + "narHash": "sha256-s8UxdemcZmXOHJ0jGZGFr6sqEIM6LwnFNSY1yq0KnBw=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "588b1ab2f2a43d61648fb82dfa3b63523440fc33", + "rev": "818331cdfddd9828002ccd3e5e6efb776aac2040", "type": "github" }, "original": { @@ -219,11 +219,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1751852175, - "narHash": "sha256-+MLlfTCCOvz4K6AcSPbaPiFM9MYi7fA2Wr1ibmRwIlM=", + "lastModified": 1752012998, + "narHash": "sha256-Q82Ms+FQmgOBkdoSVm+FBpuFoeUAffNerR5yVV7SgT8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2defa37146df235ef62f566cde69930a86f14df1", + "rev": "2a2130494ad647f953593c4e84ea4df839fbd68c", "type": "github" }, "original": { @@ -316,11 +316,11 @@ ] }, "locked": { - "lastModified": 1751942411, - "narHash": "sha256-01uMHCt2U9tP4f24DGch145tT8YQppLY5TC9mWK7O0A=", + "lastModified": 1752288212, + "narHash": "sha256-f2PMqtf61mWAM11QoIfGv3hjD2AsJrij4FCzftepuaE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "c587235f892930a61c9e415f0d9792a1b27a41a2", + "rev": "678296525a4cce249c608749b171d0b2ceb8b2ff", "type": "github" }, "original": { @@ -390,11 +390,11 @@ ] }, "locked": { - "lastModified": 1750931469, - "narHash": "sha256-0IEdQB1nS+uViQw4k3VGUXntjkDp7aAlqcxdewb/hAc=", + "lastModified": 1752055615, + "narHash": "sha256-19m7P4O/Aw/6+CzncWMAJu89JaKeMh3aMle1CNQSIwM=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "ac8e6f32e11e9c7f153823abc3ab007f2a65d3e1", + "rev": "c9d477b5d5bd7f26adddd3f96cfd6a904768d4f9", "type": "github" }, "original": { From f1dc6b7f82a98055376add18a34e3195bdc4f380 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 20 Jul 2025 01:11:55 +0000 Subject: [PATCH 14/21] chore(flake): bump inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nci': 'github:yusdacra/nix-cargo-integration/818331cdfddd9828002ccd3e5e6efb776aac2040?narHash=sha256-s8UxdemcZmXOHJ0jGZGFr6sqEIM6LwnFNSY1yq0KnBw%3D' (2025-07-12) → 'github:yusdacra/nix-cargo-integration/47e02f590e1e2c72b4ffc2bcf92b2b11c3195395?narHash=sha256-fhwoEa%2BrjxLsRANRqh4jl4evnGpVNTLWUf4a/KDkQ3k%3D' (2025-07-19) • Updated input 'nci/dream2nix': 'github:nix-community/dream2nix/bd83ed026b859acb34c52c3fdc15631c8766af8e?narHash=sha256-udleaLnEHK3A5RZVCEQnE6Zeww6yq03NUcqJ/TcUQVc%3D' (2025-06-18) → 'github:nix-community/dream2nix/667ba5ee25c95cf63ace92307db270e235dce66e?narHash=sha256-T6wYez5urMcY8oUetwOIqPcqj77Ey3qka7wQsi6YCd4%3D' (2025-07-15) • Updated input 'nci/dream2nix/pyproject-nix': 'github:davhau/pyproject.nix/5a06a2697b228c04dd2f35659b4b659ca74f7aeb?narHash=sha256-hFg5s/hoJFv7tDpiGvEvXP0UfFvFEDgTdyHIjDVHu1I%3D' (2023-12-13) → 'github:pyproject-nix/pyproject.nix/16ee295c25107a94e59a7fc7f2e5322851781162?narHash=sha256-luVj97hIMpCbwhx3hWiRwjP2YvljWy8FM%2B4W9njDhLA%3D' (2025-07-14) • Added input 'nci/dream2nix/pyproject-nix/nixpkgs': follows 'nci/dream2nix/nixpkgs' • Updated input 'nci/rust-overlay': 'github:oxalica/rust-overlay/678296525a4cce249c608749b171d0b2ceb8b2ff?narHash=sha256-f2PMqtf61mWAM11QoIfGv3hjD2AsJrij4FCzftepuaE%3D' (2025-07-12) → 'github:oxalica/rust-overlay/742248f12aed0183a124637e8b27a238a47f46a2?narHash=sha256-LLvDqLiK2%2Bdr7bQqKTnZIZ8F1H67DLt3FUyVrGolGVw%3D' (2025-07-19) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/2a2130494ad647f953593c4e84ea4df839fbd68c?narHash=sha256-Q82Ms%2BFQmgOBkdoSVm%2BFBpuFoeUAffNerR5yVV7SgT8%3D' (2025-07-08) → 'github:NixOS/nixpkgs/6b4955211758ba47fac850c040a27f23b9b4008f?narHash=sha256-dPALCtmik9Wr14MGqVXm%2BOQcv7vhPBXcWNIOThGnB/Q%3D' (2025-07-19) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/c9d477b5d5bd7f26adddd3f96cfd6a904768d4f9?narHash=sha256-19m7P4O/Aw/6%2BCzncWMAJu89JaKeMh3aMle1CNQSIwM%3D' (2025-07-09) → 'github:numtide/treefmt-nix/0043b95d80b5bf6d61e84d237e2007727f4dd38d?narHash=sha256-Eh8FkMvGRaY71BU/oyZTTzt9RsBIq2E6j0r3eLZ/2kY%3D' (2025-07-19) --- flake.lock | 49 ++++++++++++++++++-------------- modules/api/nixos-module.nix | 3 +- modules/fetcher/nixos-module.nix | 3 +- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/flake.lock b/flake.lock index 2945dac9..6dc367bf 100644 --- a/flake.lock +++ b/flake.lock @@ -47,11 +47,11 @@ "pyproject-nix": "pyproject-nix" }, "locked": { - "lastModified": 1750272463, - "narHash": "sha256-udleaLnEHK3A5RZVCEQnE6Zeww6yq03NUcqJ/TcUQVc=", + "lastModified": 1752547840, + "narHash": "sha256-T6wYez5urMcY8oUetwOIqPcqj77Ey3qka7wQsi6YCd4=", "owner": "nix-community", "repo": "dream2nix", - "rev": "bd83ed026b859acb34c52c3fdc15631c8766af8e", + "rev": "667ba5ee25c95cf63ace92307db270e235dce66e", "type": "github" }, "original": { @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1752301087, - "narHash": "sha256-s8UxdemcZmXOHJ0jGZGFr6sqEIM6LwnFNSY1yq0KnBw=", + "lastModified": 1752905922, + "narHash": "sha256-fhwoEa+rjxLsRANRqh4jl4evnGpVNTLWUf4a/KDkQ3k=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "818331cdfddd9828002ccd3e5e6efb776aac2040", + "rev": "47e02f590e1e2c72b4ffc2bcf92b2b11c3195395", "type": "github" }, "original": { @@ -219,11 +219,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1752012998, - "narHash": "sha256-Q82Ms+FQmgOBkdoSVm+FBpuFoeUAffNerR5yVV7SgT8=", + "lastModified": 1752900028, + "narHash": "sha256-dPALCtmik9Wr14MGqVXm+OQcv7vhPBXcWNIOThGnB/Q=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2a2130494ad647f953593c4e84ea4df839fbd68c", + "rev": "6b4955211758ba47fac850c040a27f23b9b4008f", "type": "github" }, "original": { @@ -279,18 +279,23 @@ } }, "pyproject-nix": { - "flake": false, + "inputs": { + "nixpkgs": [ + "nci", + "dream2nix", + "nixpkgs" + ] + }, "locked": { - "lastModified": 1702448246, - "narHash": "sha256-hFg5s/hoJFv7tDpiGvEvXP0UfFvFEDgTdyHIjDVHu1I=", - "owner": "davhau", + "lastModified": 1752481895, + "narHash": "sha256-luVj97hIMpCbwhx3hWiRwjP2YvljWy8FM+4W9njDhLA=", + "owner": "pyproject-nix", "repo": "pyproject.nix", - "rev": "5a06a2697b228c04dd2f35659b4b659ca74f7aeb", + "rev": "16ee295c25107a94e59a7fc7f2e5322851781162", "type": "github" }, "original": { - "owner": "davhau", - "ref": "dream2nix", + "owner": "pyproject-nix", "repo": "pyproject.nix", "type": "github" } @@ -316,11 +321,11 @@ ] }, "locked": { - "lastModified": 1752288212, - "narHash": "sha256-f2PMqtf61mWAM11QoIfGv3hjD2AsJrij4FCzftepuaE=", + "lastModified": 1752892850, + "narHash": "sha256-LLvDqLiK2+dr7bQqKTnZIZ8F1H67DLt3FUyVrGolGVw=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "678296525a4cce249c608749b171d0b2ceb8b2ff", + "rev": "742248f12aed0183a124637e8b27a238a47f46a2", "type": "github" }, "original": { @@ -390,11 +395,11 @@ ] }, "locked": { - "lastModified": 1752055615, - "narHash": "sha256-19m7P4O/Aw/6+CzncWMAJu89JaKeMh3aMle1CNQSIwM=", + "lastModified": 1752909129, + "narHash": "sha256-Eh8FkMvGRaY71BU/oyZTTzt9RsBIq2E6j0r3eLZ/2kY=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "c9d477b5d5bd7f26adddd3f96cfd6a904768d4f9", + "rev": "0043b95d80b5bf6d61e84d237e2007727f4dd38d", "type": "github" }, "original": { diff --git a/modules/api/nixos-module.nix b/modules/api/nixos-module.nix index e4a1ff1d..f9f11621 100644 --- a/modules/api/nixos-module.nix +++ b/modules/api/nixos-module.nix @@ -69,7 +69,8 @@ systemd.services.pr-tracker-api.wantedBy = [ "multi-user.target" ]; systemd.services.pr-tracker-api.after = [ "network.target" - ] ++ lib.optional cfg.db.isLocal "postgresql.target"; + ] + ++ lib.optional cfg.db.isLocal "postgresql.target"; systemd.services.pr-tracker-api.bindsTo = lib.optional cfg.db.isLocal "postgresql.target"; systemd.services.pr-tracker-api.script = lib.concatLines ( diff --git a/modules/fetcher/nixos-module.nix b/modules/fetcher/nixos-module.nix index d337a408..576bf19c 100644 --- a/modules/fetcher/nixos-module.nix +++ b/modules/fetcher/nixos-module.nix @@ -92,7 +92,8 @@ systemd.services.pr-tracker-fetcher.description = "pr-tracker-fetcher"; systemd.services.pr-tracker-fetcher.after = [ "network.target" - ] ++ lib.optional cfg.db.isLocal "postgresql.target"; + ] + ++ lib.optional cfg.db.isLocal "postgresql.target"; systemd.services.pr-tracker-fetcher.requires = lib.optional cfg.db.isLocal "postgresql.target"; systemd.services.pr-tracker-fetcher.script = lib.concatLines ( [ From 442a4b3530f323e1a3f33fd94719d990cb5100c1 Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Tue, 22 Jul 2025 13:47:59 +0700 Subject: [PATCH 15/21] docs: move readme content to manual closes #256 --- README.md | 105 +----------------------------------- flake.nix | 3 ++ modules/api/default.nix | 17 ++++-- modules/fetcher/default.nix | 15 ++++-- modules/introduction.nix | 46 ++++++++++++++++ modules/manual.nix | 24 ++++++--- modules/prior-art.nix | 30 +++++++++++ modules/release/default.nix | 15 ++++++ modules/vision.nix | 52 ++++++++++++++++++ 9 files changed, 189 insertions(+), 118 deletions(-) create mode 100644 modules/introduction.nix create mode 100644 modules/prior-art.nix create mode 100644 modules/vision.nix diff --git a/README.md b/README.md index a3975eae..b8193a84 100644 --- a/README.md +++ b/README.md @@ -1,104 +1 @@ -# pr-tracker - -## What - -This is a system that provides answers to the following question: - -> Which branches did a certain GitHub pull request "land" in? - -A pull request is considered landed in a branch when that branch contains that pull request's "merge commit"[^1]. - -As of 2024-02-02 GitHub does not provide an API for directly asking this question. - -## How - -In order to provide an API that answers this question the following are obtained: - -1. All pull requests and their merge commits (via GitHub's GraphQL API). -2. A clone of the repository. - -From these, all landings are deduced and stored in a (PostgreSQL) database. - -It is assumed that in the tracked branches, history is never rewritten. - -Two programs are provided: - -1. pr-tracker-fetcher: obtains data, determines landings and persists them. -2. pr-tracker-api: provides an HTTP endpoint for querying landings. - -## pr-tracker-fetcher - -Intended to be periodically executed. -Takes no arguments. -Expects [configuration via environment](https://molybdenumsoftware.github.io/pr-tracker/fetcher.html). - -## pr-tracker-api - -Takes no arguments. -Expects [configuration via environment](https://molybdenumsoftware.github.io/pr-tracker/api.html). - -- `/openapi.json` -- `/` redirects to API documentation - -## NixOS modules - -[Manual](https://molybdenumsoftware.github.io/pr-tracker/nixos.html) - -## Versioning - -- This project uses [Conventional Commits v1](https://www.conventionalcommits.org/en/v1.0.0/) and [Semantic Versioning v2](https://semver.org/spec/v2.0.0.html). -- With regard to versioning, the documented executables and NixOS modules are public. - The libraries are private. -- This project, with all its components, is versioned as one. - -[^1]: Note that in GitHub, a pull request has a "merge commit" even having been merged without an actual merge commit. - -## Prior art - -- [Alyssa Ross' pr-tracker](https://nixpk.gs/pr-tracker.html) ([source](https://git.qyliss.net/pr-tracker)) - Server-side rendered web app. Computes landings for a given PR on the fly by invoking Git on the backend. -- [ocfox's nixpkgs-tracker](https://nixpkgs-tracker.ocfox.me/) ([source](https://github.com/ocfox/nixpkgs-tracker)) - Client-side rendered web app. Computes landings for a given PR on the fly using GitHub api. -- [Maralorn's nixpkgs-bot](https://blog.maralorn.de/projects#nixpkgs-bot) ([source](https://code.maralorn.de/maralorn/config/src/commit/b34d2e0d0adc62c30875edb475f1c09a752fe19e/packages/nixpkgs-bot)) - Matrix bot that provides notification of PR landings. - Periodically computes new PR landings using Git and sends messages. - -All of the above are [Nixpkgs](https://github.com/nixos/nixpkgs/) specific, whereas this project is not. -None of the above internally maintain a dataset of landings. -None of the above currently provide an HTTP API. - -## Vision - -### Push-driven updates - -The current architecture of obtaining data via polling allows instantaneous -and hopefully reliable responses. -However, the data can be stale. - -In the future, we intend to provide fresher data by subscribing to GitHub webhooks. - -Since the public cannot subscribe to GitHub webhooks, -this will require deployment by the repo owner. - -### Event record keeping - -Building upon the implementation of push-driven updates, -we intend to keep track of _when_ PRs land in branches. -This requires a dataset of landings. - -### Webhook service - -We intend to allow users to subscribe to webhook notifications of PR landings. -This provides a couple of benefits over subscribing to GitHub webhooks directly: - -- GitHub webhooks can only notify when a PR lands in its target branch. They - cannot notify when that PR lands in other branches. -- Only repo owners can subscribe to GitHub webhooks. - -### Backport PRs - -A backport PR is a re-application of another PR, targeting a different branch. - -We intend to adopt or invent a workflow whereby in backport PRs the original PR is declared. -Using that metadata, when providing landings for an original PR, -we intend to also include branches on which a backport PR had landed. +[See Manual](https://molybdenumsoftware.github.io/pr-tracker) diff --git a/flake.nix b/flake.nix index e93eb126..fdcf0359 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,9 @@ ./modules/formatting.nix ./modules/integration-tests ./modules/manual.nix + ./modules/prior-art.nix + ./modules/introduction.nix + ./modules/vision.nix ./modules/nci.nix ./modules/nixos-modules-lib.nix ./modules/private-nixos-modules diff --git a/modules/api/default.nix b/modules/api/default.nix index b5ad8054..c33adce0 100644 --- a/modules/api/default.nix +++ b/modules/api/default.nix @@ -46,11 +46,20 @@ title = "API"; drv = pkgs.writeTextFile { name = "api.md"; - text = '' - ## Environment Variables + text = + # markdown + '' + Takes no arguments. - ${environmentVariablesToMarkdown api.environmentVariables} - ''; + - `/openapi.json` + - `/` redirects to API documentation + + ## Environment Variables + + Reads the following environment variables. + + ${environmentVariablesToMarkdown api.environmentVariables} + ''; }; }; diff --git a/modules/fetcher/default.nix b/modules/fetcher/default.nix index 650fd994..0b8185d4 100644 --- a/modules/fetcher/default.nix +++ b/modules/fetcher/default.nix @@ -66,11 +66,18 @@ title = "Fetcher"; drv = pkgs.writeTextFile { name = "fetcher.md"; - text = '' - ## Environment Variables + text = + # markdown + '' + Intended to be periodically executed. + Takes no arguments. - ${environmentVariablesToMarkdown fetcher.environmentVariables} - ''; + ## Environment Variables + + Reads the following environment variables. + + ${environmentVariablesToMarkdown fetcher.environmentVariables} + ''; }; }; diff --git a/modules/introduction.nix b/modules/introduction.nix new file mode 100644 index 00000000..85758c73 --- /dev/null +++ b/modules/introduction.nix @@ -0,0 +1,46 @@ +{ + perSystem = + { + pkgs, + ... + }: + { + chapters.introduction = { + title = "Introduction"; + drv = pkgs.writeTextFile { + name = "introduction.md"; + text = + # markdown + '' + ## What + + This is a system that provides answers to the following question: + + > Which branches did a certain GitHub pull request "land" in? + + A pull request is considered landed in a branch when that branch contains that pull request's "merge commit"[^1]. + + As of 2024-02-02 GitHub does not provide an API for directly asking this question. + + ## How + + In order to provide an API that answers this question the following are obtained: + + 1. All pull requests and their merge commits (via GitHub's GraphQL API). + 2. A clone of the repository. + + From these, all landings are deduced and stored in a (PostgreSQL) database. + + It is assumed that in the tracked branches, history is never rewritten. + + Two programs are provided: + + 1. pr-tracker-fetcher: obtains data, determines landings and persists them. + 2. pr-tracker-api: provides an HTTP endpoint for querying landings. + + [^1]: Note that in GitHub, a pull request has a "merge commit" even having been merged without an actual merge commit. + ''; + }; + }; + }; +} diff --git a/modules/manual.nix b/modules/manual.nix index a27917c4..7bb78173 100644 --- a/modules/manual.nix +++ b/modules/manual.nix @@ -48,12 +48,16 @@ text = # markdown '' - - ${mkChapterLink psArgs.config.chapters.nixos} + ${mkChapterLink psArgs.config.chapters.introduction} - # Programs + ${mkChapterLink psArgs.config.chapters.fetcher} + ${mkChapterLink psArgs.config.chapters.api} - - ${mkChapterLink psArgs.config.chapters.api} - - ${mkChapterLink psArgs.config.chapters.fetcher} + ${mkChapterLink psArgs.config.chapters.nixos} + + ${mkChapterLink psArgs.config.chapters.versioning} + ${mkChapterLink psArgs.config.chapters.prior-art} + ${mkChapterLink psArgs.config.chapters.vision} ''; }; @@ -88,7 +92,7 @@ config = { chapters = { nixos = { - title = "NixOS"; + title = "NixOS Module"; drv = optionsMd; }; }; @@ -107,7 +111,15 @@ ln -s ${summaryMd} src/SUMMARY.md ${lib.pipe psArgs.config.chapters [ - (lib.mapAttrsToList (name: chapter: "ln -s ${chapter.drv} src/${chapter.basename}.md")) + (lib.mapAttrsToList ( + name: chapter: '' + ( + echo ${lib.escapeShellArg ("# " + chapter.title)} + echo "" + cat ${chapter.drv} + )> src/${chapter.basename}.md + '' + )) lib.concatLines ]} diff --git a/modules/prior-art.nix b/modules/prior-art.nix new file mode 100644 index 00000000..31aaefcd --- /dev/null +++ b/modules/prior-art.nix @@ -0,0 +1,30 @@ +{ + perSystem = + { + pkgs, + ... + }: + { + chapters.prior-art = { + title = "Prior art"; + drv = pkgs.writeTextFile { + name = "prior-art.md"; + text = + # markdown + '' + - [Alyssa Ross' pr-tracker](https://nixpk.gs/pr-tracker.html) ([source](https://git.qyliss.net/pr-tracker)) + Server-side rendered web app. Computes landings for a given PR on the fly by invoking Git on the backend. + - [ocfox's nixpkgs-tracker](https://nixpkgs-tracker.ocfox.me/) ([source](https://github.com/ocfox/nixpkgs-tracker)) + Client-side rendered web app. Computes landings for a given PR on the fly using GitHub api. + - [Maralorn's nixpkgs-bot](https://blog.maralorn.de/projects#nixpkgs-bot) ([source](https://code.maralorn.de/maralorn/config/src/commit/b34d2e0d0adc62c30875edb475f1c09a752fe19e/packages/nixpkgs-bot)) + Matrix bot that provides notification of PR landings. + Periodically computes new PR landings using Git and sends messages. + + All of the above are [Nixpkgs](https://github.com/nixos/nixpkgs/) specific, whereas this project is not. + None of the above internally maintain a dataset of landings. + None of the above currently provide an HTTP API. + ''; + }; + }; + }; +} diff --git a/modules/release/default.nix b/modules/release/default.nix index d033e4f8..2e5d3b83 100644 --- a/modules/release/default.nix +++ b/modules/release/default.nix @@ -33,6 +33,21 @@ }; in { + chapters.versioning = { + title = "Versioning"; + drv = pkgs.writeTextFile { + name = "versioning.md"; + text = + # markdown + '' + - This project uses [Conventional Commits v1](https://www.conventionalcommits.org/en/v1.0.0/) and [Semantic Versioning v2](https://semver.org/spec/v2.0.0.html). + - With regard to versioning, the documented executables and NixOS modules are public. + The libraries are private. + - This project, with all its components, is versioned as one. + ''; + }; + }; + apps.bump-version = { type = "app"; program = lib.getExe bump-version; diff --git a/modules/vision.nix b/modules/vision.nix new file mode 100644 index 00000000..9fb88665 --- /dev/null +++ b/modules/vision.nix @@ -0,0 +1,52 @@ +{ + perSystem = + { + pkgs, + ... + }: + { + chapters.vision = { + title = "Vision"; + drv = pkgs.writeTextFile { + name = "vision.md"; + text = + # markdown + '' + ## Push-driven updates + + The current architecture of obtaining data via polling allows instantaneous + and hopefully reliable responses. + However, the data can be stale. + + In the future, we intend to provide fresher data by subscribing to GitHub webhooks. + + Since the public cannot subscribe to GitHub webhooks, + this will require deployment by the repo owner. + + ## Event record keeping + + Building upon the implementation of push-driven updates, + we intend to keep track of _when_ PRs land in branches. + This requires a dataset of landings. + + ## Webhook service + + We intend to allow users to subscribe to webhook notifications of PR landings. + This provides a couple of benefits over subscribing to GitHub webhooks directly: + + - GitHub webhooks can only notify when a PR lands in its target branch. They + cannot notify when that PR lands in other branches. + - Only repo owners can subscribe to GitHub webhooks. + + ## Backport PRs + + A backport PR is a re-application of another PR, targeting a different branch. + + We intend to adopt or invent a workflow whereby in backport PRs the original PR is declared. + Using that metadata, when providing landings for an original PR, + we intend to also include branches on which a backport PR had landed. + ''; + }; + }; + }; +} From 9508429690ad398730000e2c6c3ebdf06bc248b7 Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Tue, 22 Jul 2025 13:59:13 +0700 Subject: [PATCH 16/21] chore: use pre-commit treefmt integration --- modules/formatting.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/formatting.nix b/modules/formatting.nix index 7a8e0b12..814f9bd2 100644 --- a/modules/formatting.nix +++ b/modules/formatting.nix @@ -4,10 +4,7 @@ inputs.treefmt-nix.flakeModule ]; perSystem = { - pre-commit.settings.hooks.nix-fmt = { - enable = true; - entry = "nix fmt -- --fail-on-change"; - }; + pre-commit.settings.hooks.treefmt.enable = true; treefmt = { projectRootFile = "flake.nix"; From c0e329a77b0825b26d1bd92d175fccaf04b4c911 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 27 Jul 2025 01:11:51 +0000 Subject: [PATCH 17/21] chore(flake): bump inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'flake-parts': 'github:hercules-ci/flake-parts/77826244401ea9de6e3bac47c2db46005e1f30b5?narHash=sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ%3D' (2025-07-01) → 'github:hercules-ci/flake-parts/644e0fc48951a860279da645ba77fe4a6e814c5e?narHash=sha256-TVcTNvOeWWk1DXljFxVRp%2BE0tzG1LhrVjOGGoMHuXio%3D' (2025-07-21) • Updated input 'nci': 'github:yusdacra/nix-cargo-integration/47e02f590e1e2c72b4ffc2bcf92b2b11c3195395?narHash=sha256-fhwoEa%2BrjxLsRANRqh4jl4evnGpVNTLWUf4a/KDkQ3k%3D' (2025-07-19) → 'github:yusdacra/nix-cargo-integration/8e1e80dec474b72a1e5e1a05c4dd722c56871990?narHash=sha256-4wKSD8fihiZIxP6bcBIsITWOtBX56ynbIc5p6yqfF0k%3D' (2025-07-26) • Updated input 'nci/dream2nix': 'github:nix-community/dream2nix/667ba5ee25c95cf63ace92307db270e235dce66e?narHash=sha256-T6wYez5urMcY8oUetwOIqPcqj77Ey3qka7wQsi6YCd4%3D' (2025-07-15) → 'github:nix-community/dream2nix/e6566e4ce924a8258499c379ee9552dba1883bce?narHash=sha256-jsoTEhkmn3weESMNRMLNk/ROW3fcHCr8Wgf5amzs5z8%3D' (2025-07-24) • Updated input 'nci/rust-overlay': 'github:oxalica/rust-overlay/742248f12aed0183a124637e8b27a238a47f46a2?narHash=sha256-LLvDqLiK2%2Bdr7bQqKTnZIZ8F1H67DLt3FUyVrGolGVw%3D' (2025-07-19) → 'github:oxalica/rust-overlay/c8b8b812010515b7d9bd7e538f06a9f4edb373ff?narHash=sha256-yzZkDMVfPpNyTciQOfriWpRXrgGNT/cvrFAEQZ//SZs%3D' (2025-07-26) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/6b4955211758ba47fac850c040a27f23b9b4008f?narHash=sha256-dPALCtmik9Wr14MGqVXm%2BOQcv7vhPBXcWNIOThGnB/Q%3D' (2025-07-19) → 'github:NixOS/nixpkgs/6027c30c8e9810896b92429f0092f624f7b1aace?narHash=sha256-cnL5WWn/xkZoyH/03NNUS7QgW5vI7D1i74g48qplCvg%3D' (2025-07-25) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/0043b95d80b5bf6d61e84d237e2007727f4dd38d?narHash=sha256-Eh8FkMvGRaY71BU/oyZTTzt9RsBIq2E6j0r3eLZ/2kY%3D' (2025-07-19) → 'github:numtide/treefmt-nix/2673921c03d6e75fdf4aa93e025772608d1482cf?narHash=sha256-Bv9h1AJegLI8uAhiJ1sZ4XAndYxhgf38tMgCQwiEpmc%3D' (2025-07-25) --- flake.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index 6dc367bf..5e9617a0 100644 --- a/flake.lock +++ b/flake.lock @@ -47,11 +47,11 @@ "pyproject-nix": "pyproject-nix" }, "locked": { - "lastModified": 1752547840, - "narHash": "sha256-T6wYez5urMcY8oUetwOIqPcqj77Ey3qka7wQsi6YCd4=", + "lastModified": 1753366881, + "narHash": "sha256-jsoTEhkmn3weESMNRMLNk/ROW3fcHCr8Wgf5amzs5z8=", "owner": "nix-community", "repo": "dream2nix", - "rev": "667ba5ee25c95cf63ace92307db270e235dce66e", + "rev": "e6566e4ce924a8258499c379ee9552dba1883bce", "type": "github" }, "original": { @@ -99,11 +99,11 @@ ] }, "locked": { - "lastModified": 1751413152, - "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", + "lastModified": 1753121425, + "narHash": "sha256-TVcTNvOeWWk1DXljFxVRp+E0tzG1LhrVjOGGoMHuXio=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", + "rev": "644e0fc48951a860279da645ba77fe4a6e814c5e", "type": "github" }, "original": { @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1752905922, - "narHash": "sha256-fhwoEa+rjxLsRANRqh4jl4evnGpVNTLWUf4a/KDkQ3k=", + "lastModified": 1753510731, + "narHash": "sha256-4wKSD8fihiZIxP6bcBIsITWOtBX56ynbIc5p6yqfF0k=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "47e02f590e1e2c72b4ffc2bcf92b2b11c3195395", + "rev": "8e1e80dec474b72a1e5e1a05c4dd722c56871990", "type": "github" }, "original": { @@ -219,11 +219,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1752900028, - "narHash": "sha256-dPALCtmik9Wr14MGqVXm+OQcv7vhPBXcWNIOThGnB/Q=", + "lastModified": 1753432016, + "narHash": "sha256-cnL5WWn/xkZoyH/03NNUS7QgW5vI7D1i74g48qplCvg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6b4955211758ba47fac850c040a27f23b9b4008f", + "rev": "6027c30c8e9810896b92429f0092f624f7b1aace", "type": "github" }, "original": { @@ -321,11 +321,11 @@ ] }, "locked": { - "lastModified": 1752892850, - "narHash": "sha256-LLvDqLiK2+dr7bQqKTnZIZ8F1H67DLt3FUyVrGolGVw=", + "lastModified": 1753497720, + "narHash": "sha256-yzZkDMVfPpNyTciQOfriWpRXrgGNT/cvrFAEQZ//SZs=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "742248f12aed0183a124637e8b27a238a47f46a2", + "rev": "c8b8b812010515b7d9bd7e538f06a9f4edb373ff", "type": "github" }, "original": { @@ -395,11 +395,11 @@ ] }, "locked": { - "lastModified": 1752909129, - "narHash": "sha256-Eh8FkMvGRaY71BU/oyZTTzt9RsBIq2E6j0r3eLZ/2kY=", + "lastModified": 1753439394, + "narHash": "sha256-Bv9h1AJegLI8uAhiJ1sZ4XAndYxhgf38tMgCQwiEpmc=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "0043b95d80b5bf6d61e84d237e2007727f4dd38d", + "rev": "2673921c03d6e75fdf4aa93e025772608d1482cf", "type": "github" }, "original": { From 6d4a4bd1e8c02836b8e4c22e122077c292374567 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 3 Aug 2025 01:13:36 +0000 Subject: [PATCH 18/21] chore(flake): bump inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'flake-parts': 'github:hercules-ci/flake-parts/644e0fc48951a860279da645ba77fe4a6e814c5e?narHash=sha256-TVcTNvOeWWk1DXljFxVRp%2BE0tzG1LhrVjOGGoMHuXio%3D' (2025-07-21) → 'github:hercules-ci/flake-parts/67df8c627c2c39c41dbec76a1f201929929ab0bd?narHash=sha256-XKqDMN1/Qj1DKivQvscI4vmHfDfvYR2pfuFOJiCeewM%3D' (2025-08-01) • Updated input 'nci': 'github:yusdacra/nix-cargo-integration/8e1e80dec474b72a1e5e1a05c4dd722c56871990?narHash=sha256-4wKSD8fihiZIxP6bcBIsITWOtBX56ynbIc5p6yqfF0k%3D' (2025-07-26) → 'github:yusdacra/nix-cargo-integration/fa4b1c0aa460d1741a4e8cb695cf9b2b74b52db1?narHash=sha256-7fVDO8gvsIkXtmxBSSYMseIRvxCd1m%2BHrtubtUhgp3Q%3D' (2025-08-02) • Updated input 'nci/rust-overlay': 'github:oxalica/rust-overlay/c8b8b812010515b7d9bd7e538f06a9f4edb373ff?narHash=sha256-yzZkDMVfPpNyTciQOfriWpRXrgGNT/cvrFAEQZ//SZs%3D' (2025-07-26) → 'github:oxalica/rust-overlay/08ff39bf869cadca3102b39824f4c7025186b7dc?narHash=sha256-d6nZ%2B1e4VDqW6VAwfx9EAUDJdPxSwqwGiuli32FEgoE%3D' (2025-08-02) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/6027c30c8e9810896b92429f0092f624f7b1aace?narHash=sha256-cnL5WWn/xkZoyH/03NNUS7QgW5vI7D1i74g48qplCvg%3D' (2025-07-25) → 'github:NixOS/nixpkgs/7b6929d8b900de3142638310f8bc40cff4f2c507?narHash=sha256-S30TWshtDmNlU30u842RidFUraKj1f2dd4nrKRHm3gE%3D' (2025-08-02) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/2673921c03d6e75fdf4aa93e025772608d1482cf?narHash=sha256-Bv9h1AJegLI8uAhiJ1sZ4XAndYxhgf38tMgCQwiEpmc%3D' (2025-07-25) → 'github:numtide/treefmt-nix/58bd4da459f0a39e506847109a2a5cfceb837796?narHash=sha256-ONcNxdSiPyJ9qavMPJYAXDNBzYobHRxw0WbT38lKbwU%3D' (2025-08-01) --- flake.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index 5e9617a0..fb615330 100644 --- a/flake.lock +++ b/flake.lock @@ -99,11 +99,11 @@ ] }, "locked": { - "lastModified": 1753121425, - "narHash": "sha256-TVcTNvOeWWk1DXljFxVRp+E0tzG1LhrVjOGGoMHuXio=", + "lastModified": 1754091436, + "narHash": "sha256-XKqDMN1/Qj1DKivQvscI4vmHfDfvYR2pfuFOJiCeewM=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "644e0fc48951a860279da645ba77fe4a6e814c5e", + "rev": "67df8c627c2c39c41dbec76a1f201929929ab0bd", "type": "github" }, "original": { @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1753510731, - "narHash": "sha256-4wKSD8fihiZIxP6bcBIsITWOtBX56ynbIc5p6yqfF0k=", + "lastModified": 1754115510, + "narHash": "sha256-7fVDO8gvsIkXtmxBSSYMseIRvxCd1m+HrtubtUhgp3Q=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "8e1e80dec474b72a1e5e1a05c4dd722c56871990", + "rev": "fa4b1c0aa460d1741a4e8cb695cf9b2b74b52db1", "type": "github" }, "original": { @@ -219,11 +219,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1753432016, - "narHash": "sha256-cnL5WWn/xkZoyH/03NNUS7QgW5vI7D1i74g48qplCvg=", + "lastModified": 1754151594, + "narHash": "sha256-S30TWshtDmNlU30u842RidFUraKj1f2dd4nrKRHm3gE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6027c30c8e9810896b92429f0092f624f7b1aace", + "rev": "7b6929d8b900de3142638310f8bc40cff4f2c507", "type": "github" }, "original": { @@ -321,11 +321,11 @@ ] }, "locked": { - "lastModified": 1753497720, - "narHash": "sha256-yzZkDMVfPpNyTciQOfriWpRXrgGNT/cvrFAEQZ//SZs=", + "lastModified": 1754102567, + "narHash": "sha256-d6nZ+1e4VDqW6VAwfx9EAUDJdPxSwqwGiuli32FEgoE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "c8b8b812010515b7d9bd7e538f06a9f4edb373ff", + "rev": "08ff39bf869cadca3102b39824f4c7025186b7dc", "type": "github" }, "original": { @@ -395,11 +395,11 @@ ] }, "locked": { - "lastModified": 1753439394, - "narHash": "sha256-Bv9h1AJegLI8uAhiJ1sZ4XAndYxhgf38tMgCQwiEpmc=", + "lastModified": 1754061284, + "narHash": "sha256-ONcNxdSiPyJ9qavMPJYAXDNBzYobHRxw0WbT38lKbwU=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "2673921c03d6e75fdf4aa93e025772608d1482cf", + "rev": "58bd4da459f0a39e506847109a2a5cfceb837796", "type": "github" }, "original": { From 680373fb1d7aa05e2a54ad209960c81524915772 Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Wed, 6 Aug 2025 17:38:11 +0700 Subject: [PATCH 19/21] feat(fetcher): some more req/res logging --- crates/fetcher/src/github.rs | 44 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/crates/fetcher/src/github.rs b/crates/fetcher/src/github.rs index ef1f4023..c58c573c 100644 --- a/crates/fetcher/src/github.rs +++ b/crates/fetcher/src/github.rs @@ -1,6 +1,7 @@ use anyhow::Context; use graphql_client::GraphQLQuery; use pr_tracker_store::{GitCommit, GithubPrQueryCursor, Pr, PrNumber}; +use reqwest::header::HeaderValue; // https://docs.github.com/en/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api#node-limit const PAGE_SIZE: i64 = 100; @@ -51,10 +52,9 @@ impl GitHubGraphqlClient { page_size_override_for_testing: Option, ) -> anyhow::Result { let mut headers = reqwest::header::HeaderMap::new(); - headers.insert( - reqwest::header::AUTHORIZATION, - format!("Bearer {api_token}").parse()?, - ); + let mut authorization = HeaderValue::from_str(&format!("Bearer {api_token}"))?; + authorization.set_sensitive(true); + headers.insert(reqwest::header::AUTHORIZATION, authorization); let client = reqwest::Client::builder() .user_agent(USER_AGENT) @@ -81,27 +81,41 @@ impl GithubClient for GitHubGraphqlClient { cursor: cursor.map(|cursor| cursor.as_str().to_string()), page_size: self.page_size, }; - let resp = - graphql_client::reqwest::post_graphql::(self, API_URL, query_vars) - .await?; + + let body = PullsQuery::build_query(query_vars); + let request = self.post(API_URL).json(&body); + log::info!("request: {request:#?}"); + log::info!("request body: {body:#?}"); + let resp: graphql_client::Response = + request.send().await?.json().await?; // https://github.com/graphql-rust/graphql-client/issues/467 let data = resp .data + .as_ref() .context("response with no data, this might be due to an expired token")?; log::info!("rate limits: {:?}", data.rate_limit); - let repository = data.repository.context("data with no repo")?; - let response_prs = repository.pull_requests; - let nodes = response_prs.nodes.unwrap_or_default(); + let repository = data + .repository + .as_ref() + .context(format!("data with no repo\n{:#?}", &resp))?; + let nodes = repository + .pull_requests + .nodes + .as_deref() + .unwrap_or_default(); let prs = nodes - .into_iter() + .iter() .map(|node| -> anyhow::Result<_> { - let node = node.context("null PR node")?; + let node = node.as_ref().context("null PR node")?; - let commit = node.merge_commit.map(|commit| GitCommit(commit.oid)); + let commit = node + .merge_commit + .as_ref() + .map(|commit| GitCommit(commit.oid.clone())); let number: PrNumber = node .number @@ -112,9 +126,11 @@ impl GithubClient for GitHubGraphqlClient { }) .collect::>>()?; - let new_cursor = response_prs + let new_cursor = repository + .pull_requests .page_info .end_cursor + .clone() .map(GithubPrQueryCursor::new); Ok((prs, new_cursor)) From 2160ff90ced18decf7b00f2f8d3c94c28a3e666c Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 6 Aug 2025 11:05:37 -0700 Subject: [PATCH 20/21] fix: address race condition with migrations Our architecture is a bit strange here: both pr-tracker-api and pr-tracker-fetcher race to apply migrations to the database. We just ran into a situation where pr-tracker-api creates the `branches` table, along with an associated `branches_id_seq` sequence which the pr-tracker-fetcher user did not have access to: ``` pr-tracker=> SELECT schemaname, sequencename, sequenceowner FROM pg_sequences; schemaname | sequencename | sequenceowner ------------+-----------------+---------------- public | branches_id_seq | pr-tracker-api ``` This resulted in pr-tracker-fetcher failing to insert rows into the `branches` table: ``` LOG: execute sqlx_s_9: SELECT * from github_prs LOG: statement: BEGIN LOG: execute sqlx_s_10: SELECT * from branches WHERE name = $1 DETAIL: parameters: $1 = 'master' LOG: execute sqlx_s_11: INSERT INTO branches (name) VALUES ($1) RETURNING * DETAIL: parameters: $1 = 'master' ERROR: permission denied for sequence branches_id_seq ``` I don't know if there are other postgres nouns that we're going to wish we'd granted as well. Ideally we'd have caught this in our nixos tests, but I don't think any of our nixos tests actually do anything interesting with pr-tracker-fetcher, because that would require talking to github. I've filed https://github.com/molybdenumsoftware/pr-tracker/issues/268 to track that. --- modules/private-nixos-modules/db.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/private-nixos-modules/db.nix b/modules/private-nixos-modules/db.nix index a898cc26..421b63ed 100644 --- a/modules/private-nixos-modules/db.nix +++ b/modules/private-nixos-modules/db.nix @@ -98,6 +98,7 @@ systemd.services.postgresql-setup.postStart = '' psql '${cfg.db.name}' -c 'GRANT "${cfg.db.name}" TO "${programCfg.user}"' psql '${cfg.db.name}' -c 'ALTER DEFAULT PRIVILEGES FOR ROLE "${programCfg.user}" IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO "${cfg.db.name}"' + psql '${cfg.db.name}' -c 'ALTER DEFAULT PRIVILEGES FOR ROLE "${programCfg.user}" IN SCHEMA public GRANT ALL PRIVILEGES ON SEQUENCES TO "${cfg.db.name}"' ''; }; } From 4bd27df3645e2ab09b01628830a60e4006cd193c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 7 Aug 2025 07:32:51 +0000 Subject: [PATCH 21/21] chore(release): 7.3.0 [skip ci] ## [7.3.0](https://github.com/molybdenumsoftware/pr-tracker/compare/v7.2.0...v7.3.0) (2025-08-07) ### Features * **fetcher:** some more req/res logging ([680373f](https://github.com/molybdenumsoftware/pr-tracker/commit/680373fb1d7aa05e2a54ad209960c81524915772)) ### Bug Fixes * address race condition with migrations ([2160ff9](https://github.com/molybdenumsoftware/pr-tracker/commit/2160ff90ced18decf7b00f2f8d3c94c28a3e666c)) --- CHANGELOG.md | 12 ++++++++++++ Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a10e788c..9e67707a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## [7.3.0](https://github.com/molybdenumsoftware/pr-tracker/compare/v7.2.0...v7.3.0) (2025-08-07) + + +### Features + +* **fetcher:** some more req/res logging ([680373f](https://github.com/molybdenumsoftware/pr-tracker/commit/680373fb1d7aa05e2a54ad209960c81524915772)) + + +### Bug Fixes + +* address race condition with migrations ([2160ff9](https://github.com/molybdenumsoftware/pr-tracker/commit/2160ff90ced18decf7b00f2f8d3c94c28a3e666c)) + ## [7.2.0](https://github.com/molybdenumsoftware/pr-tracker/compare/v7.1.0...v7.2.0) (2025-05-20) diff --git a/Cargo.lock b/Cargo.lock index 5fec910d..c00885f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -527,7 +527,7 @@ dependencies = [ [[package]] name = "db-context" -version = "7.2.0" +version = "7.3.0" dependencies = [ "camino", "fragile-child", @@ -763,7 +763,7 @@ dependencies = [ [[package]] name = "fragile-child" -version = "7.2.0" +version = "7.3.0" [[package]] name = "futures" @@ -2924,7 +2924,7 @@ dependencies = [ [[package]] name = "pr-tracker-api" -version = "7.2.0" +version = "7.3.0" dependencies = [ "anyhow", "camino", @@ -2948,7 +2948,7 @@ dependencies = [ [[package]] name = "pr-tracker-fetcher" -version = "7.2.0" +version = "7.3.0" dependencies = [ "anyhow", "camino", @@ -2975,7 +2975,7 @@ dependencies = [ [[package]] name = "pr-tracker-store" -version = "7.2.0" +version = "7.3.0" dependencies = [ "derive_more", "getset", @@ -4210,7 +4210,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "util" -version = "7.2.0" +version = "7.3.0" dependencies = [ "clap", "db-context", diff --git a/Cargo.toml b/Cargo.toml index 4a91ea2e..89533fb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,4 +29,4 @@ authors = ["Molybdenum Software"] edition = "2024" license = "MIT" repository = "https://github.com/molybdenumsoftware/pr-tracker" -version = "7.2.0" +version = "7.3.0"