summary refs log tree commit diff
path: root/nixos/tests/darling.nix
blob: 5665b4c2ffef22dbfa8e1b5c31143fa2e2a8f2da (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
40
41
42
43
44
import ./make-test-python.nix ({ pkgs, lib, ... }:

let
  # Well, we _can_ cross-compile from Linux :)
  hello = pkgs.runCommand "hello" {
    sdk = "${pkgs.darling.sdk}/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk";
    nativeBuildInputs = with pkgs.llvmPackages_14; [ clang-unwrapped lld ];
    src = pkgs.writeText "hello.c" ''
      #include <stdio.h>
      int main() {
        printf("Hello, Darling!\n");
        return 0;
      }
    '';
  } ''
    clang \
      -target x86_64-apple-darwin \
      -fuse-ld=lld \
      -nostdinc -nostdlib \
      -mmacosx-version-min=10.15 \
      --sysroot $sdk \
      -isystem $sdk/usr/include \
      -L $sdk/usr/lib -lSystem \
      $src -o $out
  '';
in
{
  name = "darling";

  meta.maintainers = with lib.maintainers; [ zhaofengli ];

  nodes.machine = {
    programs.darling.enable = true;
  };

  testScript = ''
    start_all()

    # Darling holds stdout until the server is shutdown
    machine.succeed("darling ${hello} >hello.out")
    machine.succeed("grep Hello hello.out")
    machine.succeed("darling shutdown")
  '';
})