1 { config, lib, pkgs, ... }:
4 inherit (lib) last splitString mkOption types optionals;
6 libDir = pkgs.stdenv.hostPlatform.libDir;
7 ldsoBasename = builtins.unsafeDiscardStringContext (last (splitString "/" pkgs.stdenv.cc.bintools.dynamicLinker));
9 # Hard-code to avoid creating another instance of nixpkgs. Also avoids eval errors in some cases.
10 libDir32 = "lib"; # pkgs.pkgsi686Linux.stdenv.hostPlatform.libDir
11 ldsoBasename32 = "ld-linux.so.2"; # last (splitString "/" pkgs.pkgsi686Linux.stdenv.cc.bintools.dynamicLinker)
14 environment.ldso = mkOption {
15 type = types.nullOr types.path;
18 The executable to link into the normal FHS location of the ELF loader.
22 environment.ldso32 = mkOption {
23 type = types.nullOr types.path;
26 The executable to link into the normal FHS location of the 32-bit ELF loader.
28 This currently only works on x86_64 architectures.
35 { assertion = isNull config.environment.ldso32 || pkgs.stdenv.hostPlatform.isx86_64;
36 message = "Option environment.ldso32 currently only works on x86_64.";
40 systemd.tmpfiles.rules = (
41 if isNull config.environment.ldso then [
42 "r /${libDir}/${ldsoBasename} - - - - -"
44 "d /${libDir} 0755 root root - -"
45 "L+ /${libDir}/${ldsoBasename} - - - - ${config.environment.ldso}"
47 ) ++ optionals pkgs.stdenv.hostPlatform.isx86_64 (
48 if isNull config.environment.ldso32 then [
49 "r /${libDir32}/${ldsoBasename32} - - - - -"
51 "d /${libDir32} 0755 root root - -"
52 "L+ /${libDir32}/${ldsoBasename32} - - - - ${config.environment.ldso32}"
57 meta.maintainers = with lib.maintainers; [ tejing ];