third_party/nix: introduce toolchain bundle

This introduces a nix derivation that builds a musl amd64/aarch64
toolchain sysroot.

Change-Id: Iba082edb8fd1f2ab580020bb1c7339a76487f3c8
Reviewed-on: https://review.monogon.dev/c/monogon/+/4006
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/third_party/nix/default.nix b/third_party/nix/default.nix
new file mode 100644
index 0000000..7688b7f
--- /dev/null
+++ b/third_party/nix/default.nix
@@ -0,0 +1,26 @@
+{ sources ? import ./sources.nix }:
+let
+  pkgs = import sources.nixpkgs
+    {
+      overlays = [
+        (self: super: {
+          qemu-minimal = import ./pkgs/qemu { pkgs = super; };
+          diffutils = import ./pkgs/diffutils { pkgs = super; };
+          util-linux-minimal = (import ./pkgs/util-linux { pkgs = super; });
+          bazel-unwrapped = import ./pkgs/bazel { pkgs = super; };
+          perl = import ./pkgs/perl { pkgs = super; };
+        })
+        (self: super: {
+          vde2 = super.vde2.overrideAttrs (oldAttrs: {
+            env.NIX_CFLAGS_COMPILE = (oldAttrs.NIX_CFLAGS_COMPILE or "") + " -Wno-error=int-conversion -Wno-error=implicit-function-declaration";
+          });
+        })
+      ];
+
+      config.replaceCrossStdenv = { buildPackages, baseStdenv }:
+        (buildPackages.withCFlags [ "-fPIC" ]) baseStdenv;
+    };
+in
+pkgs // {
+  lib.version = "${sources.nixpkgs.branch}.${sources.nixpkgs.rev}";
+}