about summary refs log tree commit diff
path: root/flake.nix
blob: 9021e966e0002583039045e754a4402e9996de5c (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs =
    { self, nixpkgs }:
    let
      systems = [
        "x86_64-linux"
        "x86_64-darwin"
        "aarch64-linux"
        "aarch64-darwin"
        "riscv64-linux"
      ];

      eachSystem =
        f:
        nixpkgs.lib.genAttrs systems (
          system:
          f {
            inherit system;
            pkgs = import nixpkgs { inherit system; };
          }
        );
    in
    {
      devShells = eachSystem (
        { system, pkgs }:
        with pkgs;
        let
          stdenv = llvmPackages.stdenv;
          shell = mkShell.override { inherit stdenv; };

          musl-src = runCommand "musl-src" { } ''
            mkdir $out
            tar -xf ${musl.src} -C $out
          '';

          musl-static = musl.overrideAttrs (attrs: {
            # this HAS the be fixed in upstream nixpkgs one day, right?
            CFLAGS = attrs.CFLAGS ++ [
              "-fdebug-prefix-map=/build=${musl-src}"
            ];
            seperateDebugInfo = false;
            dontStrip = true;
          });
        in
        {
          default = shell {
            buildInputs = [
              musl-static
            ];

            nativeBuildInputs = [
              pkg-config
              gnumake
              lldb
              llvmPackages.bintools
            ];
          };
        }
      );
    };
}