A simple Tiger compiler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
tig-rs/flake.nix

160 lines
3.6 KiB

{
description = "A simple Tiger compiler";
inputs = {
flake-utils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "master";
};
naersk = {
type = "github";
owner = "nix-community";
repo = "naersk";
ref = "master";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixpkgs-unstable";
};
pre-commit-hooks = {
type = "github";
owner = "cachix";
repo = "pre-commit-hooks.nix";
ref = "master";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
rust-overlay = {
type = "github";
owner = "oxalica";
repo = "rust-overlay";
ref = "master";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
{ self
, flake-utils
, naersk
, nixpkgs
, pre-commit-hooks
, rust-overlay
}:
{
overlay = final: prev: {
tig-rs =
let
inherit (final) system;
overlays = [
(import rust-overlay)
];
pkgs = import nixpkgs { inherit overlays system; };
my-rust = pkgs.rust-bin.stable.latest;
naersk-lib = naersk.lib."${system}".override {
cargo = my-rust.default;
rustc = my-rust.default;
};
in
naersk-lib.buildPackage {
pname = "tig-rs";
version = "0.0.0";
src = ./.;
nativeBuildInputs = with final; [
pkg-config
];
buildInputs = with final; [
openssl
];
passthru = {
inherit my-rust;
};
meta = with final.lib; {
homepage = "https://gitea.belanyi.fr/ambroisie/tig-rs";
license = with licenses; [ mit asl20 ];
maintainers = with maintainers; [ ambroisie ];
platforms = platforms.unix;
};
};
};
} // (flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ self.overlay ];
pkgs = import nixpkgs { inherit overlays system; };
inherit (pkgs) lib;
inherit (pkgs.tig-rs.passthru) my-rust;
in
rec {
apps = {
tig-rs = flake-utils.lib.mkApp { drv = packages.tig-rs; };
};
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
# FIXME: clippy and rustfmt fail when inside `nix flake check`
# but `pre-commit run --all` works properly...
# Also a problem when not overriding the `entry`
hooks = {
clippy = {
enable = true;
entry = lib.mkForce "${my-rust.clippy}/bin/cargo-clippy clippy";
};
nixpkgs-fmt = {
enable = true;
};
rustfmt = {
enable = true;
entry = lib.mkForce "${my-rust.rustfmt}/bin/cargo-fmt fmt -- --check --color always";
};
};
};
};
defaultApp = apps.tig-rs;
defaultPackage = packages.tig-rs;
devShell = pkgs.mkShell {
inputsFrom = [
defaultPackage
];
nativeBuildInputs = with pkgs; [
rust-analyzer
];
inherit (checks.pre-commit) shellHook;
RUST_SRC_PATH = "${my-rust.rust-src}/lib/rustlib/src/rust/library";
};
packages = {
inherit (pkgs) tig-rs;
};
}));
}