diff --git a/.envrc b/.envrc index 868d7b5ab..9260fbb7d 100644 --- a/.envrc +++ b/.envrc @@ -1,9 +1,19 @@ -# Preserve the caller's TMPDIR state because some nix shells replace it with -# a temp directory path that no longer exists after activation. +use_flake_subdir() { + # Keep direnv's cache in sync with every tracked Nix input. + for file in $(git ls-files nix); do + watch_file "$file" + done + mkdir -p "$(direnv_layout_dir)" + eval "$(nix --extra-experimental-features "nix-command flakes" print-dev-env \ + --profile "$(direnv_layout_dir)/flake-profile" "path:nix" "$@")" +} + +# Preserve the caller's TMPDIR state because Nix development shells may replace +# it with a temporary directory path that no longer exists after activation. old_tmpdir="${TMPDIR-}" old_tmpdir_was_set="${TMPDIR+x}" -use nix +use flake_subdir if [ -n "${old_tmpdir_was_set}" ]; then export TMPDIR="$old_tmpdir" diff --git a/.github/workflows/mintlify-validate.yml b/.github/workflows/mintlify-validate.yml index b49d49ca9..b0c15854f 100644 --- a/.github/workflows/mintlify-validate.yml +++ b/.github/workflows/mintlify-validate.yml @@ -13,6 +13,9 @@ concurrency: group: mintlify-validate-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + NIX_CONFIG: "extra-experimental-features = nix-command flakes" + jobs: mintlify-validate: name: mintlify validate @@ -25,23 +28,23 @@ jobs: uses: cachix/install-nix-action@v31 - name: Validate external snippet wrapper - run: nix-shell --run 'npm run test:external-snippets' + run: nix develop path:nix --command npm run test:external-snippets - name: Validate generated-reference history output run: >- - nix-shell --run 'python3 -m pytest + nix develop path:nix --command python3 -m pytest tests/test_history_contract.py tests/test_reference_page_history.py tests/test_openapi_manual_render.py - tests/test_json_api_openapi.py' + tests/test_json_api_openapi.py - name: Check JSON Ledger OpenAPI generated output - run: >- - nix-shell --run 'python3 scripts/generate_json_api_reference.py && - git diff --exit-code -- - docs-main/docs.json - docs-main/openapi/json-ledger-api/openapi.yaml - docs-main/reference/json-api-reference' + run: | + nix develop path:nix --command python3 scripts/generate_json_api_reference.py + git diff --exit-code -- \ + docs-main/docs.json \ + docs-main/openapi/json-ledger-api/openapi.yaml \ + docs-main/reference/json-api-reference - name: Run Mintlify validation - run: nix-shell --run 'cd docs-main && npx mint validate' + run: nix develop path:nix --command bash -c 'cd docs-main && npx mint validate' diff --git a/.github/workflows/update-version-dashboard.yml b/.github/workflows/update-version-dashboard.yml index 2f2458081..a331e7cb5 100644 --- a/.github/workflows/update-version-dashboard.yml +++ b/.github/workflows/update-version-dashboard.yml @@ -24,6 +24,9 @@ concurrency: group: update-generated-docs cancel-in-progress: false +env: + NIX_CONFIG: "extra-experimental-features = nix-command flakes" + # The canton-network-cf-docs runner contract provides Nix through a shared store and daemon. jobs: select-targets: @@ -41,7 +44,7 @@ jobs: env: GENERATED_DOCS_TARGETS: ${{ inputs.targets || 'all' }} run: | - target_matrix="$(SKIP_NPM_INSTALL=1 nix-shell --run 'python3 scripts/update_generated_reference_prs.py --targets $GENERATED_DOCS_TARGETS --print-target-matrix-json')" + target_matrix="$(SKIP_NPM_INSTALL=1 nix develop path:nix --command bash -c 'python3 scripts/update_generated_reference_prs.py --targets $GENERATED_DOCS_TARGETS --print-target-matrix-json')" echo "target_matrix=$target_matrix" >> "$GITHUB_OUTPUT" update-generated-docs: @@ -63,19 +66,19 @@ jobs: run: SKIP_NPM_INSTALL=1 direnv allow . && SKIP_NPM_INSTALL=1 direnv exec . true - name: Install npm dependencies - run: SKIP_NPM_INSTALL=1 nix-shell --run 'npm ci' + run: SKIP_NPM_INSTALL=1 nix develop path:nix --command npm ci - name: Set up Daml tooling if: ${{ matrix.requires_daml_tooling }} run: | - SKIP_NPM_INSTALL=1 nix-shell --run 'bash scripts/install_daml_tooling.sh' + SKIP_NPM_INSTALL=1 nix develop path:nix --command bash scripts/install_daml_tooling.sh echo "$HOME/.dpm/bin" >> "$GITHUB_PATH" echo "$HOME/.daml/bin" >> "$GITHUB_PATH" - name: Verify generated-doc dependencies env: GENERATED_DOCS_DEPENDENCY_ARGS: ${{ matrix.requires_daml_tooling && '--require-daml' || '' }} - run: SKIP_NPM_INSTALL=1 nix-shell --run "python3 scripts/check_generated_docs_dependencies.py $GENERATED_DOCS_DEPENDENCY_ARGS" + run: SKIP_NPM_INSTALL=1 nix develop path:nix --command bash -c "python3 scripts/check_generated_docs_dependencies.py $GENERATED_DOCS_DEPENDENCY_ARGS" - name: Check generated-docs merger app configuration id: merger-app @@ -100,7 +103,7 @@ jobs: - name: Configure generated-docs PR authentication env: GH_TOKEN: ${{ steps.merger-token.outputs.token || github.token }} - run: SKIP_NPM_INSTALL=1 nix-shell --run 'gh auth setup-git' + run: SKIP_NPM_INSTALL=1 nix develop path:nix --command gh auth setup-git - name: Generate update pull requests env: @@ -113,5 +116,4 @@ jobs: if [[ "${{ inputs.dry_run || false }}" == "true" ]]; then args+=(--dry-run) fi - printf -v generated_docs_command '%q ' "${args[@]}" - SKIP_NPM_INSTALL=1 nix-shell --run "$generated_docs_command" + SKIP_NPM_INSTALL=1 nix develop path:nix --command "${args[@]}" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2936ef79e..e7bbee840 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,7 +58,7 @@ For new pages, restructuring, or anything touching multiple files, set up a loca Either: - [`direnv`](https://direnv.net/) -- [`nix`](https://nixos.org/download/) +- [`nix`](https://nixos.org/download/) with `nix-command` and flakes support OR: diff --git a/README.md b/README.md index 6783f24ac..fba58b59b 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Use this to report a problem or request new content without editing the source y Either: - [`direnv`](https://direnv.net/) -- [`nix`](https://nixos.org/download/) +- [`nix`](https://nixos.org/download/) with `nix-command` and flakes support OR: diff --git a/nix/flake.lock b/nix/flake.lock new file mode 100644 index 000000000..bbad20a00 --- /dev/null +++ b/nix/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1779971959, + "narHash": "sha256-R5nauXyqyfRUFiZycFFZdkF7wl6eaUpPLst35+2nJQY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ec942ba042dad5ef097e2ef3a3effc034241f011", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/flake.nix b/nix/flake.nix new file mode 100644 index 000000000..394af0a35 --- /dev/null +++ b/nix/flake.nix @@ -0,0 +1,18 @@ +{ + description = "cf-docs development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShells.default = import ./shell.nix { inherit pkgs; }; + }); +} diff --git a/shell.nix b/nix/shell.nix similarity index 74% rename from shell.nix rename to nix/shell.nix index 016dce9eb..11fde3a55 100644 --- a/shell.nix +++ b/nix/shell.nix @@ -1,14 +1,6 @@ -let - # To get the sha256: - # nix-prefetch-url --unpack https://github.com/NixOS/nixpkgs/archive/.tar.gz - rev = "ec942ba042dad5ef097e2ef3a3effc034241f011"; - sha256 = "sha256:01i5lznyfxyb5r7llscybv17nhbnb58p0wi62rag9jdagjwxm6a7"; - - pkgs = (import (builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; - inherit sha256; - }) {}); +{ pkgs }: +let pythonBase = pkgs.python314; python = pythonBase.withPackages (ps: [ ps.grpcio-tools @@ -23,6 +15,7 @@ let in pkgs.mkShell { packages = [ + pkgs.bash pkgs.curl pkgs.gh pkgs.git diff --git a/scripts/update_generated_reference_prs.py b/scripts/update_generated_reference_prs.py index 5714675d2..5df8f873d 100644 --- a/scripts/update_generated_reference_prs.py +++ b/scripts/update_generated_reference_prs.py @@ -32,6 +32,21 @@ "docs-main/sdks-tools/api-reference/splice-scan-gs-connectivity-api.mdx", ) +NIX_DEVELOP_PREFIX = ( + "nix", + "--extra-experimental-features", + "nix-command flakes", + "develop", + "path:nix", + "--command", + "bash", + "-c", +) + + +def nix_develop_command(command: str) -> tuple[str, ...]: + return (*NIX_DEVELOP_PREFIX, command) + @dataclass(frozen=True) class UpdateTarget: @@ -62,7 +77,7 @@ class UpdateTarget: "package, and installer sources, then refreshes generated pages that render " "network-specific values from that data." ), - generate_commands=(("nix-shell", "--run", "npm run generate:network-variable-tabs"),), + generate_commands=(nix_develop_command("npm run generate:network-variable-tabs"),), paths=( "config/repo-version-config.json", "docs-main/snippets/generated/version-dashboard-data.mdx", @@ -77,7 +92,7 @@ class UpdateTarget: "git diff --check", ), source_update_commands=( - ("nix-shell", "--run", "npm run generate:version-compatibility-dashboard"), + nix_develop_command("npm run generate:version-compatibility-dashboard"), ), source_update_paths=( "config/repo-version-config.json", @@ -95,7 +110,7 @@ class UpdateTarget: "specifications, operation pages, history, and navigation." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:splice-mintlify-openapi"), + nix_develop_command("npm run generate:splice-mintlify-openapi"), ), paths=( "docs-main/docs.json", @@ -131,7 +146,7 @@ class UpdateTarget: "canton-network/splice release tag." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:splice-token-standard-v2-reference"), + nix_develop_command("npm run generate:splice-token-standard-v2-reference"), ), paths=( "config/x2mdx/splice-token-standard-v2/source-artifacts.json", @@ -164,7 +179,7 @@ class UpdateTarget: "OpenRPC reference pages." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:wallet-gateway-openrpc-reference"), + nix_develop_command("npm run generate:wallet-gateway-openrpc-reference"), ), paths=( "config/x2mdx/wallet-gateway-openrpc/source-artifacts.json", @@ -180,7 +195,7 @@ class UpdateTarget: "git diff --check", ), source_update_commands=( - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source wallet-gateway-openrpc"), + nix_develop_command("npm run update:generated-reference-sources -- --source wallet-gateway-openrpc"), ), source_update_paths=("config/x2mdx/wallet-gateway-openrpc/source-artifacts.json",), ), @@ -194,7 +209,7 @@ class UpdateTarget: "the checked-in OpenAPI reference." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:json-api-reference"), + nix_develop_command("npm run generate:json-api-reference"), ), paths=( "config/x2mdx/ledger-api/source-artifacts.json", @@ -211,7 +226,7 @@ class UpdateTarget: "git diff --check", ), source_update_commands=( - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source ledger-api"), + nix_develop_command("npm run update:generated-reference-sources -- --source ledger-api"), ), source_update_paths=("config/x2mdx/ledger-api/source-artifacts.json",), ), @@ -225,7 +240,7 @@ class UpdateTarget: "the checked-in AsyncAPI reference." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:json-api-asyncapi-reference"), + nix_develop_command("npm run generate:json-api-asyncapi-reference"), ), paths=( "config/x2mdx/ledger-api-asyncapi/source-artifacts.json", @@ -241,7 +256,7 @@ class UpdateTarget: "git diff --check", ), source_update_commands=( - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source ledger-api-asyncapi"), + nix_develop_command("npm run update:generated-reference-sources -- --source ledger-api-asyncapi"), ), source_update_paths=("config/x2mdx/ledger-api-asyncapi/source-artifacts.json",), ), @@ -253,7 +268,7 @@ class UpdateTarget: "Regenerates the checked-in gRPC Ledger API reference from the latest " "stable Canton protobuf release bundles selected by the existing source config." ), - generate_commands=(("nix-shell", "--run", "npm run generate:grpc-ledger-api-reference"),), + generate_commands=(nix_develop_command("npm run generate:grpc-ledger-api-reference"),), paths=( "docs-main/docs.json", "docs-main/reference/grpc-ledger-api-reference", @@ -274,7 +289,7 @@ class UpdateTarget: "Regenerates the checked-in Canton protobuf history references from the " "latest stable Canton protobuf release bundles selected by the existing source config." ), - generate_commands=(("nix-shell", "--run", "npm run generate:canton-protobuf-history"),), + generate_commands=(nix_develop_command("npm run generate:canton-protobuf-history"),), paths=( "config/x2mdx/protobuf-history/metadata.json", "docs-main/docs.json", @@ -299,7 +314,7 @@ class UpdateTarget: "Maven artifacts and regenerates the checked-in Java bindings reference pages." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:ledger-bindings-api-reference"), + nix_develop_command("npm run generate:ledger-bindings-api-reference"), ), paths=( "config/x2mdx/ledger-bindings/source-artifacts.json", @@ -316,7 +331,7 @@ class UpdateTarget: "git diff --check", ), source_update_commands=( - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source ledger-bindings"), + nix_develop_command("npm run update:generated-reference-sources -- --source ledger-bindings"), ), source_update_paths=("config/x2mdx/ledger-bindings/source-artifacts.json",), auto_merge=False, @@ -330,7 +345,7 @@ class UpdateTarget: "version and regenerates the checked-in Daml Standard Library reference pages." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:daml-standard-library-reference"), + nix_develop_command("npm run generate:daml-standard-library-reference"), ), paths=( "config/x2mdx/daml-standard-library/source-artifacts.json", @@ -346,7 +361,7 @@ class UpdateTarget: "git diff --check", ), source_update_commands=( - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source daml-standard-library"), + nix_develop_command("npm run update:generated-reference-sources -- --source daml-standard-library"), ), source_update_paths=("config/x2mdx/daml-standard-library/source-artifacts.json",), requires_daml_tooling=True, @@ -360,7 +375,7 @@ class UpdateTarget: "regenerates the checked-in Daml Script reference pages." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:daml-script-reference"), + nix_develop_command("npm run generate:daml-script-reference"), ), paths=( "config/x2mdx/daml-script/source-artifacts.json", @@ -376,7 +391,7 @@ class UpdateTarget: "git diff --check", ), source_update_commands=( - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source daml-script"), + nix_develop_command("npm run update:generated-reference-sources -- --source daml-script"), ), source_update_paths=("config/x2mdx/daml-script/source-artifacts.json",), requires_daml_tooling=True, @@ -390,7 +405,7 @@ class UpdateTarget: "releases and regenerates the checked-in TypeScript bindings reference pages." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:typescript-bindings-reference"), + nix_develop_command("npm run generate:typescript-bindings-reference"), ), paths=( "config/x2mdx/typescript-bindings/source-artifacts.json", @@ -407,7 +422,7 @@ class UpdateTarget: "git diff --check", ), source_update_commands=( - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source typescript-bindings"), + nix_develop_command("npm run update:generated-reference-sources -- --source typescript-bindings"), ), source_update_paths=("config/x2mdx/typescript-bindings/source-artifacts.json",), ), @@ -419,7 +434,7 @@ class UpdateTarget: "Regenerates the checked-in Canton console command reference from runtime " "help metadata in the latest public Canton release binary." ), - generate_commands=(("nix-shell", "--run", "npm run generate:canton-console-reference"),), + generate_commands=(nix_develop_command("npm run generate:canton-console-reference"),), paths=("docs-main/global-synchronizer/reference/canton-console-commands.mdx",), summary_kind="static", summary_path=None, @@ -437,7 +452,7 @@ class UpdateTarget: "Regenerates the checked-in Canton error-code inventory from runtime " "metadata in the latest public Canton release binary." ), - generate_commands=(("nix-shell", "--run", "npm run generate:canton-error-codes-reference"),), + generate_commands=(nix_develop_command("npm run generate:canton-error-codes-reference"),), paths=("docs-main/global-synchronizer/reference/error-codes.mdx",), summary_kind="static", summary_path=None, @@ -455,7 +470,7 @@ class UpdateTarget: "Regenerates the Canton release-to-protocol compatibility table from " "runtime metadata in the latest public Canton release binary." ), - generate_commands=(("nix-shell", "--run", "npm run generate:canton-release-protocol-versions"),), + generate_commands=(nix_develop_command("npm run generate:canton-release-protocol-versions"),), paths=("docs-main/release-notes/releases-and-versioning.mdx",), summary_kind="static", summary_path=None, @@ -473,7 +488,7 @@ class UpdateTarget: "Regenerates the checked-in Canton Metrics reference page from the latest " "Canton release documentation source." ), - generate_commands=(("nix-shell", "--run", "npm run generate:canton-metrics-reference"),), + generate_commands=(nix_develop_command("npm run generate:canton-metrics-reference"),), paths=("docs-main/global-synchronizer/reference/canton-metrics.mdx",), summary_kind="static", summary_path=None, @@ -493,8 +508,8 @@ class UpdateTarget: "protocol/protobuf compatibility table from the public release binary." ), generate_commands=( - ("nix-shell", "--run", "npm run generate:canton-topology-proto-link"), - ("nix-shell", "--run", "npm run generate:canton-topology-transaction-versions"), + nix_develop_command("npm run generate:canton-topology-proto-link"), + nix_develop_command("npm run generate:canton-topology-transaction-versions"), ), paths=( "docs-main/snippets/generated/canton-topology-proto-link.mdx", @@ -517,7 +532,7 @@ class UpdateTarget: "Updates the published Canton release-note pages from the `RELEASE-NOTES.md` " "files in stable public Canton release bundles." ), - generate_commands=(("nix-shell", "--run", "npm run update:canton-release-notes"),), + generate_commands=(nix_develop_command("npm run update:canton-release-notes"),), paths=( "docs-main/docs.json", "docs-main/global-synchronizer/release-notes", @@ -539,7 +554,7 @@ class UpdateTarget: "`@canton-network/wallet-gateway-remote` GitHub releases in " "`canton-network/wallet`." ), - generate_commands=(("nix-shell", "--run", "npm run update:release-notes -- --target wallet-gateway"),), + generate_commands=(nix_develop_command("npm run update:release-notes -- --target wallet-gateway"),), paths=( "docs-main/docs.json", "docs-main/integrations/release-notes/wallet-gateway.mdx", @@ -562,7 +577,7 @@ class UpdateTarget: "`docs/wallet-integration-guide/src/release-notes/index.rst` in " "`canton-network/wallet`." ), - generate_commands=(("nix-shell", "--run", "npm run update:release-notes -- --target wallet-sdk"),), + generate_commands=(nix_develop_command("npm run update:release-notes -- --target wallet-sdk"),), paths=( "docs-main/docs.json", "docs-main/integrations/release-notes/wallet-sdk.mdx", @@ -585,7 +600,7 @@ class UpdateTarget: "`@canton-network/dapp-sdk` GitHub releases in " "`canton-network/wallet`." ), - generate_commands=(("nix-shell", "--run", "npm run update:release-notes -- --target dapp-sdk"),), + generate_commands=(nix_develop_command("npm run update:release-notes -- --target dapp-sdk"),), paths=( "docs-main/docs.json", "docs-main/integrations/release-notes/dapp-sdk.mdx", diff --git a/tests/test_update_generated_reference_prs.py b/tests/test_update_generated_reference_prs.py index 40ec767d2..dc40c123d 100644 --- a/tests/test_update_generated_reference_prs.py +++ b/tests/test_update_generated_reference_prs.py @@ -70,15 +70,29 @@ def test_update_targets_cover_all_generated_doc_surfaces() -> None: ] +def test_update_target_commands_use_the_locked_nix_development_shell() -> None: + module = load_script_module() + + commands = ( + command + for target in module.UPDATE_TARGETS + for command in (*target.source_update_commands, *target.generate_commands) + ) + assert all( + command[: len(module.NIX_DEVELOP_PREFIX)] == module.NIX_DEVELOP_PREFIX + for command in commands + ) + + def test_dashboard_target_runs_network_variable_tabs_after_dashboard_data_generation() -> None: module = load_script_module() target = next(target for target in module.UPDATE_TARGETS if target.key == "version-dashboard") assert target.source_update_commands == ( - ("nix-shell", "--run", "npm run generate:version-compatibility-dashboard"), + module.nix_develop_command("npm run generate:version-compatibility-dashboard"), ) assert target.generate_commands == ( - ("nix-shell", "--run", "npm run generate:network-variable-tabs"), + module.nix_develop_command("npm run generate:network-variable-tabs"), ) assert target.source_update_paths == ( "config/repo-version-config.json", @@ -107,7 +121,7 @@ def test_splice_openapi_target_regenerates_without_a_source_pin() -> None: assert target.summary_kind == "static" assert target.summary_path is None assert target.generate_commands == ( - ("nix-shell", "--run", "npm run generate:splice-mintlify-openapi"), + module.nix_develop_command("npm run generate:splice-mintlify-openapi"), ) assert "config/mintlify-openapi/splice-openapi/source-artifacts.json" not in target.paths assert "docs-main/reference/splice-scan-api" in target.paths @@ -124,15 +138,17 @@ def test_generated_docs_workflow_uses_merger_app_for_pr_mutations() -> None: assert "GENERATED_DOCS_WORKFLOW_TOKEN: ${{ github.token }}" in workflow assert "uses: cachix/install-nix-action@v31" not in workflow assert "sudo apt-get" not in workflow + assert "nix-shell" not in workflow + assert 'NIX_CONFIG: "extra-experimental-features = nix-command flakes"' in workflow assert ( "run: SKIP_NPM_INSTALL=1 direnv allow . && SKIP_NPM_INSTALL=1 direnv exec . true" in workflow ) assert "python3 scripts/check_generated_docs_dependencies.py" in workflow - assert "run: SKIP_NPM_INSTALL=1 nix-shell --run 'gh auth setup-git'" in workflow + assert "run: SKIP_NPM_INSTALL=1 nix develop path:nix --command gh auth setup-git" in workflow assert 'args=(python3 scripts/update_generated_reference_prs.py --targets "${{ matrix.target }}")' in workflow assert "args+=(--dry-run)" in workflow - assert "SKIP_NPM_INSTALL=1 nix-shell --run \"$generated_docs_command\"" in workflow + assert 'SKIP_NPM_INSTALL=1 nix develop path:nix --command "${args[@]}"' in workflow def test_generated_docs_workflow_only_sets_up_daml_for_declared_targets() -> None: @@ -168,11 +184,11 @@ def test_daml_script_target_wires_source_pin_and_generated_paths() -> None: assert target.branch == "generated-references/daml-script/update" assert target.source_update_commands == ( - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source daml-script"), + module.nix_develop_command("npm run update:generated-reference-sources -- --source daml-script"), ) assert target.source_update_paths == ("config/x2mdx/daml-script/source-artifacts.json",) assert target.generate_commands == ( - ("nix-shell", "--run", "npm run generate:daml-script-reference"), + module.nix_develop_command("npm run generate:daml-script-reference"), ) assert target.paths == ( "config/x2mdx/daml-script/source-artifacts.json", @@ -215,7 +231,7 @@ def fake_run(command: tuple[str, ...]) -> None: assert calls == [ ("reset", "base-sha"), - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source daml-script"), + module.nix_develop_command("npm run update:generated-reference-sources -- --source daml-script"), ("close", "generated-references/daml-script/update"), ] assert not any("generate:daml-script-reference" in " ".join(call) for call in calls if isinstance(call, tuple)) @@ -250,7 +266,7 @@ def fake_run(command: tuple[str, ...]) -> None: assert calls == [ ("reset", "base-sha"), - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source wallet-gateway-openrpc"), + module.nix_develop_command("npm run update:generated-reference-sources -- --source wallet-gateway-openrpc"), ("close", "generated-references/wallet-gateway-openrpc/update"), ] @@ -281,7 +297,7 @@ def test_version_dashboard_skips_timestamp_only_source_changes(monkeypatch, tmp_ assert calls == [ ("reset", "base-sha"), - ("nix-shell", "--run", "npm run generate:version-compatibility-dashboard"), + module.nix_develop_command("npm run generate:version-compatibility-dashboard"), ("close", "version-dashboard/update"), ] assert not any("generate:network-variable-tabs" in " ".join(call) for call in calls) @@ -318,8 +334,8 @@ def fake_run(command: tuple[str, ...]) -> None: assert calls == [ ("reset", "base-sha"), - ("nix-shell", "--run", "npm run update:generated-reference-sources -- --source wallet-gateway-openrpc"), - ("nix-shell", "--run", "npm run generate:wallet-gateway-openrpc-reference"), + module.nix_develop_command("npm run update:generated-reference-sources -- --source wallet-gateway-openrpc"), + module.nix_develop_command("npm run generate:wallet-gateway-openrpc-reference"), ("pr", "wallet-gateway-openrpc"), ] assert body_paths @@ -587,7 +603,10 @@ def test_main_dry_run_lists_targets_without_git_or_gh(monkeypatch, capsys) -> No assert module.main() == 0 output = capsys.readouterr().out assert "version-dashboard: Update generated docs" in output - assert "source $ nix-shell --run npm run generate:version-compatibility-dashboard" in output + expected_source_command = "source $ " + " ".join( + module.nix_develop_command("npm run generate:version-compatibility-dashboard") + ) + assert expected_source_command in output assert "npm run generate:network-variable-tabs" in output