Compare commits

...

2 Commits

Author SHA1 Message Date
ada434032b Got windows cross-compilation working
The resulting binary is still untested, but it _does_ compile!

This required re-jiggering basically everything about the nix flake,
including replacing the toolchain management to fenix.
2023-11-14 22:49:49 +01:00
4ded1c4ab4 Use builtin tokio ctrl-c rather than signal-hook-tokio
signal-hook-tokio does not support windows, and the builtin ctrl-c
function does everything domani really needs.
2023-11-11 21:39:40 +01:00
6 changed files with 238 additions and 207 deletions

99
Cargo.lock generated
View File

@ -20,6 +20,15 @@ dependencies = [
"tracing-futures", "tracing-futures",
] ]
[[package]]
name = "addr2line"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
dependencies = [
"gimli",
]
[[package]] [[package]]
name = "adler" name = "adler"
version = "1.0.2" version = "1.0.2"
@ -140,6 +149,21 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 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]] [[package]]
name = "base64" name = "base64"
version = "0.13.1" version = "0.13.1"
@ -503,7 +527,6 @@ dependencies = [
"serde_yaml", "serde_yaml",
"sha2", "sha2",
"signal-hook", "signal-hook",
"signal-hook-tokio",
"tempdir", "tempdir",
"thiserror", "thiserror",
"tls-listener", "tls-listener",
@ -808,6 +831,12 @@ dependencies = [
"wasi", "wasi",
] ]
[[package]]
name = "gimli"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]] [[package]]
name = "gix" name = "gix"
version = "0.44.1" version = "0.44.1"
@ -1570,7 +1599,7 @@ dependencies = [
"httpdate", "httpdate",
"itoa", "itoa",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2 0.4.9",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing", "tracing",
@ -1732,7 +1761,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be"
dependencies = [ dependencies = [
"socket2", "socket2 0.4.9",
"widestring", "widestring",
"winapi", "winapi",
"winreg", "winreg",
@ -1820,9 +1849,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.142" version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
@ -1941,14 +1970,13 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.6" version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
dependencies = [ dependencies = [
"libc", "libc",
"log",
"wasi", "wasi",
"windows-sys 0.45.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -2072,6 +2100,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "object"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.17.1" version = "1.17.1"
@ -2233,9 +2270,9 @@ dependencies = [
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.9" version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -2576,6 +2613,12 @@ dependencies = [
"walkdir", "walkdir",
] ]
[[package]]
name = "rustc-demangle"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.37.18" version = "0.37.18"
@ -2804,18 +2847,6 @@ dependencies = [
"libc", "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]] [[package]]
name = "slab" name = "slab"
version = "0.4.8" version = "0.4.8"
@ -2841,6 +2872,16 @@ dependencies = [
"winapi", "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]] [[package]]
name = "spin" name = "spin"
version = "0.5.2" version = "0.5.2"
@ -3005,11 +3046,11 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.28.1" version = "1.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9"
dependencies = [ dependencies = [
"autocfg", "backtrace",
"bytes", "bytes",
"libc", "libc",
"mio", "mio",
@ -3017,16 +3058,16 @@ dependencies = [
"parking_lot", "parking_lot",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"socket2", "socket2 0.5.5",
"tokio-macros", "tokio-macros",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "2.1.0" version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -20,10 +20,9 @@ serde_json = "1.0.96"
trust-dns-client = "0.22.0" trust-dns-client = "0.22.0"
mockall = "0.11.4" mockall = "0.11.4"
thiserror = "1.0.40" 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" signal-hook = "0.3.15"
futures = "0.3.28" futures = "0.3.28"
signal-hook-tokio = { version = "0.3.1", features = [ "futures-v0_3" ]}
clap = { version = "4.2.7", features = ["derive", "env"] } clap = { version = "4.2.7", features = ["derive", "env"] }
handlebars = { version = "4.3.7", features = [ "rust-embed" ]} handlebars = { version = "4.3.7", features = [ "rust-embed" ]}
rust-embed = "6.6.1" rust-embed = "6.6.1"
@ -49,4 +48,6 @@ gemini = "0.0.5"
bytes = "1.4.0" bytes = "1.4.0"
[patch.crates-io] [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" } tokio-rustls = { git = "https://code.betamike.com/micropelago/tokio-rustls.git", branch = "start-handshake-into-inner" }

View File

@ -1,26 +1,27 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "fenix": {
"inputs": { "inputs": {
"systems": "systems" "nixpkgs": "nixpkgs",
"rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1681202837, "lastModified": 1699770036,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "narHash": "sha256-bZmI7ytPAYLpyFNgj5xirDkKuAniOkj1xHdv5aIJ5GM=",
"owner": "numtide", "owner": "nix-community",
"repo": "flake-utils", "repo": "fenix",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401", "rev": "81ab0b4f7ae9ebb57daa0edf119c4891806e4d3a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "nix-community",
"repo": "flake-utils", "repo": "fenix",
"type": "github" "type": "github"
} }
}, },
"naersk": { "naersk": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1690373729, "lastModified": 1690373729,
@ -38,6 +39,22 @@
} }
}, },
"nixpkgs": { "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": { "locked": {
"lastModified": 1691003216, "lastModified": 1691003216,
"narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=", "narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=",
@ -51,7 +68,7 @@
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgs_2": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1688392541, "lastModified": 1688392541,
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
@ -67,94 +84,27 @@
"type": "github" "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": { "root": {
"inputs": { "inputs": {
"fenix": "fenix",
"naersk": "naersk", "naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay",
"utils": "utils"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_3" "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": { "locked": {
"lastModified": 1681028828, "lastModified": 1699715108,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "narHash": "sha256-yPozsobJU55gj+szgo4Lpcg1lHvGQYAT6Y4MrC80mWE=",
"owner": "nix-systems", "owner": "rust-lang",
"repo": "default", "repo": "rust-analyzer",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "rev": "5fcf5289e726785d20d3aa4d13d90a43ed248e83",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-systems", "owner": "rust-lang",
"repo": "default", "ref": "nightly",
"type": "github" "repo": "rust-analyzer",
}
},
"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",
"type": "github" "type": "github"
} }
} }

183
flake.nix
View File

@ -1,102 +1,143 @@
{ {
inputs = { inputs = {
fenix.url = "github:nix-community/fenix";
naersk.url = "github:nix-community/naersk/master"; naersk.url = "github:nix-community/naersk/master";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; 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 let
buildTargetsBySystem = { buildTargets = {
"x86_64-linux" = "x86_64-unknown-linux-musl"; "x86_64-linux" = {
"i686-linux" = "i686-unknown-linux-musl"; crossSystemConfig = "x86_64-unknown-linux-musl";
"aarch64-linux" = "aarch64-unknown-linux-musl"; rustTarget = "x86_64-unknown-linux-musl";
}; };
supportedSystems = builtins.attrNames buildTargetsBySystem; "i686-linux" = {
crossSystemConfig = "i686-unknown-linux-musl";
rustTarget = "i686-unknown-linux-musl";
};
eachCrossSystem = callback: (builtins.foldl' "aarch64-linux" = {
(overall: buildSystem: overall // { crossSystemConfig = "aarch64-unknown-linux-musl";
${buildSystem} = (builtins.foldl' rustTarget = "aarch64-unknown-linux-musl";
(inner: hostSystem: inner // { };
"cross-${hostSystem}" = callback buildSystem hostSystem;
"x86_64-windows" = {
crossSystemConfig = "x86_64-w64-mingw32";
rustTarget = "x86_64-pc-windows-gnu";
makeBuildPackageAttrs = pkgsCross: {
depsBuildBuild = [
pkgsCross.stdenv.cc
pkgsCross.windows.pthreads
];
};
};
};
# 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 [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; } { default = callback buildSystem buildSystem; }
supportedSystems supportedSystems
); );
})
{}
supportedSystems
);
mkPkgs = buildSystem: hostSystem: import nixpkgs ({ mkPkgs = buildSystem: targetSystem: import nixpkgs ({
system = buildSystem; system = buildSystem;
overlays = [ } // (if targetSystem == null then {} else {
(import rust-overlay)
(final: prev: {
rust-toolchain = prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
})
];
} // (if buildSystem == hostSystem then {} else {
# The nixpkgs cache doesn't have any packages where cross-compiling has # 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 # 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 # build platform (and therefore it's not really cross-compiling). So we
# only set up the cross-compiling config if the target platform is # only set up the cross-compiling config if the target platform is
# different. # different.
crossSystem.config = hostSystem; crossSystem.config = buildTargets.${targetSystem}.crossSystemConfig;
})); }));
mkRustEnv = crossPkgs: hostSystem: { in {
packages = eachCrossSystem
(builtins.attrNames buildTargets)
(buildSystem: targetSystem: let
pkgs = mkPkgs buildSystem null;
pkgsCross = mkPkgs buildSystem targetSystem;
rustTarget = buildTargets.${targetSystem}.rustTarget;
# 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=";
#};
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
];
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_STATIC = "1";
OPENSSL_LIB_DIR = "${crossPkgs.pkgsStatic.openssl.out}/lib"; OPENSSL_LIB_DIR = "${pkgsCross.pkgsStatic.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${crossPkgs.pkgsStatic.openssl.dev}/include"; OPENSSL_INCLUDE_DIR = "${pkgsCross.pkgsStatic.openssl.dev}/include";
CARGO_BUILD_TARGET = buildTargetsBySystem.${hostSystem};
# 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 = [ CARGO_BUILD_RUSTFLAGS = [
"-C" "target-feature=+crt-static" "-C" "target-feature=+crt-static"
"-C" "linker=${crossPkgs.stdenv.cc}/bin/${crossPkgs.stdenv.cc.targetPrefix}cc"
"-C" "link-arg=-static" "-C" "link-arg=-static"
];
};
in # https://github.com/rust-lang/cargo/issues/4133
{ "-C" "linker=${TARGET_CC}"
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)
); );
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
];
shellHook = ''
export CARGO_HOME=$(pwd)/.cargo
if [ -f "config.yml" ]; then
export DOMANI_CONFIG_PATH=config-dev.yml
fi
'';
} // rustEnv));
}; };
} }

View File

@ -4,5 +4,6 @@ components = [ "rustfmt", "rustc-dev", "clippy", "cargo" ]
targets = [ targets = [
"x86_64-unknown-linux-musl", "x86_64-unknown-linux-musl",
"i686-unknown-linux-musl", "i686-unknown-linux-musl",
"aarch64-unknown-linux-musl" "aarch64-unknown-linux-musl",
"x86_64-pc-windows-gnu"
] ]

View File

@ -1,9 +1,6 @@
#![feature(trait_upcasting)] #![feature(trait_upcasting)]
use clap::Parser; use clap::Parser;
use futures::stream::StreamExt;
use signal_hook_tokio::Signals;
use std::path; use std::path;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@ -195,18 +192,18 @@ async fn main() {
); );
} }
let mut signals = tokio::signal::ctrl_c()
Signals::new(signal_hook::consts::TERM_SIGNALS).expect("initializing signals failed"); .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 { tokio::spawn(async move {
if (signals.next().await).is_some() { tokio::signal::ctrl_c()
.await
.expect("failed to listen for kill signal");
log::warn!("Forcefully shutting down"); log::warn!("Forcefully shutting down");
std::process::exit(1); std::process::exit(1);
};
}); });
task_stack task_stack