diff --git a/doc/doc-support/package.nix b/doc/doc-support/package.nix index f1d9996120ceea..172b64d07e54e1 100644 --- a/doc/doc-support/package.nix +++ b/doc/doc-support/package.nix @@ -9,6 +9,7 @@ mkShellNoCC, documentation-highlighter, nixos-render-docs, + nixos-render-docs-redirects, nixpkgs ? { }, }: @@ -105,8 +106,16 @@ stdenvNoCC.mkDerivation ( buildArgs = "./."; open = "/share/doc/nixpkgs/manual.html"; }; + nixos-render-docs-redirects' = nixos-render-docs-redirects.override { + redirectsFile = ../redirects.json; + }; in - mkShellNoCC { packages = [ devmode' ]; }; + mkShellNoCC { + packages = [ + devmode' + nixos-render-docs-redirects' + ]; + }; tests.manpage-urls = callPackage ../tests/manpage-urls.nix { }; }; diff --git a/nixos/doc/manual/shell.nix b/nixos/doc/manual/shell.nix index aeec93118fc01e..c006a20e524044 100644 --- a/nixos/doc/manual/shell.nix +++ b/nixos/doc/manual/shell.nix @@ -10,7 +10,13 @@ let buildArgs = "../../release.nix -A manualHTML.${builtins.currentSystem}"; open = "/${outputPath}/${indexPath}"; }; + nixos-render-docs-redirects = pkgs.nixos-render-docs-redirects.override { + redirectsFile = ./redirects.json; + }; in pkgs.mkShellNoCC { - packages = [ devmode ]; + packages = [ + devmode + nixos-render-docs-redirects + ]; } diff --git a/pkgs/by-name/ni/nixos-render-docs-redirects/package.nix b/pkgs/by-name/ni/nixos-render-docs-redirects/package.nix index a473fd1533ca5d..96855b2b1bbd01 100644 --- a/pkgs/by-name/ni/nixos-render-docs-redirects/package.nix +++ b/pkgs/by-name/ni/nixos-render-docs-redirects/package.nix @@ -1,4 +1,8 @@ -{ lib, python3 }: +{ + lib, + python3, + redirectsFile ? ./., +}: python3.pkgs.buildPythonApplication { pname = "nixos-render-docs-redirects"; @@ -7,6 +11,11 @@ python3.pkgs.buildPythonApplication { src = ./src; + postPatch = '' + substituteInPlace nixos_render_docs_redirects/__init__.py \ + --replace-fail "@redirects_file@" "${toString redirectsFile}" + ''; + build-system = with python3.pkgs; [ setuptools ]; nativeCheckInputs = with python3.pkgs; [ diff --git a/pkgs/by-name/ni/nixos-render-docs-redirects/src/nixos_render_docs_redirects/__init__.py b/pkgs/by-name/ni/nixos-render-docs-redirects/src/nixos_render_docs_redirects/__init__.py index 0104ef0c3bc1ca..cb0117f1722b54 100644 --- a/pkgs/by-name/ni/nixos-render-docs-redirects/src/nixos_render_docs_redirects/__init__.py +++ b/pkgs/by-name/ni/nixos-render-docs-redirects/src/nixos_render_docs_redirects/__init__.py @@ -67,7 +67,6 @@ def remove_and_redirect( def main(): parser = argparse.ArgumentParser(description="redirects manipulation for nixos manuals") commands = parser.add_subparsers(dest="command", required=True) - parser.add_argument("-f", "--file", type=Path, required=True) add_content_cmd = commands.add_parser("add-content") add_content_cmd.add_argument("identifier", type=str) @@ -87,7 +86,7 @@ def main(): args = parser.parse_args() - with open(args.file) as file: + with open("@redirects_file@") as file: redirects = json.load(file) try: @@ -113,7 +112,7 @@ def main(): except Exception as error: print(error, file=sys.stderr) else: - with open(args.file, "w") as file: + with open("@redirects_file@", "w") as file: json.dump(redirects, file, indent=2) file.write("\n")