2024-05-04 18:55:52 +00:00
|
|
|
# Copyright (C) 2024 - 2024:
|
2024-05-06 14:29:15 +00:00
|
|
|
# The Trinitrix Project <benedikt.peetz@b-peetz.de, antifallobst@systemausfall.org, sils@sils.li>
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2024-05-04 18:55:52 +00:00
|
|
|
#
|
|
|
|
# This file is part of Trinitrix.
|
|
|
|
#
|
2024-05-08 19:18:29 +00:00
|
|
|
# Trinitrix is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published
|
|
|
|
# by the Free Software Foundation, either version 3 of the License,
|
|
|
|
# or (at your option) any later version.
|
2024-05-04 18:55:52 +00:00
|
|
|
#
|
2024-05-08 19:18:29 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
2024-05-04 18:55:52 +00:00
|
|
|
#
|
2024-05-08 19:18:29 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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
|
|
|
|
|