statix/flake.nix

119 lines
2.9 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-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-02 08:22:22 +03:00
}:
let
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.overlays.default ];
2021-10-19 18:09:11 +03:00
});
2021-10-23 10:48:03 +03:00
2023-02-20 13:23:48 +03:00
rustChannel = p: (fenix.overlay p p).fenix.complete;
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
overlays.default = final: prev: {
2021-11-01 05:54:19 +03:00
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 = self;
cargoLock.lockFile = ./Cargo.lock;
2023-02-20 13:23:48 +03:00
buildFeatures = [ "json" ];
2021-11-28 16:55:36 +03:00
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
2022-05-01 18:12:12 +03:00
apps = forAllSystems
(system:
let
pkgs = nixpkgsFor."${system}";
cachix-push-script = pkgs.writeScriptBin "cachix-push" ''
${pkgs.nixUnstable}/bin/nix build --json \
| ${pkgs.jq}/bin/jq -r '.[].outputs | to_entries[].value' \
| ${pkgs.cachix}/bin/cachix push statix
'';
in
{
cachix-push = {
type = "app";
program = "${cachix-push-script}/bin/cachix-push";
};
}
);
2021-10-19 18:09:11 +03:00
};
2021-09-10 17:12:30 +03:00
}