From c18190fd697d731b04407e449b0c00119f6e966f Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 24 Feb 2023 06:44:45 +0200 Subject: [PATCH 1/2] stdenv: run toString on lists in env to allow lists in env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit will make appending to lists in env in overrideAttrs more ergonomic due to no longer needing to add spaces manually ``` nix-repl> keepassxc.NIX_CFLAGS_COMPILE "-Wno-old-style-cast -Wno-error -D__BIG_ENDIAN__=0" nix-repl> (keepassxc.overrideAttrs(oA: { passthru.oA = oA; })).oA.env.NIX_CFLAGS_COMPILE [ "-Wno-old-style-cast" "-Wno-error" "-D__BIG_ENDIAN__=0" ] nix-repl> (keepassxc.overrideAttrs(oA: { passthru.oA = oA; })).oA.NIX_CFLAGS_COMPILE error: … while evaluating the attribute 'oA.NIX_CFLAGS_COMPILE' at «string»:1:32: 1| (keepassxc.overrideAttrs(oA: { passthru.oA = oA; })).oA.NIX_CFLAGS_COMPILE | ^ error: attribute 'NIX_CFLAGS_COMPILE' missing at «string»:1:1: 1| (keepassxc.overrideAttrs(oA: { passthru.oA = oA; })).oA.NIX_CFLAGS_COMPILE | ^ ``` --- pkgs/stdenv/generic/make-derivation.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 3d60934557c6a..fc36edf9ee419 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -537,8 +537,8 @@ else let assert lib.assertMsg (overlappingNames == [ ]) "The ‘env’ attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping: ${lib.concatStringsSep ", " overlappingNames}"; lib.mapAttrs - (n: v: assert lib.assertMsg (lib.isString v || lib.isBool v || lib.isInt v || lib.isDerivation v) - "The ‘env’ attribute set can only contain derivation, string, boolean or integer attributes. The ‘${n}’ attribute is of type ${builtins.typeOf v}."; v) + (n: v: assert lib.assertMsg (lib.isString v || lib.isBool v || lib.isInt v || lib.isDerivation v || lib.isList v) + "The ‘env’ attribute set can only contain derivation, list, string, boolean or integer attributes. The ‘${n}’ attribute is of type ${builtins.typeOf v}."; (if lib.isList v then toString v else v)) env; in From b4137846afe51eb478353923f44c638fef8d16b3 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 24 Feb 2023 06:50:55 +0200 Subject: [PATCH 2/2] show that it works keepassxc> cc1: warning: command-line option '-Wno-old-style-cast' is valid for C++/ObjC++ but not for C declare -x NIX_CFLAGS_COMPILE="..." --- pkgs/applications/misc/keepassxc/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/misc/keepassxc/default.nix b/pkgs/applications/misc/keepassxc/default.nix index 1870c21bed136..998b4836e9756 100644 --- a/pkgs/applications/misc/keepassxc/default.nix +++ b/pkgs/applications/misc/keepassxc/default.nix @@ -49,12 +49,17 @@ stdenv.mkDerivation rec { sha256 = "sha256-amedKK9nplLVJTldeabN3/c+g/QesrdH+qx+rba2/4s="; }; - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang [ + __structuredAttrs = true; + env.NIX_CFLAGS_COMPILE = lib.optionals true [ "-Wno-old-style-cast" "-Wno-error" "-D__BIG_ENDIAN__=${if stdenv.isBigEndian then "1" else "0"}" ]; + postConfigure = '' + typeset -p NIX_CFLAGS_COMPILE + ''; + NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-rpath ${libargon2}/lib"; patches = [