2024-05-04 18:55:52 +00:00
|
|
|
# Copyright (C) 2024 - 2024:
|
|
|
|
# The Trinitrix Project <bpeetz@b-peetz.de, antifallobst@systemausfall.org>
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
#
|
|
|
|
# This file is part of Trinitrix.
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person
|
|
|
|
# obtaining a copy of this software and associated documentation files
|
|
|
|
# (the “Software”), to deal in the Software without restriction,
|
|
|
|
# including without limitation the rights to use, copy, modify, merge,
|
|
|
|
# publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
# and to permit persons to whom the Software is furnished to do so,
|
|
|
|
# subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be
|
|
|
|
# included in all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
# OTHER DEALINGS IN THE SOFTWARE.
|
2023-07-09 05:13:32 +00:00
|
|
|
{
|
2024-05-04 18:40:02 +00:00
|
|
|
description = "A multi protocol chat client";
|
2023-07-09 05:13:32 +00:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
|
2024-05-04 18:40:02 +00:00
|
|
|
treefmt-nix = {
|
|
|
|
url = "github:numtide/treefmt-nix";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-07-09 05:13:32 +00:00
|
|
|
};
|
2023-12-23 20:58:19 +00:00
|
|
|
|
2023-07-09 05:13:32 +00:00
|
|
|
crane = {
|
|
|
|
url = "github:ipetkov/crane";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
};
|
|
|
|
};
|
2024-05-04 18:40:02 +00:00
|
|
|
|
|
|
|
# inputs for following
|
|
|
|
systems = {
|
|
|
|
url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
|
|
|
|
};
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
flake-utils = {
|
|
|
|
url = "github:numtide/flake-utils";
|
|
|
|
inputs = {
|
|
|
|
systems.follows = "systems";
|
|
|
|
};
|
|
|
|
};
|
2023-07-09 05:13:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
flake-utils,
|
2024-05-04 18:40:02 +00:00
|
|
|
treefmt-nix,
|
|
|
|
crane,
|
2023-07-09 05:13:32 +00:00
|
|
|
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;
|
2024-05-04 18:40:02 +00:00
|
|
|
rust_minimal =
|
2023-09-03 20:11:41 +00:00
|
|
|
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
|
2024-05-04 18:40:02 +00:00
|
|
|
(pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal)).override {
|
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
|
|
|
extensions = ["rustc-codegen-cranelift-preview"];
|
|
|
|
}
|
2024-05-04 18:40:02 +00:00
|
|
|
else pkgs.rust-bin.stable.latest.minimal;
|
|
|
|
rust_default =
|
2023-11-07 19:48:06 +00:00
|
|
|
if nightly
|
|
|
|
then
|
2024-05-04 18:40:02 +00:00
|
|
|
(pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)).override {
|
2023-11-07 19:48:06 +00:00
|
|
|
extensions = ["rustc-codegen-cranelift-preview"];
|
|
|
|
}
|
2024-05-04 18:40:02 +00:00
|
|
|
else pkgs.rust-bin.stable.latest.default;
|
2023-09-03 20:11:41 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
pkg-config
|
2023-10-31 17:55:18 +00:00
|
|
|
mold-wrapped
|
2024-05-03 19:23:26 +00:00
|
|
|
|
|
|
|
clang-tools
|
2023-09-03 20:11:41 +00:00
|
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
openssl
|
|
|
|
lua54Packages.lua
|
|
|
|
];
|
2024-05-04 18:40:02 +00:00
|
|
|
cargo_toml = craneLib.cleanCargoToml {cargoToml = ./Cargo.toml;};
|
|
|
|
pname = cargo_toml.package.name;
|
|
|
|
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain rust_minimal;
|
2023-09-03 20:11:41 +00:00
|
|
|
craneBuild = craneLib.buildPackage {
|
2024-05-04 18:40:02 +00:00
|
|
|
inherit nativeBuildInputs buildInputs;
|
|
|
|
|
2024-05-08 19:03:42 +00:00
|
|
|
src = let
|
|
|
|
trixyFilter = path: _type: builtins.match ".*tri$" path != null;
|
|
|
|
markdownOrCargo = path: type:
|
|
|
|
(trixyFilter path type) || (craneLib.filterCargoSources path type);
|
|
|
|
in
|
|
|
|
pkgs.lib.cleanSourceWith {
|
|
|
|
src = craneLib.path ./.;
|
|
|
|
filter = markdownOrCargo;
|
|
|
|
};
|
2023-09-03 20:11:41 +00:00
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
};
|
2024-05-04 18:40:02 +00:00
|
|
|
|
|
|
|
manual = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "${pname}-manual";
|
|
|
|
inherit (cargo_toml.package) version;
|
|
|
|
|
|
|
|
src = ./docs;
|
|
|
|
nativeBuildInputs = with pkgs; [pandoc];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
mkdir --parents $out/docs;
|
|
|
|
|
|
|
|
pandoc "./${pname}.1.md" -s -t man > $out/docs/${pname}.1
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -D $out/docs/${pname}.1 $out/share/man/man1/${pname};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
|
2023-09-03 20:11:41 +00:00
|
|
|
in {
|
2024-05-04 18:40:02 +00:00
|
|
|
packages.default = pkgs.symlinkJoin {
|
|
|
|
inherit (cargo_toml.package) name;
|
|
|
|
|
|
|
|
paths = [manual craneBuild];
|
2023-09-03 20:11:41 +00:00
|
|
|
};
|
|
|
|
|
2024-05-04 18:40:02 +00:00
|
|
|
checks = {
|
|
|
|
inherit craneBuild;
|
|
|
|
formatting = treefmtEval.config.build.check self;
|
2023-09-03 20:11:41 +00:00
|
|
|
};
|
2023-07-24 15:11:17 +00:00
|
|
|
|
2024-05-04 18:40:02 +00:00
|
|
|
formatter = treefmtEval.config.build.wrapper;
|
|
|
|
|
2023-09-03 20:11:41 +00:00
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
packages = with pkgs; [
|
2024-05-04 18:40:02 +00:00
|
|
|
cocogitto
|
2023-09-03 20:11:41 +00:00
|
|
|
|
2024-05-04 19:00:15 +00:00
|
|
|
yq
|
|
|
|
|
2024-05-04 18:40:02 +00:00
|
|
|
rust_default
|
2023-09-03 20:11:41 +00:00
|
|
|
cargo-edit
|
2024-05-04 18:09:02 +00:00
|
|
|
|
|
|
|
valgrind
|
2024-05-04 18:40:02 +00:00
|
|
|
licensure
|
2023-09-03 20:11:41 +00:00
|
|
|
];
|
2024-05-06 13:51:41 +00:00
|
|
|
inherit nativeBuildInputs buildInputs;
|
2023-09-03 20:11:41 +00:00
|
|
|
};
|
|
|
|
});
|
2023-07-09 05:13:32 +00:00
|
|
|
}
|
|
|
|
# vim: ts=2
|
|
|
|
|