From c0de6131584582470781c4b3ff37550a99dce96c Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Mon, 21 Feb 2022 17:37:20 +0400 Subject: [PATCH] Add bash to #! line for python wrapper in nixpkgs Leverage makeScriptWriter from nixpkgs that includes fix NixOS/nixpkgs#93757 for macOS compatibility. Fixes #186 --- .github/workflows/workflow.yaml | 2 -- nixpkgs/nixpkgs.bzl | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 15fc47c8a..cd692a14d 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -64,8 +64,6 @@ jobs: without_nix=( cc go rust ) if [ "${{ runner.os }}" == "macOS" ]; then - # Python - https://github.com/tweag/rules_nixpkgs/issues/186 - skip with_nix python # Rust - https://github.com/tweag/rules_nixpkgs/issues/187 skip with_nix rust skip without_nix rust diff --git a/nixpkgs/nixpkgs.bzl b/nixpkgs/nixpkgs.bzl index 061170e67..903631e8e 100644 --- a/nixpkgs/nixpkgs.bzl +++ b/nixpkgs/nixpkgs.bzl @@ -1053,16 +1053,15 @@ _nixpkgs_python_toolchain = repository_rule( ) def _python_nix_file_content(attribute_path, bin_path, version): - if versions.is_at_least("4.2.0", versions.get()): - stub_shebang = """stub_shebang = "#!${{{attribute_path}}}/{bin_path}",""".format( - attribute_path = attribute_path, - bin_path = bin_path, - ) - else: - stub_shebang = "" + add_shebang = versions.is_at_least("4.2.0", versions.get()) return """ with import {{ config = {{}}; overlays = []; }}; +let + addShebang = {add_shebang}; + interpreterPath = "${{{attribute_path}}}/{bin_path}"; + shebangLine = interpreter: writers.makeScriptWriter {{ inherit interpreter; }} "shebang" ""; +in runCommand "bazel-nixpkgs-python-toolchain" {{ executable = false; # Pointless to do this on a remote machine. @@ -1076,17 +1075,19 @@ runCommand "bazel-nixpkgs-python-toolchain" cat >>$n <