rmlint: fix NIX_* environment propagations to scons

scons build system does not work by default in nixpkgs envoironment as
it filters system environment and throws away NIX_* flags:

    https://scons.org/doc/2.1.0/HTML/scons-user/x1750.html

Fix build system to always propagate os.environment. Drop the
workarounds that pass subset of the variables through.
This commit is contained in:
Sergei Trofimovich 2023-01-27 19:08:46 +00:00
parent 92b7725154
commit f6647dfd94
2 changed files with 25 additions and 3 deletions

View file

@ -31,6 +31,11 @@ stdenv.mkDerivation rec {
sha256 = "15xfkcw1bkfyf3z8kl23k3rlv702m0h7ghqxvhniynvlwbgh6j2x";
};
patches = [
# pass through NIX_* environment variables to scons.
./scons-nix-env.patch
];
nativeBuildInputs = [
pkg-config
sphinx
@ -56,9 +61,6 @@ stdenv.mkDerivation rec {
];
prePatch = ''
export CFLAGS="$NIX_CFLAGS_COMPILE"
export LDFLAGS="''${NIX_LDFLAGS//-rpath /-Wl,-rpath=}"
# remove sources of nondeterminism
substituteInPlace lib/cmdline.c \
--replace "__DATE__" "\"Jan 1 1970\"" \
@ -67,6 +69,7 @@ stdenv.mkDerivation rec {
--replace "gzip -c " "gzip -cn "
'';
# Otherwise tries to access /usr.
prefixKey = "--prefix=";
sconsFlags = lib.optionals (!withGui) [ "--without-gui" ];

View file

@ -0,0 +1,19 @@
scons does not use os environment by default:
https://scons.org/doc/2.1.0/HTML/scons-user/x1750.html
nixpkgs' cc-wrapper on the other hand relies on various NIX_* variables
to be passed through like NIX_CFLAGS_COMPILE_BEFORE.
--- a/SConstruct
+++ b/SConstruct
@@ -559,10 +559,7 @@ options = dict(
SHLINKCOMSTR=link_shared_library_message,
LINKCOMSTR=link_program_message,
PREFIX=GetOption('prefix'),
- ENV = dict([ (key, os.environ[key])
- for key in os.environ
- if key in ['PATH', 'TERM', 'HOME', 'PKG_CONFIG_PATH']
- ])
+ ENV = os.environ,
)
if ARGUMENTS.get('VERBOSE') == "1":