This repository has been archived on 2024-05-26. You can view files and clone it, but cannot push or open issues or pull requests.
trixy/flake.nix

136 lines
3.4 KiB
Nix

# Copyright (C) 2023 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/>.
{
description = "A rust crate used to generate multi-language apis for your
application";
inputs = {
# nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:soispha/nixpkgs/licensure";
# 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";
};
};
ebnf2pdf = {
url = "git+https://codeberg.org/soispha/ebnf2pdf.git";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = {
nixpkgs,
crane,
flake-utils,
rust-overlay,
ebnf2pdf,
...
}:
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;
};
in {
checks.default = craneBuild;
packages = {
default = craneBuild;
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
alejandra
cocogitto
licensure
rust
cargo-edit
cargo-expand
# Used to format the c header files
libclang
gdb
ebnf2pdf.outputs.packages."${system}".default
];
inherit nativeBuildInputs buildInputs;
};
});
}