Compare commits
2 Commits
023dffe70c
...
ada434032b
Author | SHA1 | Date | |
---|---|---|---|
ada434032b | |||
4ded1c4ab4 |
99
Cargo.lock
generated
99
Cargo.lock
generated
@ -20,6 +20,15 @@ dependencies = [
|
||||
"tracing-futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
@ -140,6 +149,21 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.1"
|
||||
@ -503,7 +527,6 @@ dependencies = [
|
||||
"serde_yaml",
|
||||
"sha2",
|
||||
"signal-hook",
|
||||
"signal-hook-tokio",
|
||||
"tempdir",
|
||||
"thiserror",
|
||||
"tls-listener",
|
||||
@ -808,6 +831,12 @@ dependencies = [
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
|
||||
|
||||
[[package]]
|
||||
name = "gix"
|
||||
version = "0.44.1"
|
||||
@ -1570,7 +1599,7 @@ dependencies = [
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"socket2 0.4.9",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
@ -1732,7 +1761,7 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be"
|
||||
dependencies = [
|
||||
"socket2",
|
||||
"socket2 0.4.9",
|
||||
"widestring",
|
||||
"winapi",
|
||||
"winreg",
|
||||
@ -1820,9 +1849,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.142"
|
||||
version = "0.2.150"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
|
||||
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
@ -1941,14 +1970,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.8.6"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
|
||||
checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys 0.45.0",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2072,6 +2100,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.1"
|
||||
@ -2233,9 +2270,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
@ -2576,6 +2613,12 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.37.18"
|
||||
@ -2804,18 +2847,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-tokio"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "213241f76fb1e37e27de3b6aa1b068a2c333233b59cca6634f634b80a27ecf1e"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"libc",
|
||||
"signal-hook",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.8"
|
||||
@ -2841,6 +2872,16 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
@ -3005,11 +3046,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.28.1"
|
||||
version = "1.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105"
|
||||
checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
@ -3017,16 +3058,16 @@ dependencies = [
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"socket2 0.5.5",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.1.0"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
|
||||
checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -20,10 +20,9 @@ serde_json = "1.0.96"
|
||||
trust-dns-client = "0.22.0"
|
||||
mockall = "0.11.4"
|
||||
thiserror = "1.0.40"
|
||||
tokio = { version = "1.28.1", features = [ "full", "net" ]}
|
||||
tokio = { version = "1.34.0", features = ["full", "net", "signal"] }
|
||||
signal-hook = "0.3.15"
|
||||
futures = "0.3.28"
|
||||
signal-hook-tokio = { version = "0.3.1", features = [ "futures-v0_3" ]}
|
||||
clap = { version = "4.2.7", features = ["derive", "env"] }
|
||||
handlebars = { version = "4.3.7", features = [ "rust-embed" ]}
|
||||
rust-embed = "6.6.1"
|
||||
@ -49,4 +48,6 @@ gemini = "0.0.5"
|
||||
bytes = "1.4.0"
|
||||
|
||||
[patch.crates-io]
|
||||
|
||||
# The micropelago fork of tokio-rustls allows for gemini proxying
|
||||
tokio-rustls = { git = "https://code.betamike.com/micropelago/tokio-rustls.git", branch = "start-handshake-into-inner" }
|
||||
|
128
flake.lock
128
flake.lock
@ -1,26 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"lastModified": 1699770036,
|
||||
"narHash": "sha256-bZmI7ytPAYLpyFNgj5xirDkKuAniOkj1xHdv5aIJ5GM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "81ab0b4f7ae9ebb57daa0edf119c4891806e4d3a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"naersk": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1690373729,
|
||||
@ -38,6 +39,22 @@
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1699099776,
|
||||
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1691003216,
|
||||
"narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=",
|
||||
@ -51,7 +68,7 @@
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1688392541,
|
||||
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
|
||||
@ -67,94 +84,27 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681358109,
|
||||
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"fenix": "fenix",
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1691029059,
|
||||
"narHash": "sha256-QwVeE9YTgH3LmL7yw2V/hgswL6yorIvYSp4YGI8lZYM=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "99df4908445be37ddb2d332580365fce512a7dcf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"lastModified": 1699715108,
|
||||
"narHash": "sha256-yPozsobJU55gj+szgo4Lpcg1lHvGQYAT6Y4MrC80mWE=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "5fcf5289e726785d20d3aa4d13d90a43ed248e83",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1689068808,
|
||||
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "rust-lang",
|
||||
"ref": "nightly",
|
||||
"repo": "rust-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
189
flake.nix
189
flake.nix
@ -1,102 +1,143 @@
|
||||
{
|
||||
inputs = {
|
||||
fenix.url = "github:nix-community/fenix";
|
||||
naersk.url = "github:nix-community/naersk/master";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
|
||||
outputs = { self, nixpkgs, naersk, fenix }:
|
||||
let
|
||||
buildTargetsBySystem = {
|
||||
"x86_64-linux" = "x86_64-unknown-linux-musl";
|
||||
"i686-linux" = "i686-unknown-linux-musl";
|
||||
"aarch64-linux" = "aarch64-unknown-linux-musl";
|
||||
buildTargets = {
|
||||
"x86_64-linux" = {
|
||||
crossSystemConfig = "x86_64-unknown-linux-musl";
|
||||
rustTarget = "x86_64-unknown-linux-musl";
|
||||
};
|
||||
|
||||
"i686-linux" = {
|
||||
crossSystemConfig = "i686-unknown-linux-musl";
|
||||
rustTarget = "i686-unknown-linux-musl";
|
||||
};
|
||||
|
||||
"aarch64-linux" = {
|
||||
crossSystemConfig = "aarch64-unknown-linux-musl";
|
||||
rustTarget = "aarch64-unknown-linux-musl";
|
||||
};
|
||||
|
||||
"x86_64-windows" = {
|
||||
crossSystemConfig = "x86_64-w64-mingw32";
|
||||
rustTarget = "x86_64-pc-windows-gnu";
|
||||
makeBuildPackageAttrs = pkgsCross: {
|
||||
depsBuildBuild = [
|
||||
pkgsCross.stdenv.cc
|
||||
pkgsCross.windows.pthreads
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
supportedSystems = builtins.attrNames buildTargetsBySystem;
|
||||
# eachSystem [system] (system: ...)
|
||||
#
|
||||
# Returns an attrset with a key for every system in the given array, with
|
||||
# the key's value being the result of calling the callback with that key.
|
||||
eachSystem = supportedSystems: callback: builtins.foldl'
|
||||
(overall: system: overall // { ${system} = callback system; })
|
||||
{}
|
||||
supportedSystems;
|
||||
|
||||
eachCrossSystem = callback: (builtins.foldl'
|
||||
(overall: buildSystem: overall // {
|
||||
${buildSystem} = (builtins.foldl'
|
||||
(inner: hostSystem: inner // {
|
||||
"cross-${hostSystem}" = callback buildSystem hostSystem;
|
||||
# eachCrossSystem [system] (buildSystem: targetSystem: ...)
|
||||
#
|
||||
# Returns an attrset with a key "$buildSystem.cross-$targetSystem" for
|
||||
# every combination of the elements of the array of system strings. The
|
||||
# value of the attrs will be the result of calling the callback with each
|
||||
# combination.
|
||||
#
|
||||
# There will also be keys "$system.default", which are aliases of
|
||||
# "$system.cross-$system" for every system.
|
||||
#
|
||||
eachCrossSystem = supportedSystems: callback:
|
||||
eachSystem supportedSystems (buildSystem: builtins.foldl'
|
||||
(inner: targetSystem: inner // {
|
||||
"cross-${targetSystem}" = callback buildSystem targetSystem;
|
||||
})
|
||||
{ default = callback buildSystem buildSystem; }
|
||||
supportedSystems
|
||||
);
|
||||
})
|
||||
{}
|
||||
supportedSystems
|
||||
);
|
||||
);
|
||||
|
||||
mkPkgs = buildSystem: hostSystem: import nixpkgs ({
|
||||
mkPkgs = buildSystem: targetSystem: import nixpkgs ({
|
||||
system = buildSystem;
|
||||
overlays = [
|
||||
(import rust-overlay)
|
||||
(final: prev: {
|
||||
rust-toolchain = prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
})
|
||||
];
|
||||
} // (if buildSystem == hostSystem then {} else {
|
||||
} // (if targetSystem == null then {} else {
|
||||
# The nixpkgs cache doesn't have any packages where cross-compiling has
|
||||
# been enabled, even if the target platform is actually the same as the
|
||||
# build platform (and therefore it's not really cross-compiling). So we
|
||||
# only set up the cross-compiling config if the target platform is
|
||||
# different.
|
||||
crossSystem.config = hostSystem;
|
||||
crossSystem.config = buildTargets.${targetSystem}.crossSystemConfig;
|
||||
}));
|
||||
|
||||
mkRustEnv = crossPkgs: hostSystem: {
|
||||
OPENSSL_STATIC = "1";
|
||||
OPENSSL_LIB_DIR = "${crossPkgs.pkgsStatic.openssl.out}/lib";
|
||||
OPENSSL_INCLUDE_DIR = "${crossPkgs.pkgsStatic.openssl.dev}/include";
|
||||
CARGO_BUILD_TARGET = buildTargetsBySystem.${hostSystem};
|
||||
CARGO_BUILD_RUSTFLAGS = [
|
||||
"-C" "target-feature=+crt-static"
|
||||
"-C" "linker=${crossPkgs.stdenv.cc}/bin/${crossPkgs.stdenv.cc.targetPrefix}cc"
|
||||
"-C" "link-arg=-static"
|
||||
];
|
||||
};
|
||||
in {
|
||||
packages = eachCrossSystem
|
||||
(builtins.attrNames buildTargets)
|
||||
(buildSystem: targetSystem: let
|
||||
pkgs = mkPkgs buildSystem null;
|
||||
pkgsCross = mkPkgs buildSystem targetSystem;
|
||||
rustTarget = buildTargets.${targetSystem}.rustTarget;
|
||||
|
||||
in
|
||||
{
|
||||
packages = eachCrossSystem (buildSystem: hostSystem: let
|
||||
pkgs = mkPkgs buildSystem buildSystem;
|
||||
crossPkgs = mkPkgs buildSystem hostSystem;
|
||||
naersk-lib = pkgs.callPackage naersk {
|
||||
cargo = pkgs.rust-toolchain;
|
||||
rustc = pkgs.rust-toolchain;
|
||||
};
|
||||
rustEnv = mkRustEnv crossPkgs hostSystem;
|
||||
in
|
||||
naersk-lib.buildPackage ({
|
||||
src = ./.;
|
||||
doCheck = false;
|
||||
nativeBuildInputs = [ crossPkgs.pkgsStatic.stdenv.cc ];
|
||||
} // rustEnv)
|
||||
);
|
||||
# TODO I'd prefer to use the toolchain file
|
||||
# https://github.com/nix-community/fenix/issues/123
|
||||
#toolchain = fenix.packages.${buildSystem}.fromToolchainFile {
|
||||
# file = ./rust-toolchain.toml;
|
||||
# sha256 = "sha256-LU4C/i+maIOqBZagUaXpFyWZyOVfQ3Ah5/JTz7v6CG4=";
|
||||
#};
|
||||
|
||||
devShells = eachCrossSystem (buildSystem: hostSystem: let
|
||||
pkgs = mkPkgs buildSystem buildSystem;
|
||||
crossPkgs = mkPkgs buildSystem hostSystem;
|
||||
rustEnv = mkRustEnv crossPkgs hostSystem;
|
||||
in
|
||||
pkgs.mkShell ({
|
||||
nativeBuildInputs = [
|
||||
crossPkgs.stdenv.cc
|
||||
crossPkgs.openssl
|
||||
pkgs.nmap # ncat
|
||||
pkgs.rust-toolchain
|
||||
fenixPkgs = fenix.packages.${buildSystem};
|
||||
|
||||
mkToolchain = fenixPkgs: fenixPkgs.toolchainOf {
|
||||
channel = "nightly";
|
||||
date = "2023-07-23";
|
||||
sha256 = "sha256-LU4C/i+maIOqBZagUaXpFyWZyOVfQ3Ah5/JTz7v6CG4=";
|
||||
};
|
||||
|
||||
toolchain = fenixPkgs.combine [
|
||||
(mkToolchain fenixPkgs).rustc
|
||||
(mkToolchain fenixPkgs).cargo
|
||||
(mkToolchain fenixPkgs.targets.${rustTarget}).rust-std
|
||||
];
|
||||
shellHook = ''
|
||||
export CARGO_HOME=$(pwd)/.cargo
|
||||
|
||||
if [ -f "config.yml" ]; then
|
||||
export DOMANI_CONFIG_PATH=config-dev.yml
|
||||
fi
|
||||
'';
|
||||
} // rustEnv));
|
||||
buildPackageAttrs = if
|
||||
builtins.hasAttr "makeBuildPackageAttrs" buildTargets.${targetSystem}
|
||||
then
|
||||
buildTargets.${targetSystem}.makeBuildPackageAttrs pkgsCross
|
||||
else
|
||||
{};
|
||||
|
||||
naersk-lib = pkgs.callPackage naersk {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
|
||||
in
|
||||
naersk-lib.buildPackage (buildPackageAttrs // rec {
|
||||
src = ./.;
|
||||
strictDeps = true;
|
||||
doCheck = false;
|
||||
|
||||
OPENSSL_STATIC = "1";
|
||||
OPENSSL_LIB_DIR = "${pkgsCross.pkgsStatic.openssl.out}/lib";
|
||||
OPENSSL_INCLUDE_DIR = "${pkgsCross.pkgsStatic.openssl.dev}/include";
|
||||
|
||||
# Required because ring crate is special. This also seems to have
|
||||
# fixed some issues with the x86_64-windows cross-compile :shrug:
|
||||
TARGET_CC="${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
|
||||
|
||||
CARGO_BUILD_TARGET = rustTarget;
|
||||
CARGO_BUILD_RUSTFLAGS = [
|
||||
"-C" "target-feature=+crt-static"
|
||||
"-C" "link-arg=-static"
|
||||
|
||||
# https://github.com/rust-lang/cargo/issues/4133
|
||||
"-C" "linker=${TARGET_CC}"
|
||||
];
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -4,5 +4,6 @@ components = [ "rustfmt", "rustc-dev", "clippy", "cargo" ]
|
||||
targets = [
|
||||
"x86_64-unknown-linux-musl",
|
||||
"i686-unknown-linux-musl",
|
||||
"aarch64-unknown-linux-musl"
|
||||
"aarch64-unknown-linux-musl",
|
||||
"x86_64-pc-windows-gnu"
|
||||
]
|
||||
|
21
src/main.rs
21
src/main.rs
@ -1,9 +1,6 @@
|
||||
#![feature(trait_upcasting)]
|
||||
|
||||
use clap::Parser;
|
||||
use futures::stream::StreamExt;
|
||||
use signal_hook_tokio::Signals;
|
||||
|
||||
use std::path;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
@ -195,18 +192,18 @@ async fn main() {
|
||||
);
|
||||
}
|
||||
|
||||
let mut signals =
|
||||
Signals::new(signal_hook::consts::TERM_SIGNALS).expect("initializing signals failed");
|
||||
tokio::signal::ctrl_c()
|
||||
.await
|
||||
.expect("failed to listen for kill signal");
|
||||
|
||||
if (signals.next().await).is_some() {
|
||||
log::info!("Gracefully shutting down...");
|
||||
}
|
||||
log::info!("Gracefully shutting down...");
|
||||
|
||||
tokio::spawn(async move {
|
||||
if (signals.next().await).is_some() {
|
||||
log::warn!("Forcefully shutting down");
|
||||
std::process::exit(1);
|
||||
};
|
||||
tokio::signal::ctrl_c()
|
||||
.await
|
||||
.expect("failed to listen for kill signal");
|
||||
log::warn!("Forcefully shutting down");
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
||||
task_stack
|
||||
|
Loading…
Reference in New Issue
Block a user