2024-02-19 15:13:06 +00:00
|
|
|
# Copyright (C) 2023 - 2024:
|
|
|
|
# The Trinitrix Project <soispha@vhack.eu, antifallobst@systemausfall.org>
|
|
|
|
#
|
|
|
|
# This file is part of the Trixy crate for Trinitrix.
|
|
|
|
#
|
|
|
|
# Trixy is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the Lesser GNU General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of
|
|
|
|
# the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# and the Lesser GNU General Public License along with this program.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/>.
|
2023-12-23 15:07:17 +00:00
|
|
|
{
|
|
|
|
description = "A rust crate used to generate multi-language apis for your
|
|
|
|
application";
|
|
|
|
inputs = {
|
2024-02-18 12:11:33 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2023-12-23 15:07:17 +00:00
|
|
|
|
|
|
|
# inputs for following
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
|
2024-02-19 19:48:50 +00:00
|
|
|
treefmt-nix = {
|
|
|
|
url = "github:numtide/treefmt-nix";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-02-18 12:11:33 +00:00
|
|
|
systems = {
|
|
|
|
url = "github:nix-systems/default";
|
|
|
|
};
|
|
|
|
|
2023-12-23 15:07:17 +00:00
|
|
|
crane = {
|
|
|
|
url = "github:ipetkov/crane";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
flake-utils = {
|
|
|
|
url = "github:numtide/flake-utils";
|
2024-02-18 12:11:33 +00:00
|
|
|
inputs = {
|
|
|
|
systems.follows = "systems";
|
|
|
|
};
|
2023-12-23 15:07:17 +00:00
|
|
|
};
|
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
ebnf2pdf = {
|
|
|
|
url = "git+https://codeberg.org/soispha/ebnf2pdf.git";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-utils.follows = "flake-utils";
|
2024-02-18 12:11:33 +00:00
|
|
|
flake-compat.follows = "flake-compat";
|
|
|
|
systems.follows = "systems";
|
2023-12-23 15:07:17 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
outputs = {
|
2024-02-19 19:48:50 +00:00
|
|
|
self,
|
2023-12-23 15:07:17 +00:00
|
|
|
nixpkgs,
|
|
|
|
crane,
|
|
|
|
flake-utils,
|
|
|
|
rust-overlay,
|
2023-12-23 17:35:38 +00:00
|
|
|
ebnf2pdf,
|
2024-02-19 19:48:50 +00:00
|
|
|
treefmt-nix,
|
2023-12-23 15:07:17 +00:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
flake-utils.lib.eachDefaultSystem (system: let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [(import rust-overlay)];
|
|
|
|
};
|
|
|
|
|
|
|
|
nightly = false;
|
|
|
|
rust =
|
|
|
|
if nightly
|
|
|
|
then
|
|
|
|
(pkgs.rust-bin.selectLatestNightlyWith (toolchain:
|
|
|
|
toolchain.default))
|
|
|
|
.override {
|
|
|
|
extensions = ["rustc-codegen-cranelift-preview"];
|
|
|
|
}
|
|
|
|
else pkgs.rust-bin.stable.latest.default;
|
|
|
|
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;
|
|
|
|
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain rust_min;
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
lua54Packages.lua
|
|
|
|
];
|
|
|
|
|
|
|
|
craneBuild = craneLib.buildPackage {
|
|
|
|
src = craneLib.cleanCargoSource ./.;
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
inherit nativeBuildInputs buildInputs;
|
|
|
|
};
|
2024-02-19 19:48:50 +00:00
|
|
|
treefmtEval = treefmt-nix.lib.evalModule pkgs (
|
|
|
|
{pkgs, ...}: {
|
|
|
|
# Used to find the project root
|
|
|
|
projectRootFile = "flake.nix";
|
|
|
|
|
|
|
|
programs = {
|
|
|
|
alejandra.enable = true;
|
|
|
|
rustfmt.enable = true;
|
|
|
|
clang-format.enable = true;
|
|
|
|
mdformat.enable = true;
|
|
|
|
shfmt = {
|
|
|
|
enable = true;
|
|
|
|
indent_size = 4;
|
|
|
|
};
|
|
|
|
shellcheck.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
settings.formatter = {
|
|
|
|
clang-format = {
|
|
|
|
options = ["--style" "GNU"];
|
|
|
|
};
|
|
|
|
rustfmt = {
|
|
|
|
# also add the Trixy files
|
|
|
|
includes = ["*.tri"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
2023-12-23 15:07:17 +00:00
|
|
|
in {
|
|
|
|
checks.default = craneBuild;
|
|
|
|
packages = {
|
|
|
|
default = craneBuild;
|
|
|
|
};
|
|
|
|
|
2024-02-19 19:48:50 +00:00
|
|
|
formatter = treefmtEval.config.build.wrapper;
|
|
|
|
checks = {
|
|
|
|
formatting = treefmtEval.config.build.check self;
|
|
|
|
};
|
|
|
|
|
2023-12-23 15:07:17 +00:00
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
packages = with pkgs; [
|
|
|
|
alejandra
|
|
|
|
|
2023-12-23 17:35:38 +00:00
|
|
|
cocogitto
|
|
|
|
licensure
|
2024-02-19 19:48:50 +00:00
|
|
|
treefmt
|
2023-12-23 17:35:38 +00:00
|
|
|
|
2023-12-23 15:07:17 +00:00
|
|
|
rust
|
|
|
|
cargo-edit
|
|
|
|
cargo-expand
|
2024-03-24 20:13:46 +00:00
|
|
|
valgrind
|
2023-12-23 15:07:17 +00:00
|
|
|
|
2023-12-25 21:23:52 +00:00
|
|
|
# Used to format the c header files
|
|
|
|
libclang
|
|
|
|
gdb
|
|
|
|
|
2023-12-23 15:07:17 +00:00
|
|
|
ebnf2pdf.outputs.packages."${system}".default
|
|
|
|
];
|
|
|
|
inherit nativeBuildInputs buildInputs;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|