Compare commits

...

7 commits

Author SHA1 Message Date
asonix 9b4c62dd59 Update flake.lock
Some checks failed
continuous-integration/drone/push Build is failing
2023-11-19 14:51:29 -06:00
asonix 8981d99e89 Strip binaries
Some checks failed
continuous-integration/drone/push Build is failing
2023-11-19 14:02:14 -06:00
asonix ca3f34cdac remove protobuf, simplify CC variables 2023-11-19 14:00:13 -06:00
asonix 01ad4c7453 Fix mold setup 2023-11-19 14:00:13 -06:00
asonix 8d62d35c1b Override optimization levels 2023-11-19 14:00:12 -06:00
asonix e214c81ae5 link with mold 2023-11-19 13:59:40 -06:00
asonix 5ea26bfc20 preprare nightly cross-compile environment 2023-11-19 13:59:39 -06:00
6 changed files with 338 additions and 56 deletions

202
Cargo.lock generated
View file

@ -466,6 +466,43 @@ dependencies = [
"bytes",
]
[[package]]
name = "c-gull"
version = "0.15.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16db458286db3b6e1657f54edb6112122eb59d12e658be45e0ae164da82319c8"
dependencies = [
"c-scape",
"errno",
"libc",
"printf-compat",
"rustix",
"tz-rs",
]
[[package]]
name = "c-scape"
version = "0.15.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "054a3095b1264c87499e52d2b87ffe260deec4d2298be4d00763ee71bb7aef41"
dependencies = [
"bitflags 2.4.1",
"errno",
"libc",
"libm",
"memoffset",
"origin",
"rand",
"rand_core",
"rand_pcg",
"realpath-ext",
"rustix",
"rustix-dlmalloc",
"rustix-futex-sync",
"rustix-openpty",
"unwinding",
]
[[package]]
name = "cc"
version = "1.0.83"
@ -690,6 +727,22 @@ dependencies = [
"typenum",
]
[[package]]
name = "cstr_core"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd98742e4fdca832d40cab219dc2e3048de17d873248f83f17df47c1bea70956"
dependencies = [
"cty",
"memchr",
]
[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]]
name = "dashmap"
version = "5.5.3"
@ -843,6 +896,25 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e"
dependencies = [
"libc",
"windows-sys",
]
[[package]]
name = "eyra"
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c142c64e0117d284b72c30b126dce72bbb85b21a5b6d84e823a6b74c6f0723e"
dependencies = [
"c-gull",
]
[[package]]
name = "eyre"
version = "0.6.8"
@ -1260,6 +1332,15 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.10.5"
@ -1311,12 +1392,24 @@ version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "libm"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
[[package]]
name = "local-channel"
version = "0.1.5"
@ -1652,6 +1745,20 @@ dependencies = [
"num-traits",
]
[[package]]
name = "origin"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5ec3dcf976d221ecd72070fc76a8a8bc7de6cef95559b7be77579697408c5e8"
dependencies = [
"bitflags 2.4.1",
"linux-raw-sys",
"memoffset",
"rustix",
"rustix-futex-sync",
"unwinding",
]
[[package]]
name = "overload"
version = "0.1.1"
@ -1767,6 +1874,7 @@ dependencies = [
"diesel",
"diesel-async",
"diesel-derive-enum",
"eyra",
"flume",
"futures-core",
"hex",
@ -1906,6 +2014,18 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "printf-compat"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b002af28ffe3d3d67202ae717810a28125a494d5396debc43de01ee136ac404"
dependencies = [
"bitflags 1.3.2",
"cstr_core",
"cty",
"itertools 0.9.0",
]
[[package]]
name = "proc-macro2"
version = "1.0.69"
@ -2035,6 +2155,15 @@ dependencies = [
"getrandom",
]
[[package]]
name = "rand_pcg"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e"
dependencies = [
"rand_core",
]
[[package]]
name = "raw-cpuid"
version = "10.7.0"
@ -2044,6 +2173,17 @@ dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "realpath-ext"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692f72862a0d532b44a0f4965fb10f17e7659eaedf24d2ce3c989ca778bd092f"
dependencies = [
"bitflags 1.3.2",
"errno",
"libc",
]
[[package]]
name = "redox_syscall"
version = "0.2.16"
@ -2281,6 +2421,52 @@ dependencies = [
"semver",
]
[[package]]
name = "rustix"
version = "0.38.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
dependencies = [
"bitflags 2.4.1",
"errno",
"itoa",
"libc",
"linux-raw-sys",
"once_cell",
"windows-sys",
]
[[package]]
name = "rustix-dlmalloc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "730c0a5fbe9885450abcfca57da8c5d5a886492d01aa1a78b782fc5ddb2c0931"
dependencies = [
"rustix",
"rustix-futex-sync",
]
[[package]]
name = "rustix-futex-sync"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bebec5b686394f118236986b64350c06de4504a4dbe32f4e2e96c9f8adc15390"
dependencies = [
"lock_api",
"rustix",
]
[[package]]
name = "rustix-openpty"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a25c3aad9fc1424eb82c88087789a7d938e1829724f3e4043163baf0d13cfc12"
dependencies = [
"errno",
"libc",
"rustix",
]
[[package]]
name = "rustls"
version = "0.21.8"
@ -3163,6 +3349,12 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "tz-rs"
version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33851b15c848fad2cf4b105c6bb66eb9512b6f6c44a4b13f57c53c73c707e2b4"
[[package]]
name = "unicase"
version = "2.7.0"
@ -3199,6 +3391,16 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "unwinding"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37a19a21a537f635c16c7576f22d0f2f7d63353c1337ad4ce0d8001c7952a25b"
dependencies = [
"gimli",
"libc",
]
[[package]]
name = "url"
version = "2.4.1"

View file

@ -7,7 +7,12 @@ license = "AGPL-3.0"
readme = "README.md"
repository = "https://git.asonix.dog/asonix/pict-rs"
edition = "2021"
build = "src/build.rs"
[profile.dev]
opt-level = 1
[profile.dev.package."*"]
opt-level = 3
[profile.release]
strip = true
@ -81,6 +86,7 @@ tracing-subscriber = { version = "0.3.0", features = [
] }
url = { version = "2.2", features = ["serde"] }
uuid = { version = "1", features = ["serde", "std", "v4", "v7"] }
std = { version = "0.16.3", package = "eyra" }
[dependencies.tracing-actix-web]
version = "0.7.8"

View file

@ -1,5 +1,26 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1700374854,
"narHash": "sha256-mJOk9Rg5dbh9LorTKaiXlxCpfLZju/ngSvDABPzv870=",
"owner": "nix-community",
"repo": "fenix",
"rev": "95b4121cdcf9d6e91666305a1a9c57e483947e15",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@ -18,13 +39,33 @@
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1698420672,
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
"owner": "nix-community",
"repo": "naersk",
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1694959747,
"narHash": "sha256-CXQ2MuledDVlVM5dLC4pB41cFlBWxRw4tCBsFrq3cRk=",
"lastModified": 1700204040,
"narHash": "sha256-xSVcS5HBYnD3LTer7Y2K8ZQCDCXMa3QUD1MzRjHzuhI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "970a59bd19eff3752ce552935687100c46e820a5",
"rev": "c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad",
"type": "github"
},
"original": {
@ -36,10 +77,29 @@
},
"root": {
"inputs": {
"fenix": "fenix",
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1700247620,
"narHash": "sha256-+Xg0qZLbC9dZx0Z6JbaVHR/BklAr2I83dzKLB8r41c8=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "255eed40c45fcf108ba844b4ad126bdc4e7a18df",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,

View file

@ -4,20 +4,69 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils }:
outputs = { self, nixpkgs, flake-utils, fenix, naersk }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
};
systemMappings = {
"x86_64-linux" = ["x86_64" "unknown" "linux" "gnu"];
"aarch64-linux" = ["aarch64" "unknown" "linux" "gnu"];
};
hostCargoTarget = nixpkgs.lib.strings.concatMapStringsSep "_" (nixpkgs.lib.strings.toUpper) systemMappings.${system};
makeRustCrossPackage = (crossSystem:
let
pkgsCross = import nixpkgs {
inherit system;
crossSystem.system = crossSystem;
};
target = nixpkgs.lib.strings.concatStringsSep "-" systemMappings.${crossSystem};
cargoTarget = nixpkgs.lib.strings.concatMapStringsSep "_" (nixpkgs.lib.strings.toUpper) systemMappings.${crossSystem};
toolchain = with fenix.packages.${system}; combine [
minimal.cargo
minimal.rustc
targets.${target}.latest.rust-std
];
inherit (pkgsCross.stdenv) cc;
in
(naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
}).buildPackage {
src = ./.;
CARGO_BUILD_TARGET = target;
"CARGO_TARGET_${cargoTarget}_LINKER" = "${cc}/bin/${cc.targetPrefix}cc";
TARGET_CC = "${cc}/bin/${cc.targetPrefix}cc";
TARGET_AR = "${cc}/bin/${cc.targetPrefix}ar";
});
in
{
packages = rec {
pict-rs = pkgs.callPackage ./pict-rs.nix {
inherit (pkgs.darwin.apple_sdk.frameworks) Security;
};
pict-rs-x86_64-linux-gnu = makeRustCrossPackage "x86_64-linux";
pict-rs-aarch64-linux-gnu = makeRustCrossPackage "aarch64-linux";
pict-rs = pict-rs-x86_64-linux-gnu;
default = pict-rs;
};
@ -28,24 +77,26 @@
};
devShell = with pkgs; mkShell {
"CARGO_TARGET_${hostCargoTarget}_LINKER" = "${clang}/bin/clang";
"RUSTFLAGS" = "--cfg tokio_unstable --cfg uuid_unstable -C link-arg=-fuse-ld=${mold-wrapped}/bin/mold";
nativeBuildInputs = [
cargo
cargo-outdated
clippy
diesel-cli
exiftool
(pkgs.fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
ffmpeg_6-full
garage
gcc
imagemagick
rust-analyzer
rustc
rustfmt
rust-analyzer-nightly
taplo
tokio-console
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
});
}

View file

@ -1,40 +0,0 @@
{ exiftool
, ffmpeg_6-full
, imagemagick
, lib
, makeWrapper
, nixosTests
, rustPlatform
, Security
, stdenv
}:
rustPlatform.buildRustPackage {
pname = "pict-rs";
version = "0.5.0-beta.2";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [ stdenv makeWrapper ];
buildInputs = lib.optionals stdenv.isDarwin [ Security ];
RUSTFLAGS = "--cfg tokio_unstable --cfg uuid_unstable";
TARGET_CC = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
TARGET_AR = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}ar";
postInstall = ''
wrapProgram $out/bin/pict-rs \
--prefix PATH : "${lib.makeBinPath [ imagemagick ffmpeg_6-full exiftool ]}"
'';
passthru.tests = { inherit (nixosTests) pict-rs; };
meta = with lib; {
description = "A simple image hosting service";
homepage = "https://git.asonix.dog/asonix/pict-rs";
license = with licenses; [ agpl3Plus ];
};
}

3
src/build.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
println!("cargo:rustc-link-arg=-nostartfiles");
}