<commit_before># Model for NixOS packaging script.
#
# After https://eipi.xyz/blog/packaging-a-rust-project-for-nix/
# Run `nix-build` to build
#
# The cargoSha256 will get invalidated whenever new commits are made, running
# nix-build will give you an error message that contains the correct hash,
# replace value with that, then re-run nix-build.
#
# Use `src = ./.` instead of `src = fetchFromGithub { ... }` to build from
# local sources. Having build artifacts (`target/` directory) in the local
# directory seems to mess up `nix-build`, so do a `git clean -fdx` or clone a
# fresh instance repository before trying this.

with import <nixpkgs> { };

rustPlatform.buildRustPackage rec {
  name = "magog-${version}";
  version = "0.1.0";

  src = fetchFromGitHub {
    owner = "rsaarelm";
    repo = "magog";

    # TODO: Start using release versions when we have them.
    # Now just using an arbitrary master commit from when this script was
    # being set up.
    rev = "fa716ed154937b641a22fdc0c6366b1a4ace279c";
    # rev = "${version}";

    sha256 = "0z7ddzpibs5cgk3ijd6zhcyngkb0bfp7zfv4ykw1b2yhm4pi8vf0";
  };

  buildInputs = [ openssl pkgconfig zlib gcc cmake ];

  checkPhase = "cargo test --all";
  cargoSha256 = "sha256:0z54m1xnzfhgh8b6cscdp8dm036g39lwnnmrlv4vcxrvbp3x0ndw";

  # Binary size optimization
  prePatch = ''
    cat >> Cargo.toml << EOF
    [profile.release]
    lto = true
    codegen-units = 1
    panic = 'abort'
    EOF
  '';

  meta = with stdenv.lib; {
    description = "A fantasy roguelike game";
    homepage = https://github.com/rsaarelm/magog;
    license = licenses.agpl3;
    platforms = platforms.all;
  };
}<commit_msg>Generate dynamic linking path in NixOS install<commit_after># Model for NixOS packaging script.
#
# After https://eipi.xyz/blog/packaging-a-rust-project-for-nix/
# Run `nix-build` to build
#
# The cargoSha256 will get invalidated whenever new commits are made, running
# nix-build will give you an error message that contains the correct hash,
# replace value with that, then re-run nix-build.
#
# Use `src = ./.` instead of `src = fetchFromGithub { ... }` to build from
# local sources. Having build artifacts (`target/` directory) in the local
# directory seems to mess up `nix-build`, so do a `git clean -fdx` or clone a
# fresh instance repository before trying this.

with import <nixpkgs> { };

let
    rpath = with pkgs.xlibs; lib.makeLibraryPath
      [ pkgs.libGL libX11 libXcursor libXxf86vm libXi libXrandr vulkan-loader ];
in
rustPlatform.buildRustPackage rec {
  name = "magog-${version}";
  version = "0.1.0";

  src = fetchFromGitHub {
    owner = "rsaarelm";
    repo = "magog";

    # TODO: Start using release versions when we have them.
    # Now just using an arbitrary master commit from when this script was
    # being set up.
    rev = "fa716ed154937b641a22fdc0c6366b1a4ace279c";
    # rev = "${version}";

    sha256 = "0z7ddzpibs5cgk3ijd6zhcyngkb0bfp7zfv4ykw1b2yhm4pi8vf0";
  };

  buildInputs = [ openssl pkgconfig zlib gcc cmake makeWrapper x11 libGL ];

  cargoSha256 = "sha256:0z54m1xnzfhgh8b6cscdp8dm036g39lwnnmrlv4vcxrvbp3x0ndw";

  # Binary size optimization
  prePatch = ''
    cat >> Cargo.toml << EOF
    [profile.release]
    lto = true
    codegen-units = 1
    panic = 'abort'
    EOF
  '';

  # Binary wants to link dynamically to X11 libs, generate wrapper.
  postInstall = ''
    wrapProgram $out/bin/magog --prefix LD_LIBRARY_PATH : "${rpath}"
  '';

  meta = with stdenv.lib; {
    description = "A fantasy roguelike game";
    homepage = https://github.com/rsaarelm/magog;
    license = licenses.agpl3;
    platforms = platforms.all;
  };
}
{'fraction_non_alphanumeric': 0.10657534246575343, 'fraction_numerical': 0.04, 'mean_word_length': 3.452439024390244, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, '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': '2296796', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1275, 'n_words': 370}