statix/flake.nix

123 lines
3.2 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-09-10 17:12:30 +03:00
mozillapkgs = {
url = "github:mozilla/nixpkgs-mozilla";
flake = false;
};
2021-10-19 18:09:11 +03:00
2021-10-31 20:15:42 +03:00
import-cargo.url = "github:edolstra/import-cargo";
gitignore.url = "github:hercules-ci/gitignore.nix";
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
, mozillapkgs
2021-10-19 18:09:11 +03:00
, import-cargo
2021-10-31 20:15:42 +03:00
, gitignore
2021-10-02 08:22:22 +03:00
, ...
}:
let
2021-10-19 18:09:11 +03:00
inherit (import-cargo.builders) importCargo;
2021-10-31 20:15:42 +03:00
inherit (gitignore.lib) gitignoreSource;
2021-10-23 10:48:03 +03:00
supportedSystems = [ "x86_64-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-19 18:09:11 +03:00
mozilla = p: p.callPackage (mozillapkgs + "/package-set.nix") { };
2021-10-02 08:22:22 +03:00
chanspec = {
2021-10-19 18:09:11 +03:00
date = "2021-09-30";
2021-10-02 08:22:22 +03:00
channel = "nightly";
2021-10-19 18:09:11 +03:00
sha256 = "Elqn7GDBDE/QT1XTDyj0EvivbC//uwjWX8d+J3Pi0dY="; # set zeros after modifying channel or date
2021-10-02 08:22:22 +03:00
};
2021-10-23 10:48:03 +03:00
rustChannel = p: (mozilla p).rustChannelOf chanspec;
2021-10-19 18:09:11 +03:00
in
{
2021-10-02 08:22:22 +03:00
2021-10-19 18:09:11 +03:00
overlay = final: prev:
let
2021-10-23 10:48:03 +03:00
inherit (rustChannel final.pkgs) rust rust-src;
2021-10-19 18:09:11 +03:00
in
{
2021-10-02 08:22:22 +03:00
2021-10-19 18:09:11 +03:00
statix = with final; pkgs.stdenv.mkDerivation {
pname = "statix";
2021-11-01 05:22:32 +03:00
version = "v0.3.4";
2021-10-31 20:22:28 +03:00
src = gitignoreSource ./.;
2021-10-19 18:09:11 +03:00
nativeBuildInputs = [
(importCargo { lockFile = ./Cargo.lock; inherit pkgs; }).cargoHome
rust
cargo
] ++ lib.optionals stdenv.isDarwin [ libiconv ];
2021-10-19 18:09:11 +03:00
buildPhase = ''
cargo build -p statix --all-features --release --offline
2021-10-19 18:09:11 +03:00
'';
# statix does not have any tests currently
doCheck = false;
2021-10-19 18:09:11 +03:00
installPhase = ''
install -Dm775 ./target/release/statix $out/bin/statix
'';
2021-10-27 05:32:57 +03:00
meta = with pkgs.lib; {
description = "Lints and suggestions for the Nix programming language";
homepage = "https://git.peppe.rs/languages/statix/about";
license = licenses.mit;
};
2021-10-19 18:09:11 +03:00
};
2021-09-10 17:12:30 +03:00
statix-vim =
with final; pkgs.vimUtils.buildVimPlugin {
pname = "statix-vim";
version = "0.1.0";
src = ./vim-plugin;
};
2021-10-19 18:09:11 +03:00
};
2021-09-10 17:12:30 +03:00
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-23 11:46:44 +03:00
defaultApp = forAllSystems (system:
{
type = "app";
program = "${self.packages."${system}".statix}/bin/statix";
});
2021-10-19 18:09:11 +03:00
devShell = forAllSystems (system:
let
2021-10-28 05:23:40 +03:00
pkgs = nixpkgsFor."${system}";
inherit (rustChannel pkgs) rust rust-src rust-analysis;
2021-10-19 18:09:11 +03:00
in
with pkgs;
mkShell rec {
buildInputs = [
rustfmt
cargo
cargo-watch
rust
rust-src
];
2021-10-23 10:48:03 +03:00
RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library";
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
}