summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorAaron Janse <aaron@ajanse.me>2020-10-17 00:43:33 -0700
committerAaron Janse <aaron@ajanse.me>2020-10-17 00:43:33 -0700
commit116ac11652659c0f896fda4a2477152b92e5326a (patch)
tree280da136ebd5075e137e4314ab571aa3b66241b7 /pkgs
parente745f9333e8ccd63db4dcb7701ea362b57e410aa (diff)
downloadnixpkgs-116ac11652659c0f896fda4a2477152b92e5326a.tar
nixpkgs-116ac11652659c0f896fda4a2477152b92e5326a.tar.gz
nixpkgs-116ac11652659c0f896fda4a2477152b92e5326a.tar.bz2
nixpkgs-116ac11652659c0f896fda4a2477152b92e5326a.tar.lz
nixpkgs-116ac11652659c0f896fda4a2477152b92e5326a.tar.xz
nixpkgs-116ac11652659c0f896fda4a2477152b92e5326a.tar.zst
nixpkgs-116ac11652659c0f896fda4a2477152b92e5326a.zip
add test
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/test/default.nix2
-rw-r--r--pkgs/test/rust-sysroot/default.nix41
2 files changed, 43 insertions, 0 deletions
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index 85142090dd4..c0a810fa01a 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -35,6 +35,8 @@ with pkgs;
 
   cross = callPackage ./cross {};
 
+  rustCustomSysroot = callPackage ./rust-sysroot {};
+
   nixos-functions = callPackage ./nixos-functions {};
 
   patch-shebangs = callPackage ./patch-shebangs {};
diff --git a/pkgs/test/rust-sysroot/default.nix b/pkgs/test/rust-sysroot/default.nix
new file mode 100644
index 00000000000..c6e9ecb89d9
--- /dev/null
+++ b/pkgs/test/rust-sysroot/default.nix
@@ -0,0 +1,41 @@
+{ rustPlatform, fetchFromGitHub, writeText }:
+
+rustPlatform.buildRustPackage rec {
+    name = "blog_os-sysroot-test";
+
+    src = fetchFromGitHub {
+        owner = "phil-opp";
+        repo = "blog_os";
+        rev = "4e38e7ddf8dd021c3cd7e4609dfa01afb827797b";
+        sha256 = "0k9ipm9ddm1bad7bs7368wzzp6xwrhyfzfpckdax54l4ffqwljcg";
+    };
+
+    cargoSha256 = "1cbcplgz28yxshyrp2krp1jphbrcqdw6wxx3rry91p7hiqyibd30";
+
+    # The book uses rust-lld for linking, but rust-lld is not currently packaged for NixOS.
+    # The justification in the book for using rust-lld suggests that gcc can still be used for testing:
+    # > Instead of using the platform's default linker (which might not support Linux targets),
+    # > we use the cross platform LLD linker that is shipped with Rust for linking our kernel.
+    # https://github.com/phil-opp/blog_os/blame/7212ffaa8383122b1eb07fe1854814f99d2e1af4/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md#L157
+    target = writeText "x86_64-blog_os.json" ''
+        {
+            "llvm-target": "x86_64-unknown-none",
+            "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
+            "arch": "x86_64",
+            "target-endian": "little",
+            "target-pointer-width": "64",
+            "target-c-int-width": "32",
+            "os": "none",
+            "executables": true,
+            "linker-flavor": "gcc",
+            "panic-strategy": "abort",
+            "disable-redzone": true,
+            "features": "-mmx,-sse,+soft-float"
+        }
+    '';
+
+    RUSTFLAGS = "-C link-arg=-nostartfiles";
+
+    # Tests don't work for `no_std`. See https://os.phil-opp.com/testing/
+    doCheck = false; 
+}