Skip to content

Commit

Permalink
partially revert NixOS#269551
Browse files Browse the repository at this point in the history
Remove the `environment.ldso32` option until it can be better thought
out.

The option creates a new instance of nixpkgs and doesn't work on all
architectures.

Fixes:

    error: i686 Linux package set can only be used with the x86 family.
  • Loading branch information
zimbatm committed Feb 13, 2024
1 parent d934204 commit a98e860
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 46 deletions.
31 changes: 4 additions & 27 deletions nixos/modules/config/ldso.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ let

libDir = pkgs.stdenv.hostPlatform.libDir;
ldsoBasename = builtins.unsafeDiscardStringContext (last (splitString "/" pkgs.stdenv.cc.bintools.dynamicLinker));

pkgs32 = pkgs.pkgsi686Linux;
libDir32 = pkgs32.stdenv.hostPlatform.libDir;
ldsoBasename32 = builtins.unsafeDiscardStringContext (last (splitString "/" pkgs32.stdenv.cc.bintools.dynamicLinker));
in {
imports = [
(lib.mkRemovedOptionModule ["environment" "ldso32"] "removed as it didn't work on all architectures")
];

options = {
environment.ldso = mkOption {
type = types.nullOr types.path;
Expand All @@ -18,39 +18,16 @@ in {
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}"
]
);
};

Expand Down
4 changes: 0 additions & 4 deletions nixos/modules/config/stub-ld.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ let
$CC -Os main.c -o $out
'';

pkgs32 = pkgs.pkgsi686Linux;

stub-ld = stub-ld-for pkgs message;
stub-ld32 = stub-ld-for pkgs32 message;
in {
options = {
environment.stub-ld = {
Expand All @@ -49,7 +46,6 @@ in {

config = mkIf cfg.enable {
environment.ldso = mkDefault stub-ld;
environment.ldso32 = mkIf pkgs.stdenv.isx86_64 (mkDefault stub-ld32);
};

meta.maintainers = with lib.maintainers; [ tejing ];
Expand Down
15 changes: 0 additions & 15 deletions nixos/tests/stub-ld.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
libDir = pkgs.stdenv.hostPlatform.libDir;
ldsoBasename = lib.last (lib.splitString "/" pkgs.stdenv.cc.bintools.dynamicLinker);

check32 = pkgs.stdenv.isx86_64;
pkgs32 = pkgs.pkgsi686Linux;

libDir32 = pkgs32.stdenv.hostPlatform.libDir;
ldsoBasename32 = lib.last (lib.splitString "/" pkgs32.stdenv.cc.bintools.dynamicLinker);

test-exec = builtins.mapAttrs (n: v: pkgs.runCommand "test-exec-${n}" { src = pkgs.fetchurl v; } "mkdir -p $out;cd $out;tar -xzf $src") {
x86_64-linux.url = "https://github.com/rustic-rs/rustic/releases/download/v0.6.1/rustic-v0.6.1-x86_64-unknown-linux-gnu.tar.gz";
x86_64-linux.hash = "sha256-3zySzx8MKFprMOi++yr2ZGASE0aRfXHQuG3SN+kWUCI=";
Expand All @@ -33,41 +27,32 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
aarch64-linux.hash = "sha256-hnldbd2cctQIAhIKoEZLIWY8H3jiFBClkNy2UlyyvAs=";
};
exec-name = "rustic";

if32 = pythonStatement: if check32 then pythonStatement else "pass";
in
''
machine.start()
machine.wait_for_unit("multi-user.target")
with subtest("Check for stub (enabled, initial)"):
machine.succeed('test -L /${libDir}/${ldsoBasename}')
${if32 "machine.succeed('test -L /${libDir32}/${ldsoBasename32}')"}
with subtest("Try FHS executable"):
machine.copy_from_host('${test-exec.${pkgs.system}}','test-exec')
machine.succeed('if test-exec/${exec-name} 2>outfile; then false; else [ $? -eq 127 ];fi')
machine.succeed('grep -qi nixos outfile')
${if32 "machine.copy_from_host('${test-exec.${pkgs32.system}}','test-exec32')"}
${if32 "machine.succeed('if test-exec32/${exec-name} 2>outfile32; then false; else [ $? -eq 127 ];fi')"}
${if32 "machine.succeed('grep -qi nixos outfile32')"}
with subtest("Disable stub"):
machine.succeed("/run/booted-system/specialisation/nostub/bin/switch-to-configuration test")
with subtest("Check for stub (disabled)"):
machine.fail('test -e /${libDir}/${ldsoBasename}')
${if32 "machine.fail('test -e /${libDir32}/${ldsoBasename32}')"}
with subtest("Create file in stub location (to be overwritten)"):
machine.succeed('mkdir -p /${libDir};touch /${libDir}/${ldsoBasename}')
${if32 "machine.succeed('mkdir -p /${libDir32};touch /${libDir32}/${ldsoBasename32}')"}
with subtest("Re-enable stub"):
machine.succeed("/run/booted-system/bin/switch-to-configuration test")
with subtest("Check for stub (enabled, final)"):
machine.succeed('test -L /${libDir}/${ldsoBasename}')
${if32 "machine.succeed('test -L /${libDir32}/${ldsoBasename32}')"}
'';
})

0 comments on commit a98e860

Please sign in to comment.