Add a nix-ld aspect for foreign binaries and AppImages
Move programs.nix-ld out of the core aspect into modules/dev/nix-ld.nix and extend the library set (on top of the module defaults) with the runtime libraries that prebuilt binaries commonly link or dlopen: C++ runtime, compression and crypto, GL/Vulkan/Wayland, audio, fonts, GTK and Electron-style helpers, and the X11 client libraries. Enable programs.appimage with binfmt so .AppImage files run directly through appimage-run. Import the aspect from the desktop host and document it in the README. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JZ16yf4acmaSiHq81vyQ6Z
This commit is contained in:
4 files changed
+134
-6
No files matched your search
@@ -46,9 +46,6 @@ in
|
||||
enable = true;
|
||||
flake = "/home/${owner.name}/nixos-config";
|
||||
};
|
||||
|
||||
# Lets prebuilt binaries (editors' language servers, game launchers) run.
|
||||
nix-ld.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
# Foreign binaries: programs built for ordinary Linux distributions (prebuilt
|
||||
# tools, language servers, npm/pip native modules, game launchers, AppImages)
|
||||
# expect /lib64/ld-linux-x86-64.so.2 and libraries in /usr/lib, neither of
|
||||
# which exists on NixOS. Two mechanisms cover that:
|
||||
#
|
||||
# - nix-ld puts a stub dynamic linker at the standard path. The stub reads
|
||||
# NIX_LD (the real linker) and NIX_LD_LIBRARY_PATH (the library directory
|
||||
# built from `programs.nix-ld.libraries`), both exported to every session,
|
||||
# and starts the program with them. A plain ELF binary then just runs. If it
|
||||
# stops with "error while loading shared libraries: libfoo.so.N", find the
|
||||
# nixpkgs package that ships that library (search.nixos.org), add it to the
|
||||
# list below and switch.
|
||||
# - AppImages bundle most of their libraries and want FUSE. appimage-run runs
|
||||
# them in an FHS environment of its own, and the binfmt registration makes
|
||||
# `./Some.AppImage` work directly. nix-ld is not involved there; to give
|
||||
# every AppImage an extra library set
|
||||
# `programs.appimage.package = pkgs.appimage-run.override { extraPkgs = pkgs: [ ... ]; };`.
|
||||
#
|
||||
# The module's own defaults (zlib, zstd, stdenv.cc.cc, curl, openssl, attr,
|
||||
# libssh, bzip2, libxml2, acl, libsodium, util-linux, xz, systemd) stay; the
|
||||
# list is merged with them. The ones repeated below are the base every
|
||||
# foreign binary needs, kept explicit so they survive a change of the defaults.
|
||||
# No whole desktop stacks (Qt, Electron) here: an app that needs one ships it
|
||||
# or gets a package of its own.
|
||||
{
|
||||
flake.modules.nixos.nix-ld =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
programs.nix-ld = {
|
||||
enable = true;
|
||||
libraries = with pkgs; [
|
||||
# C/C++ runtime (libstdc++, libgcc_s), compression, crypto, text.
|
||||
stdenv.cc.cc.lib
|
||||
zlib
|
||||
zstd
|
||||
bzip2
|
||||
xz
|
||||
openssl
|
||||
curl
|
||||
expat
|
||||
icu
|
||||
libxml2
|
||||
libxslt
|
||||
sqlite
|
||||
libffi
|
||||
ncurses
|
||||
libxcrypt-legacy # libcrypt.so.1, which older binaries still link
|
||||
libunwind
|
||||
libsecret
|
||||
libusb1
|
||||
util-linux # libuuid, libmount, libblkid
|
||||
systemd # libudev, libsystemd
|
||||
|
||||
# Graphics: OpenGL, EGL, Vulkan, hardware video, Wayland.
|
||||
libGL
|
||||
libGLU
|
||||
mesa
|
||||
libgbm
|
||||
libdrm
|
||||
vulkan-loader
|
||||
libva
|
||||
libvdpau
|
||||
wayland
|
||||
libxkbcommon
|
||||
|
||||
# Audio.
|
||||
alsa-lib
|
||||
libpulseaudio
|
||||
pipewire
|
||||
SDL2
|
||||
|
||||
# Fonts and images.
|
||||
fontconfig
|
||||
freetype
|
||||
harfbuzz
|
||||
libpng
|
||||
libjpeg
|
||||
|
||||
# GTK and the pieces Electron/Chromium-style apps dlopen.
|
||||
glib
|
||||
gtk3
|
||||
gdk-pixbuf
|
||||
pango
|
||||
cairo
|
||||
at-spi2-core # also ships libatk and libatk-bridge
|
||||
cups
|
||||
dbus
|
||||
nspr
|
||||
nss
|
||||
libnotify
|
||||
libappindicator
|
||||
libayatana-appindicator
|
||||
|
||||
# X11 client libraries (XWayland keeps X11-only binaries working).
|
||||
libx11
|
||||
libxcomposite
|
||||
libxcursor
|
||||
libxdamage
|
||||
libxext
|
||||
libxfixes
|
||||
libxi
|
||||
libxrandr
|
||||
libxrender
|
||||
libxscrnsaver
|
||||
libxtst
|
||||
libxcb
|
||||
libxxf86vm
|
||||
libxshmfence
|
||||
];
|
||||
};
|
||||
|
||||
# `appimage-run` plus the binfmt hooks for AppImage type 1 and 2; the
|
||||
# module also enables FUSE.
|
||||
programs.appimage = {
|
||||
enable = true;
|
||||
binfmt = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -28,6 +28,7 @@ in
|
||||
proxy-suite
|
||||
docker
|
||||
gitea-runner
|
||||
nix-ld
|
||||
];
|
||||
|
||||
# The owner's own programs (home-manager only). A dynamic attribute such
|
||||
|
||||
Reference in new issue
Block a user