statix/flake.nix

113 lines
2.8 KiB
Nix
Raw Normal View History

2021-09-10 17:12:30 +03:00
{
inputs = {
2021-10-19 18:09:11 +03:00
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
2021-11-01 05:54:19 +03:00
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
2021-09-10 17:12:30 +03:00
};
2021-10-19 18:09:11 +03:00
2021-11-01 05:54:19 +03:00
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-10-19 18:09:11 +03:00
2021-09-10 17:12:30 +03:00
};
2021-10-02 08:22:22 +03:00
outputs =
{ self
, nixpkgs
2021-11-01 05:54:19 +03:00
, fenix
2021-10-31 20:15:42 +03:00
, gitignore
2021-10-02 08:22:22 +03:00
}:
let
2021-10-31 20:15:42 +03:00
inherit (gitignore.lib) gitignoreSource;
2021-10-23 10:48:03 +03:00
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
2021-10-19 18:09:11 +03:00
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
2021-10-23 10:48:03 +03:00
2021-10-02 08:22:22 +03:00
chanspec = {
2022-02-19 18:14:59 +03:00
date = "2022-02-06";
2021-10-02 08:22:22 +03:00
channel = "nightly";
2022-02-19 18:14:59 +03:00
sha256 = "oKkTWopCDx4tphzTtRn+zDDtvmIZrL/H44tV2ruSfDw="; # set zeros after modifying channel or date
2021-10-02 08:22:22 +03:00
};
2021-11-01 05:54:19 +03:00
rustChannel = p: (fenix.overlay p p).fenix.toolchainOf chanspec;
2021-10-23 10:48:03 +03:00
2021-10-19 18:09:11 +03:00
in
{
2021-10-02 08:22:22 +03:00
2021-11-01 05:54:19 +03:00
overlay = final: prev: {
statix = with final;
let
pname = "statix";
packageMeta = (lib.importTOML ./bin/Cargo.toml).package;
rustPlatform = makeRustPlatform {
inherit (rustChannel final) cargo rustc;
};
in
rustPlatform.buildRustPackage {
inherit pname;
inherit (packageMeta) version;
src = gitignoreSource ./.;
cargoLock.lockFile = ./Cargo.lock;
2021-11-28 16:55:36 +03:00
buildFeatures = "json";
meta = with lib; {
description = "Lints and suggestions for the Nix programming language";
homepage = "https://git.peppe.rs/languages/statix/about";
license = licenses.mit;
};
2021-11-01 05:54:19 +03:00
};
2021-09-10 17:12:30 +03:00
2021-11-01 05:54:19 +03:00
statix-vim =
with final; vimUtils.buildVimPlugin {
pname = "statix-vim";
version = "0.1.0";
src = ./vim-plugin;
};
};
2021-10-19 18:09:11 +03:00
packages = forAllSystems (system: {
inherit (nixpkgsFor."${system}") statix statix-vim;
2021-10-19 18:09:11 +03:00
});
2021-09-10 17:12:30 +03:00
2021-10-19 18:09:11 +03:00
defaultPackage =
forAllSystems (system: self.packages."${system}".statix);
2021-09-10 17:12:30 +03:00
2021-10-19 18:09:11 +03:00
devShell = forAllSystems (system:
let
2021-10-28 05:23:40 +03:00
pkgs = nixpkgsFor."${system}";
2021-11-01 05:54:19 +03:00
toolchain = (rustChannel pkgs).withComponents [
"rustc"
"cargo"
"rust-std"
"rustfmt"
"clippy"
"rust-src"
];
2021-11-03 12:18:35 +03:00
inherit (fenix.packages."${system}") rust-analyzer;
2021-10-19 18:09:11 +03:00
in
2021-11-03 12:18:35 +03:00
pkgs.mkShell {
2021-11-01 05:54:19 +03:00
nativeBuildInputs = [
2021-11-20 16:26:26 +03:00
pkgs.bacon
2021-11-03 12:18:35 +03:00
pkgs.cargo-insta
2021-11-02 10:48:36 +03:00
rust-analyzer
2021-11-01 05:54:19 +03:00
toolchain
];
2021-10-19 18:09:11 +03:00
RUST_LOG = "info";
RUST_BACKTRACE = 1;
});
2021-09-10 17:12:30 +03:00
2021-10-19 18:09:11 +03:00
};
2021-09-10 17:12:30 +03:00
}