From c5b7122b31c7f976b302fab94557c955bd99b11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Wed, 18 Mar 2026 12:24:55 +0100 Subject: [PATCH] Properly determine paths when cross-compiling --- pkgs/nix-portable/default.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/nix-portable/default.nix b/pkgs/nix-portable/default.nix index 45a09a60..7d9c372c 100644 --- a/pkgs/nix-portable/default.nix +++ b/pkgs/nix-portable/default.nix @@ -19,6 +19,16 @@ with builtins; compression ? "zstd -19 -T0", lib ? pkgs.lib, pkgs ? import {}, + + # pkgs set from the host system (just for eval in installDynamic) + pkgsHost ? + if stdenv.hostPlatform == stdenv.buildPlatform then + pkgs + else + import pkgs.path { + system = pkgs.stdenv.hostPlatform.system; + }, + # hardcode executable to run. Useful when creating a bundle. bundledPackage ? null, @@ -86,9 +96,9 @@ let ''; installDynamic = pkgname: let - out = pkgs.${pkgname}.out; + out = builtins.unsafeDiscardStringContext pkgsHost.${pkgname}.out.outPath; in '' - if [ ! -e \$store${lib.removePrefix "/nix/store" pkgs.${pkgname}.out} ] ; then + if [ ! -e \$store${lib.removePrefix "/nix/store" out} ] ; then debug "Installing ${pkgname}" \$run \$store${lib.removePrefix "/nix/store" nix}/bin/nix build --impure --no-link --expr " (import ${nixpkgsSrc} {}).${pkgname}.out @@ -254,7 +264,7 @@ let fi # Override $SHELL with nix bashInteractive - export SHELL="${pkgs.bashInteractive.out}/bin/bash" + export SHELL="${builtins.unsafeDiscardStringContext pkgsHost.bashInteractive.out.outPath}/bin/bash" export PS1="\n\[\033[1;32m\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\$\[\033[0m\] " # unset bash function aliases