3
0
Fork 0
forked from mirrors/nixpkgs

nixos/ldso: init module

This commit is contained in:
Jeff Huffman 2023-11-27 06:50:25 -05:00
parent 94a3c17582
commit bf6f0d3cf4
No known key found for this signature in database
GPG key ID: 7F1A93286A8960C7
3 changed files with 60 additions and 1 deletions

View file

@ -0,0 +1,58 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) last splitString mkOption types mdDoc optionals;
libDir = pkgs.stdenv.hostPlatform.libDir;
ldsoBasename = last (splitString "/" pkgs.stdenv.cc.bintools.dynamicLinker);
pkgs32 = pkgs.pkgsi686Linux;
libDir32 = pkgs32.stdenv.hostPlatform.libDir;
ldsoBasename32 = last (splitString "/" pkgs32.stdenv.cc.bintools.dynamicLinker);
in {
options = {
environment.ldso = mkOption {
type = types.nullOr types.path;
default = null;
description = mdDoc ''
The executable to link into the normal FHS location of the ELF loader.
'';
};
environment.ldso32 = mkOption {
type = types.nullOr types.path;
default = null;
description = mdDoc ''
The executable to link into the normal FHS location of the 32-bit ELF loader.
This currently only works on x86_64 architectures.
'';
};
};
config = {
assertions = [
{ assertion = isNull config.environment.ldso32 || pkgs.stdenv.isx86_64;
message = "Option environment.ldso32 currently only works on x86_64.";
}
];
systemd.tmpfiles.rules = (
if isNull config.environment.ldso then [
"r /${libDir}/${ldsoBasename} - - - - -"
] else [
"d /${libDir} 0755 root root - -"
"L+ /${libDir}/${ldsoBasename} - - - - ${config.environment.ldso}"
]
) ++ optionals pkgs.stdenv.isx86_64 (
if isNull config.environment.ldso32 then [
"r /${libDir32}/${ldsoBasename32} - - - - -"
] else [
"d /${libDir32} 0755 root root - -"
"L+ /${libDir32}/${ldsoBasename32} - - - - ${config.environment.ldso32}"
]
);
};
meta.maintainers = with lib.maintainers; [ tejing ];
}

View file

@ -12,6 +12,7 @@
./config/iproute2.nix
./config/krb5/default.nix
./config/ldap.nix
./config/ldso.nix
./config/locale.nix
./config/malloc.nix
./config/mysql.nix

View file

@ -47,7 +47,7 @@ in
};
config = lib.mkIf config.programs.nix-ld.enable {
systemd.tmpfiles.packages = [ cfg.package ];
environment.ldso = "${cfg.package}/libexec/nix-ld";
environment.systemPackages = [ nix-ld-libraries ];