about summary refs log tree commit diff
path: root/nixos/tests/nix-ld.nix
blob: 9b851f88617a05983210486038445b4c803c8d5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ system ? builtins.currentSystem,
  config ? {},
  pkgs ? import ../.. { inherit system config; }
}:
let
  inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
  shared =
    { config, pkgs, ... }:
    {
      programs.nix-ld.enable = true;
      environment.systemPackages = [
        (pkgs.runCommand "patched-hello" { } ''
          install -D -m755 ${pkgs.hello}/bin/hello $out/bin/hello
          patchelf $out/bin/hello --set-interpreter $(cat ${config.programs.nix-ld.package}/nix-support/ldpath)
        '')
      ];
    };
in
{
  nix-ld = makeTest {
    name = "nix-ld";
    nodes.machine = shared;
    testScript = ''
      start_all()
      machine.succeed("hello")
    '';
  };
  nix-ld-rs = makeTest {
    name = "nix-ld-rs";
    nodes.machine = {
      imports = [ shared ];
      programs.nix-ld.package = pkgs.nix-ld-rs;
    };
    testScript = ''
      start_all()
      machine.succeed("hello")
    '';
  };
}