diff --git a/src/ariadne/BUILD b/src/ariadne/BUILD index cc4bfff..e40b023 100644 --- a/src/ariadne/BUILD +++ b/src/ariadne/BUILD @@ -1,4 +1,5 @@ sh_binary( name = "extract_and_decompile", srcs = ["extract-and-decompile.sh"], + data = ["extract-tools.nix"], ) diff --git a/src/ariadne/README.md b/src/ariadne/README.md index 1075ba1..1d25d73 100644 --- a/src/ariadne/README.md +++ b/src/ariadne/README.md @@ -18,7 +18,7 @@ The script defaults to `/src/ariadne/output`. This path stays stable when you run the command from inside `src/ariadne`. Use the game installation directory as the game root. One run processes all installed season directories. -If `rpycdec` is not available, the script re-runs itself inside a Nix shell. +If `rpycdec` is not available, the script uses `extract-tools.nix` to enter a Nix shell. Keep the script as a thin orchestration layer. Bazel owns stable inputs and wrappers. diff --git a/src/ariadne/extract-and-decompile.sh b/src/ariadne/extract-and-decompile.sh index 5788541..0249baa 100755 --- a/src/ariadne/extract-and-decompile.sh +++ b/src/ariadne/extract-and-decompile.sh @@ -46,45 +46,20 @@ enter_nix_shell_if_needed() { require_tool nix - local rpycdec_installable - rpycdec_installable=$(cat <<'NIX' -let - pkgs = import (builtins.getFlake "nixpkgs") { system = builtins.currentSystem; }; - rpycdec = pkgs.python3Packages.buildPythonApplication { - pname = "rpycdec"; - version = "0.0.0+1000bd1"; - pyproject = true; - src = pkgs.fetchFromGitHub { - owner = "cnfatal"; - repo = "rpycdec"; - rev = "1000bd1da10ef07e82f6fa560c621e6a4b55d1b8"; - hash = "sha256-VoVbIKs8xz5x2s0OGqdHbY55fWDruqMAX8YYjEQhwTQ="; - }; - nativeBuildInputs = with pkgs.python3Packages; [ - hatch-vcs - hatchling - ]; - env.SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RPYCDEC = "0.0.0+1000bd1"; - }; -in - pkgs.buildEnv { - name = "ariadne-extract-and-decompile-tools"; - paths = [ - pkgs.bash - pkgs.coreutils - pkgs.findutils - rpycdec - ]; - } -NIX -) + local tools_nix + if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then + tools_nix=$BUILD_WORKSPACE_DIRECTORY/src/ariadne/extract-tools.nix + else + tools_nix=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/extract-tools.nix + fi + + [[ -f "$tools_nix" ]] || fail "missing Ariadne tool definition: $tools_nix" say "entering Nix shell for rpycdec" export ARIADNE_NIX_SHELL=1 exec nix shell \ --extra-experimental-features 'nix-command flakes' \ - --impure \ - --expr "$rpycdec_installable" \ + --file "$tools_nix" \ --command bash "$0" "$@" } diff --git a/src/ariadne/extract-tools.nix b/src/ariadne/extract-tools.nix new file mode 100644 index 0000000..70bd6b9 --- /dev/null +++ b/src/ariadne/extract-tools.nix @@ -0,0 +1,28 @@ +let + pkgs = import (builtins.getFlake "nixpkgs") { system = builtins.currentSystem; }; + rpycdec = pkgs.python3Packages.buildPythonApplication { + pname = "rpycdec"; + version = "0.0.0+1000bd1"; + pyproject = true; + src = pkgs.fetchFromGitHub { + owner = "cnfatal"; + repo = "rpycdec"; + rev = "1000bd1da10ef07e82f6fa560c621e6a4b55d1b8"; + hash = "sha256-VoVbIKs8xz5x2s0OGqdHbY55fWDruqMAX8YYjEQhwTQ="; + }; + nativeBuildInputs = with pkgs.python3Packages; [ + hatch-vcs + hatchling + ]; + env.SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RPYCDEC = "0.0.0+1000bd1"; + }; +in +pkgs.buildEnv { + name = "ariadne-extract-and-decompile-tools"; + paths = [ + pkgs.bash + pkgs.coreutils + pkgs.findutils + rpycdec + ]; +}