diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-06-16 06:56:35 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-06-16 06:56:35 +0000 |
commit | 99fcaeccb89621dd492203ce1f2d551c06f228ed (patch) | |
tree | 41cb730ae07383004789779b0f6e11cb3f4642a3 /nixpkgs/pkgs/development/tools/simavr | |
parent | 59c5f5ac8682acc13bb22bc29c7cf02f7d75f01f (diff) | |
parent | 75a5ebf473cd60148ba9aec0d219f72e5cf52519 (diff) | |
download | nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.gz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.bz2 nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.lz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.xz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.zst nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.zip |
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/nixos/modules/config/console.nix nixpkgs/nixos/modules/services/mail/mailman.nix nixpkgs/nixos/modules/services/mail/public-inbox.nix nixpkgs/nixos/modules/services/mail/rss2email.nix nixpkgs/nixos/modules/services/networking/ssh/sshd.nix nixpkgs/pkgs/applications/networking/instant-messengers/dino/default.nix nixpkgs/pkgs/applications/networking/irc/weechat/default.nix nixpkgs/pkgs/applications/window-managers/sway/default.nix nixpkgs/pkgs/build-support/go/module.nix nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix nixpkgs/pkgs/development/interpreters/python/default.nix nixpkgs/pkgs/development/node-packages/overrides.nix nixpkgs/pkgs/development/tools/b4/default.nix nixpkgs/pkgs/servers/dict/dictd-db.nix nixpkgs/pkgs/servers/mail/public-inbox/default.nix nixpkgs/pkgs/tools/security/pinentry/default.nix nixpkgs/pkgs/tools/text/unoconv/default.nix nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/pkgs/development/tools/simavr')
-rw-r--r-- | nixpkgs/pkgs/development/tools/simavr/default.nix | 18 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/tools/simavr/setup-hook-darwin.sh | 34 |
2 files changed, 46 insertions, 6 deletions
diff --git a/nixpkgs/pkgs/development/tools/simavr/default.nix b/nixpkgs/pkgs/development/tools/simavr/default.nix index 8aa9ccd5388a..11b146e55c5e 100644 --- a/nixpkgs/pkgs/development/tools/simavr/default.nix +++ b/nixpkgs/pkgs/development/tools/simavr/default.nix @@ -1,9 +1,17 @@ -{ lib, stdenv, fetchFromGitHub, libelf, which, pkg-config, freeglut +{ lib, stdenv, makeSetupHook, fetchFromGitHub, libelf, which, pkg-config, freeglut , avrgcc, avrlibc , libGLU, libGL , GLUT }: -stdenv.mkDerivation rec { +let + setupHookDarwin = makeSetupHook { + name = "darwin-avr-gcc-hook"; + substitutions = { + darwinSuffixSalt = stdenv.cc.suffixSalt; + avrSuffixSalt = avrgcc.suffixSalt; + }; + } ./setup-hook-darwin.sh; +in stdenv.mkDerivation rec { pname = "simavr"; version = "1.7"; @@ -22,9 +30,8 @@ stdenv.mkDerivation rec { "AVR=avr-" ]; - NIX_CFLAGS_COMPILE = [ "-Wno-error=stringop-truncation" ]; - - nativeBuildInputs = [ which pkg-config avrgcc ]; + nativeBuildInputs = [ which pkg-config avrgcc ] + ++ lib.optional stdenv.isDarwin setupHookDarwin; buildInputs = [ libelf freeglut libGLU libGL ] ++ lib.optional stdenv.isDarwin GLUT; @@ -35,7 +42,6 @@ stdenv.mkDerivation rec { checkTarget = "-C tests run_tests"; meta = with lib; { - broken = stdenv.isDarwin; description = "A lean and mean Atmel AVR simulator"; homepage = "https://github.com/buserror/simavr"; license = licenses.gpl3; diff --git a/nixpkgs/pkgs/development/tools/simavr/setup-hook-darwin.sh b/nixpkgs/pkgs/development/tools/simavr/setup-hook-darwin.sh new file mode 100644 index 000000000000..3861e45973ac --- /dev/null +++ b/nixpkgs/pkgs/development/tools/simavr/setup-hook-darwin.sh @@ -0,0 +1,34 @@ + +fixupCFlagsForDarwin() { + # Because it’s getting called from a Darwin stdenv, avr-gcc will pick up on + # Darwin-specific flags, and it will barf and die on -iframework in + # particular. Strip them out, so simavr can compile its test firmware. + cflagsFilter='s|-F[^ ]*||g;s|-iframework [^ ]*||g;s|-isystem [^ ]*||g;s| *| |g' + + # The `CoreFoundation` reference is added by `linkSystemCoreFoundationFramework` in the + # Apple SDK’s setup hook. Remove that because avr-gcc will fail due to file not found. + ldFlagsFilter='s|/nix/store/[^-]*-apple-framework-CoreFoundation[^ ]*||g' + + # `cc-wrapper.sh`` supports getting flags from a system-specific salt. While it is currently a + # tuple, that’s not considered a stable interface, so the derivation will provide them. + export NIX_CFLAGS_COMPILE_@darwinSuffixSalt@=${NIX_CFLAGS_COMPILE-} + export NIX_LDFLAGS_@darwinSuffixSalt@=${NIX_LDFLAGS-} + + echo removing @darwinSuffixSalt@-specific flags from NIX_CFLAGS_COMPILE for @avrSuffixSalt@ + export NIX_CFLAGS_COMPILE_@avrSuffixSalt@+="$(sed "$cflagsFilter" <<< "$NIX_CFLAGS_COMPILE")" + echo removing @darwinSuffixSalt@-specific flags from NIX_LDFLAGS for @avrSuffixSalt@ + export NIX_LDFLAGS_@avrSuffixSalt@+="$(sed "$ldFlagsFilter;$cflagsFilter" <<< "$NIX_LDFLAGS")" + + # Make sure the global flags aren’t accidentally influencing the platform-specific flags. + export NIX_CFLAGS_COMPILE="" + export NIX_LDFLAGS="" +} + +# This is pretty hacky, but this hook _must_ run after `linkSystemCoreFoundationFramework`. +function runFixupCFlagsForDarwinLast() { + preConfigureHooks+=(fixupCFlagsForDarwin) +} + +if [ -z "${dontFixupCFlagsForDarwin-}" ]; then + postUnpackHooks+=(runFixupCFlagsForDarwinLast) +fi |