2023-07-09 05:13:32 +00:00
|
|
|
{
|
|
|
|
description = "A terminal UI client for the matrix chat protocol";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
|
|
|
|
# inputs for following
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
crane = {
|
|
|
|
url = "github:ipetkov/crane";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
flake-utils = {
|
|
|
|
url = "github:numtide/flake-utils";
|
|
|
|
inputs = {};
|
|
|
|
};
|
|
|
|
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
|
2023-09-03 20:11:41 +00:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [(import rust-overlay)];
|
|
|
|
};
|
|
|
|
|
2023-12-16 10:47:02 +00:00
|
|
|
nightly = false;
|
2023-09-03 20:11:41 +00:00
|
|
|
rust =
|
|
|
|
if nightly
|
build(flake): Replace self-packaged cranelift with rustup's
Motivation
==========
The self-packed one sort-of worked, but was rather flaky, while the one
from rustup obviously works, as it's an officially distributed part.
Running it
==========
Instead of the `cargo clif [build, etc.]` you now need to run (on nightly):
```
RUSTFLAGS="-Zcodegen-backend=cranelift" cargo build
```
Performance
===========
On my system I noticed, that a debug build takes around 20 sec *more*
with cranelift, compared to the default LLVM backend.
One possible hypothesis, for that could be, that cranelift does
not link via `mold` but instead still uses GNU's `gold`.
On the other hand, the performance decrease could also be caused
by the fact, that it's an early preview and some optimizations are
still lacking.
2023-10-31 17:07:24 +00:00
|
|
|
then
|
|
|
|
(pkgs.rust-bin.selectLatestNightlyWith (toolchain:
|
|
|
|
toolchain.default))
|
|
|
|
.override {
|
|
|
|
extensions = ["rustc-codegen-cranelift-preview"];
|
|
|
|
}
|
2023-09-03 20:11:41 +00:00
|
|
|
else pkgs.rust-bin.stable.latest.default;
|
2023-11-07 19:48:06 +00:00
|
|
|
rust_min =
|
|
|
|
if nightly
|
|
|
|
then
|
|
|
|
(pkgs.rust-bin.selectLatestNightlyWith (toolchain:
|
|
|
|
toolchain.minimal))
|
|
|
|
.override {
|
|
|
|
extensions = ["rustc-codegen-cranelift-preview"];
|
|
|
|
}
|
|
|
|
else pkgs.rust-bin.stable.latest.minimal;
|
2023-09-03 20:11:41 +00:00
|
|
|
|
2023-11-07 19:48:06 +00:00
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain rust_min;
|
2023-09-03 20:11:41 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
pkg-config
|
2023-10-31 17:55:18 +00:00
|
|
|
mold-wrapped
|
2023-09-03 20:11:41 +00:00
|
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
openssl
|
|
|
|
lua54Packages.lua
|
|
|
|
];
|
|
|
|
|
|
|
|
craneBuild = craneLib.buildPackage {
|
|
|
|
src = craneLib.cleanCargoSource ./.;
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
inherit nativeBuildInputs buildInputs;
|
|
|
|
};
|
|
|
|
in {
|
2023-12-16 10:47:21 +00:00
|
|
|
checks.default = craneBuild;
|
2023-09-03 20:11:41 +00:00
|
|
|
packages = {
|
|
|
|
default = craneBuild;
|
|
|
|
};
|
|
|
|
|
|
|
|
app.default = {
|
|
|
|
type = "app";
|
|
|
|
program = "${self.packages.${system}.default}/bin/trinitix";
|
|
|
|
};
|
2023-07-24 15:11:17 +00:00
|
|
|
|
2023-09-03 20:11:41 +00:00
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
packages = with pkgs; [
|
|
|
|
alejandra
|
|
|
|
|
|
|
|
rust
|
|
|
|
rust-analyzer
|
|
|
|
cargo-edit
|
|
|
|
cargo-expand
|
|
|
|
];
|
|
|
|
inherit nativeBuildInputs buildInputs;
|
|
|
|
};
|
|
|
|
});
|
2023-07-09 05:13:32 +00:00
|
|
|
}
|
|
|
|
# vim: ts=2
|
|
|
|
|