diff --git a/nixpkgs/BUILD.bazel b/nixpkgs/BUILD.bazel index 8aedcbe72..ab0bf9bca 100644 --- a/nixpkgs/BUILD.bazel +++ b/nixpkgs/BUILD.bazel @@ -44,6 +44,7 @@ bzl_library( "@rules_nixpkgs_cc//:cc.bzl", "@rules_nixpkgs_java//:java.bzl", "@rules_nixpkgs_python//:python.bzl", + "@rules_nixpkgs_posix//:posix.bzl", ":bazel_tools", "@bazel_skylib//lib:new_sets", "@bazel_skylib//lib:paths", diff --git a/nixpkgs/nixpkgs.bzl b/nixpkgs/nixpkgs.bzl index 6fadcf584..e66c60e8c 100644 --- a/nixpkgs/nixpkgs.bzl +++ b/nixpkgs/nixpkgs.bzl @@ -29,6 +29,10 @@ load( "@rules_nixpkgs_cc//:cc.bzl", _nixpkgs_cc_configure = "nixpkgs_cc_configure", ) +load( + "@rules_nixpkgs_posix//:posix.bzl", + _nixpkgs_sh_posix_configure = "nixpkgs_sh_posix_configure", +) # aliases for backwards compatibility prior to `bzlmod` nixpkgs_git_repository = _nixpkgs_git_repository @@ -37,6 +41,7 @@ nixpkgs_package = _nixpkgs_package nixpkgs_python_configure = _nixpkgs_python_configure nixpkgs_java_configure = _nixpkgs_java_configure nixpkgs_cc_configure = _nixpkgs_cc_configure +nixpkgs_sh_posix_configure = _nixpkgs_sh_posix_configure def nixpkgs_cc_autoconf_impl(repository_ctx): cpu_value = get_cpu_value(repository_ctx) @@ -178,155 +183,3 @@ def nixpkgs_cc_configure_deprecated( nixpkgs_cc_autoconf(name = "local_config_cc") native.bind(name = "cc_toolchain", actual = "@local_config_cc//:toolchain") native.register_toolchains("@local_config_cc//:all") - -def nixpkgs_sh_posix_config(name, packages, **kwargs): - nixpkgs_package( - name = name, - nix_file_content = """ -with import {{ config = {{}}; overlays = []; }}; - -let - # `packages` might include lists, e.g. `stdenv.initialPath` is a list itself, - # so we need to flatten `packages`. - flatten = builtins.concatMap (x: if builtins.isList x then x else [x]); - env = buildEnv {{ - name = "posix-toolchain"; - paths = flatten [ {} ]; - }}; - cmd_glob = "${{env}}/bin/*"; - os = if stdenv.isDarwin then "osx" else "linux"; -in - -runCommand "bazel-nixpkgs-posix-toolchain" - {{ executable = false; - # Pointless to do this on a remote machine. - preferLocalBuild = true; - allowSubstitutes = false; - }} - '' - n=$out/nixpkgs_sh_posix.bzl - mkdir -p "$(dirname "$n")" - - cat >>$n <>$n - fi - done - cat >>$n < {{ config = {{}}; overlays = []; }}; + +let + # `packages` might include lists, e.g. `stdenv.initialPath` is a list itself, + # so we need to flatten `packages`. + flatten = builtins.concatMap (x: if builtins.isList x then x else [x]); + env = buildEnv {{ + name = "posix-toolchain"; + paths = flatten [ {} ]; + }}; + cmd_glob = "${{env}}/bin/*"; + os = if stdenv.isDarwin then "osx" else "linux"; +in + +runCommand "bazel-nixpkgs-posix-toolchain" + {{ executable = false; + # Pointless to do this on a remote machine. + preferLocalBuild = true; + allowSubstitutes = false; + }} + '' + n=$out/nixpkgs_sh_posix.bzl + mkdir -p "$(dirname "$n")" + + cat >>$n <>$n + fi + done + cat >>$n <