The indentation stripping semantics of strings are fairly bad and have a
few gotchas where the resulting string has not the intended indentation.
This commit fixes most if not all such instances in Nixpkgs.
I tried to strive a balance between keeping the diff small and
reformatting/refactoring the code to look better. In general,
reformatting should be left to Nixfmt.
Note that this causes a lot of rebuilds by design. All changes need to
be thoroughly vetted and reviewed for correctness. There is no automatic
way to prove correctness.
List of files to fix generated by running
https://gerrit.lix.systems/c/lix/+/2092 on Nixpkgs and looking at the
warnings.
In preparation for the deprecation of `stdenv.isX`.
These shorthands are not conducive to cross-compilation because they
hide the platforms.
Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way
One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059
There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.
```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
Re-roll of https://github.com/NixOS/nixpkgs/pull/328907, but this time
adding the patch from ArchLinux, which keeps both EGL and GLX code paths
active.
Remove overrides where EGL was explicitly requested previously, as well
as the glew-egl package variant.
Add an alias for glew-egl, in case there's any users of this outside
of nixpkgs.
`SDL_VIDEODRIVER=wayland` seems to be a requirement for GLEW to
initialize when using glew-egl.
`SDL_VIDEO_WAYLAND_WMCLASS` associates the application with the .desktop
file (in GNOME Shell, at least, if not other Wayland desktops).
glew alone is not enough to propagate explicitly:
```
$ nix run nixpkgs#mindustry
[E] Failed to initialize discord. Enable debug logging for details.
[E] java.lang.ExceptionInInitializerError
at arc.backend.sdl.SdlApplication.lambda$init$0(SdlApplication.java:73)
at arc.backend.sdl.SdlApplication.check(SdlApplication.java:181)
at arc.backend.sdl.SdlApplication.init(SdlApplication.java:73)
at arc.backend.sdl.SdlApplication.<init>(SdlApplication.java:29)
at mindustry.desktop.DesktopLauncher.main(DesktopLauncher.java:36)
Caused by: arc.util.ArcRuntimeException: Couldn't load shared library 'libsdl-arc64.so' for target: Linux, 64-bit
at arc.util.SharedLibraryLoader.load(SharedLibraryLoader.java:85)
at arc.backend.sdl.jni.SDL.<clinit>(SDL.java:142)
... 5 more
Caused by: arc.util.ArcRuntimeException: java.lang.UnsatisfiedLinkError: /tmp/arc/35a2b27b/libsdl-arc64.so: /nix/store/v8pdm5rd4f89ng08zgxryyil065g1dh2-SDL2-2.0.20/lib/libSDL2.so: cannot open shared object file: No such file or directory
at arc.util.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:288)
at arc.util.SharedLibraryLoader.load(SharedLibraryLoader.java:81)
... 6 more
Caused by: java.lang.UnsatisfiedLinkError: /tmp/arc/35a2b27b/libsdl-arc64.so: /nix/store/v8pdm5rd4f89ng08zgxryyil065g1dh2-SDL2-2.0.20/lib/libSDL2.so: cannot open shared object file: No such file or directory
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2407)
at java.base/java.lang.Runtime.load0(Runtime.java:747)
at java.base/java.lang.System.load(System.java:1857)
at arc.util.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:294)
at arc.backend.sdl.jni.SDL$3.loadFile(SDL.java:140)
at arc.util.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:260)
... 7 more
```
Let's add all SDL and alsa-lib as well. Instead of using propagatedBuildInputs
let's embed store paths into a shell wrapper.
The Mindustry source code makes heavy use of internal Java APIs that
were deprecated in Java 6 and removed in Java 16. It also makes use
of features that require Java >=14.
The author is not ready to provide compatibility with any
maintained Java version at this time.
- make pre- and post-{build,install} phases usable for the main derivation
- replace uses of stdenv.lib with just lib
- specify which buildInputs are only needed for the client
- reduce the buildPhase of the fixed-output dependencies derivation to
only download all dependencies, instead of building the full thing.
- add wayland variant, which is linked against a different variant of
the glew library to run natively using SDL_VIDEODRIVER=wayland
- use jdk (Java 15) instead of jre (Java 8) at runtime
- use new copyDesktopItems hook
* update two explicit references to jdk14 to just jdk, which no longer
points at jdk8 after #89731.
* patch an explicit -XX:+UseConcMarkSweepGC to -XX:UseG1GC, as the
former now throws an error (after having been deprecated since jdk 9)