Skip to content

Commit

Permalink
wire up this tool to both shells
Browse files Browse the repository at this point in the history
  • Loading branch information
GetPsyched committed Nov 23, 2024
1 parent 8bede89 commit 6320ffd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
11 changes: 10 additions & 1 deletion doc/doc-support/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
mkShellNoCC,
documentation-highlighter,
nixos-render-docs,
nixos-render-docs-redirects,
nixpkgs ? { },
}:

Expand Down Expand Up @@ -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 { };
};
Expand Down
8 changes: 7 additions & 1 deletion nixos/doc/manual/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
11 changes: 10 additions & 1 deletion pkgs/by-name/ni/nixos-render-docs-redirects/package.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ lib, python3 }:
{
lib,
python3,
redirectsFile ? ./.,
}:

python3.pkgs.buildPythonApplication {
pname = "nixos-render-docs-redirects";
Expand All @@ -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; [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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")

Expand Down

0 comments on commit 6320ffd

Please sign in to comment.