This commit is contained in:
4JX
2023-01-05 00:30:04 +01:00
parent 5736cf293e
commit b41401f4a8
6 changed files with 2270 additions and 4 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake

6
.gitignore vendored
View File

@@ -1,5 +1,7 @@
target
Cargo.lock
# Cargo.lock
*.swp
.history
.vscode
.vscode
.direnv
result

2015
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -282,5 +282,5 @@ path = "tests/multipart.rs"
required-features = ["multipart"]
[patch.crates-io]
hyper = { git = "https://github.com/4JX/hyper.git", branch = "v0.14.18-patched", ref = "bd25359" }
h2 = { git = "https://github.com/4JX/h2.git", ref = "b088466" }
h2 = { git = "https://github.com/4JX/h2.git", branch = "imp" }
hyper = { git = "https://github.com/4JX/hyper.git", branch = "v0.14.18-patched" }

147
flake.lock generated Normal file
View File

@@ -0,0 +1,147 @@
{
"nodes": {
"crane": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1672813857,
"narHash": "sha256-JLDz8J8x+iWYdkqkZnI8wAPTxlXmJI7adhnGNjSDN9I=",
"owner": "ipetkov",
"repo": "crane",
"rev": "ec10516aadb705a20b043088072a556e3cb95253",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1668681692,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1672756850,
"narHash": "sha256-Smbq3+fitwA13qsTMeaaurv09/KVbZfW7m7lINwzDGA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "298add347c2bbce14020fcb54051f517c391196b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"crane": "crane",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay_2"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"crane",
"flake-utils"
],
"nixpkgs": [
"crane",
"nixpkgs"
]
},
"locked": {
"lastModified": 1672712534,
"narHash": "sha256-8S0DdMPcbITnlOu0uA81mTo3hgX84wK8S9wS34HEFY4=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "69fb7bf0a8c40e6c4c197fa1816773774c8ac59f",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"rust-overlay_2": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1672842277,
"narHash": "sha256-l69GU61eiLklfaSlDGehoh4urADHtAkyHioiQlPW2gI=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "746b57a0ad71ae5b9ed863868c5c8a56d3382213",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

101
flake.nix Normal file
View File

@@ -0,0 +1,101 @@
{
description = "Build env";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustVersion = "1.65.0";
rust = pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [
"rust-src" # rust-analyzer
];
};
nixLib = nixpkgs.lib;
craneLib = (crane.mkLib pkgs).overrideToolchain rust;
envVars = rec {
RUST_BACKTRACE = 1;
MOLD_PATH = "${pkgs.mold.out}/bin/mold";
RUSTFLAGS = "-Clink-arg=-fuse-ld=${MOLD_PATH} -Clinker=clang";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
};
# Allow more files to be included in the build workspace
workspaceSrc = ./.;
# workspaceSrcString = builtins.toString workspaceSrc;
workspaceFilter = path: type:
(craneLib.filterCargoSources path type);
# The main application derivation
reqwest-impersonate = craneLib.buildPackage
({
src = nixLib.cleanSourceWith
{
src = workspaceSrc;
filter = workspaceFilter;
};
doCheck = false;
buildInputs = with pkgs;
[
openssl
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ ];
nativeBuildInputs = with pkgs;
[
clang
pkg-config
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ ];
} // envVars);
in
{
checks = {
inherit reqwest-impersonate;
};
packages.default = reqwest-impersonate;
devShells.rust = pkgs.mkShell ({
nativeBuildInputs = [
rust
];
} // envVars);
devShells.default = reqwest-impersonate;
});
}