<commit_before>{ pkgs ? (
  let
    nixpkgs = import <nixpkgs>;
    pkgs_ = (nixpkgs {});
    rustOverlay = (pkgs_.fetchFromGitHub {
      owner = "mozilla";
      repo = "nixpkgs-mozilla";
      rev = "e2a920faec5a9ebd6ff34abf072aacb4e0ed6f70";
      sha256 = "1lq7zg388y4wrbl165wraji9dmlb8rkjaiam9bq28n3ynsp4b6fz";
    });
  in (nixpkgs {
    overlays = [
      (import (builtins.toPath "${rustOverlay}/rust-overlay.nix"))
      (self: super:
       with super;
       let nightly = lib.rustLib.fromManifest (lib.rustLib.manifest_v2_url {
                       channel = "nightly";
                       date = "2017-03-21";
                     }) {
                       inherit (self) stdenv fetchurl patchelf;
                     };
           rustc_ = nightly.rustc;
           cargo_ = nightly.cargo;
           rust-src_ = nightly.rust-src;
       in {
        rust = {
          rustc = rustc_;
          cargo = cargo_;
          rust-src = rust-src_;
        };
      })
    ];
  }))
}:

with pkgs;

let

x86_64-target-spec = stdenv.mkDerivation {
  name = "target-spec";
  src = ./x86_64.json;
  phases = [ "buildPhase" ];
  buildPhase = ''
    mkdir -p $out
    cp $src $out/x86_64.json
  '';
};

libcore = stdenv.mkDerivation {
  name = "libcore";
  buildInputs = [
    rust.rustc
  ];
  phases = [ "buildPhase" ];
  buildPhase = ''
    mkdir -p $out
    rustc --target=${x86_64-target-spec}/x86_64.json --out-dir=$out --crate-type=lib ${rust.rust-src}/lib/rustlib/src/rust/src/libcore/lib.rs
  '';
};

liballoc = stdenv.mkDerivation {
  name = "liballoc";
  buildInputs = [
    rust.rustc
  ];
  phases = [ "buildPhase" ];
  buildPhase = ''
    mkdir -p $out
    rustc -L ${libcore} --target=${x86_64-target-spec}/x86_64.json --out-dir=$out --crate-type=lib ${rust.rust-src}/lib/rustlib/src/rust/src/liballoc/lib.rs
  '';
};

triple = "x86_64-none-elf";

userspace-linker = stdenv.mkDerivation {
  name = "userspace-linker.ld";
  phases = [ "buildPhase" ];
  buildPhase = ''
    cat <<EOT > $out
    ENTRY(start)
    OUTPUT_FORMAT(elf64-x86-64)
    EOT
  '';
};

in stdenv.mkDerivation {
  name = "rux-env";
  buildInputs = [
    gnumake
    (binutils.override { cross = { config = triple; }; })
    qemu
    file
    gdb
    rust.rustc
    rust.cargo
    curl
  ];

  ARCH = "x86_64";
  RUST_SRC = "${rust.rust-src}";
  TARGET_SPEC = "${x86_64-target-spec}/x86_64.json";
  USERSPACE_LINKER = "${userspace-linker}";

  LIBCORE = "${libcore}";<commit_msg>Make the derivative called linker.ld<commit_after>{ pkgs ? (
  let
    nixpkgs = import <nixpkgs>;
    pkgs_ = (nixpkgs {});
    rustOverlay = (pkgs_.fetchFromGitHub {
      owner = "mozilla";
      repo = "nixpkgs-mozilla";
      rev = "e2a920faec5a9ebd6ff34abf072aacb4e0ed6f70";
      sha256 = "1lq7zg388y4wrbl165wraji9dmlb8rkjaiam9bq28n3ynsp4b6fz";
    });
  in (nixpkgs {
    overlays = [
      (import (builtins.toPath "${rustOverlay}/rust-overlay.nix"))
      (self: super:
       with super;
       let nightly = lib.rustLib.fromManifest (lib.rustLib.manifest_v2_url {
                       channel = "nightly";
                       date = "2017-03-21";
                     }) {
                       inherit (self) stdenv fetchurl patchelf;
                     };
           rustc_ = nightly.rustc;
           cargo_ = nightly.cargo;
           rust-src_ = nightly.rust-src;
       in {
        rust = {
          rustc = rustc_;
          cargo = cargo_;
          rust-src = rust-src_;
        };
      })
    ];
  }))
}:

with pkgs;

let

x86_64-target-spec = stdenv.mkDerivation {
  name = "target-spec";
  src = ./x86_64.json;
  phases = [ "buildPhase" ];
  buildPhase = ''
    mkdir -p $out
    cp $src $out/x86_64.json
  '';
};

libcore = stdenv.mkDerivation {
  name = "libcore";
  buildInputs = [
    rust.rustc
  ];
  phases = [ "buildPhase" ];
  buildPhase = ''
    mkdir -p $out
    rustc --target=${x86_64-target-spec}/x86_64.json --out-dir=$out --crate-type=lib ${rust.rust-src}/lib/rustlib/src/rust/src/libcore/lib.rs
  '';
};

liballoc = stdenv.mkDerivation {
  name = "liballoc";
  buildInputs = [
    rust.rustc
  ];
  phases = [ "buildPhase" ];
  buildPhase = ''
    mkdir -p $out
    rustc -L ${libcore} --target=${x86_64-target-spec}/x86_64.json --out-dir=$out --crate-type=lib ${rust.rust-src}/lib/rustlib/src/rust/src/liballoc/lib.rs
  '';
};

triple = "x86_64-none-elf";

userspace-linker = stdenv.mkDerivation {
  name = "userspace-linker";
  phases = [ "buildPhase" ];
  buildPhase = ''
    mkdir -p $out
    cat <<EOT > $out/linker.ld
    ENTRY(start)
    OUTPUT_FORMAT(elf64-x86-64)
    EOT
  '';
};

in stdenv.mkDerivation {
  name = "rux-env";
  buildInputs = [
    gnumake
    (binutils.override { cross = { config = triple; }; })
    qemu
    file
    gdb
    rust.rustc
    rust.cargo
    curl
  ];

  ARCH = "x86_64";
  RUST_SRC = "${rust.rust-src}";
  TARGET_SPEC = "${x86_64-target-spec}/x86_64.json";
  USERSPACE_LINKER = "${userspace-linker}/linker.ld";

  LIBCORE = "${libcore}";
{'fraction_non_alphanumeric': 0.15381542149420696, 'fraction_numerical': 0.03835397522972433, 'mean_word_length': 2.1709943001899936, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7264655', 'n_tokens_mistral': 2061, 'n_tokens_neox': 1938, 'n_words': 306}