at 24.11-pre 1.9 kB view raw
1{ config, lib, pkgs, ... }: 2 3let 4 inherit (lib) last splitString mkOption types optionals; 5 6 libDir = pkgs.stdenv.hostPlatform.libDir; 7 ldsoBasename = builtins.unsafeDiscardStringContext (last (splitString "/" pkgs.stdenv.cc.bintools.dynamicLinker)); 8 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) 12in { 13 options = { 14 environment.ldso = mkOption { 15 type = types.nullOr types.path; 16 default = null; 17 description = '' 18 The executable to link into the normal FHS location of the ELF loader. 19 ''; 20 }; 21 22 environment.ldso32 = mkOption { 23 type = types.nullOr types.path; 24 default = null; 25 description = '' 26 The executable to link into the normal FHS location of the 32-bit ELF loader. 27 28 This currently only works on x86_64 architectures. 29 ''; 30 }; 31 }; 32 33 config = { 34 assertions = [ 35 { assertion = isNull config.environment.ldso32 || pkgs.stdenv.isx86_64; 36 message = "Option environment.ldso32 currently only works on x86_64."; 37 } 38 ]; 39 40 systemd.tmpfiles.rules = ( 41 if isNull config.environment.ldso then [ 42 "r /${libDir}/${ldsoBasename} - - - - -" 43 ] else [ 44 "d /${libDir} 0755 root root - -" 45 "L+ /${libDir}/${ldsoBasename} - - - - ${config.environment.ldso}" 46 ] 47 ) ++ optionals pkgs.stdenv.isx86_64 ( 48 if isNull config.environment.ldso32 then [ 49 "r /${libDir32}/${ldsoBasename32} - - - - -" 50 ] else [ 51 "d /${libDir32} 0755 root root - -" 52 "L+ /${libDir32}/${ldsoBasename32} - - - - ${config.environment.ldso32}" 53 ] 54 ); 55 }; 56 57 meta.maintainers = with lib.maintainers; [ tejing ]; 58}