mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 00:43:20 +00:00
e0464e4788
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" ```
59 lines
1.9 KiB
Nix
59 lines
1.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) last splitString mkOption types optionals;
|
|
|
|
libDir = pkgs.stdenv.hostPlatform.libDir;
|
|
ldsoBasename = builtins.unsafeDiscardStringContext (last (splitString "/" pkgs.stdenv.cc.bintools.dynamicLinker));
|
|
|
|
# Hard-code to avoid creating another instance of nixpkgs. Also avoids eval errors in some cases.
|
|
libDir32 = "lib"; # pkgs.pkgsi686Linux.stdenv.hostPlatform.libDir
|
|
ldsoBasename32 = "ld-linux.so.2"; # last (splitString "/" pkgs.pkgsi686Linux.stdenv.cc.bintools.dynamicLinker)
|
|
in {
|
|
options = {
|
|
environment.ldso = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
description = ''
|
|
The executable to link into the normal FHS location of the ELF loader.
|
|
'';
|
|
};
|
|
|
|
environment.ldso32 = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
description = ''
|
|
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.hostPlatform.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.hostPlatform.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 ];
|
|
}
|