ha-now-playing/flake.nix

122 lines
3.4 KiB
Nix
Raw Normal View History

2021-11-19 17:44:10 +01:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
2022-11-18 09:49:45 +01:00
flake-utils.url = "github:numtide/flake-utils";
2022-01-14 10:06:26 +01:00
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
2022-11-18 09:49:45 +01:00
inputs.flake-utils.follows = "flake-utils";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.flake-utils.follows = "flake-utils";
2022-01-14 10:06:26 +01:00
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
};
2021-11-19 17:44:10 +01:00
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, pre-commit-hooks, crane }:
2022-11-18 09:49:45 +01:00
flake-utils.lib.eachDefaultSystem (system:
2021-11-20 17:37:14 +01:00
let
2022-01-14 10:06:26 +01:00
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain =
2022-11-18 09:49:45 +01:00
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
crane-lib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = crane-lib.cleanCargoSource ./.;
buildInputs = with pkgs; [
openssl
] ++ lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
nativeBuildInputs = with pkgs; [
pkgconf
];
cargoArtifacts = crane-lib.buildDepsOnly {
inherit src buildInputs nativeBuildInputs;
};
ha-now-playing = crane-lib.buildPackage {
inherit cargoArtifacts src buildInputs nativeBuildInputs;
};
2021-11-20 17:37:14 +01:00
in
2022-11-18 09:49:45 +01:00
{
formatter = pkgs.nixpkgs-fmt;
2021-11-23 14:23:12 +01:00
2022-11-18 09:49:45 +01:00
packages = {
inherit ha-now-playing;
2022-11-18 09:49:45 +01:00
};
packages.default = self.packages.${system}.ha-now-playing;
2021-11-19 17:44:10 +01:00
2022-11-18 09:49:45 +01:00
apps.ha-now-playing = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
2021-11-20 17:37:14 +01:00
};
2022-11-18 09:49:45 +01:00
apps.default = self.apps.${system}.ha-now-playing;
2021-11-19 17:44:10 +01:00
2022-11-18 09:49:45 +01:00
overlays = _final: _prev: {
inherit (self.packages.${system}) ha-now-playing;
};
checks = {
inherit ha-now-playing;
ha-now-playing-clippy = crane-lib.cargoClippy {
inherit cargoArtifacts src buildInputs nativeBuildInputs;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
ha-now-playing-fmt = crane-lib.cargoFmt {
inherit src;
};
2022-11-18 09:49:45 +01:00
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
deadnix.enable = true;
rust-overlay-clippy = {
enable = true;
name = "rust-overlay clippy";
entry = "${rustToolchain}/bin/cargo-clippy clippy";
files = "\\.rs$";
excludes = [ "^$" ];
types = [ "file" ];
types_or = [ ];
language = "system";
pass_filenames = false;
};
2022-11-18 09:49:45 +01:00
};
};
2021-11-23 14:23:12 +01:00
};
2022-03-23 10:51:43 +01:00
devShells.default = with pkgs; mkShell {
2022-11-18 09:49:45 +01:00
inherit (self.checks.${system}.pre-commit-check) shellHook;
name = "ha-now-playing";
inputsFrom = [ self.packages.${system}.ha-now-playing ];
2023-07-03 16:05:13 +02:00
packages = [
rustToolchain
cargo-edit
cargo-diet
cargo-feature
cargo-outdated
pre-commit
rust-analyzer
taplo
gitflow
];
2021-11-19 17:44:10 +01:00
};
2021-11-20 17:37:14 +01:00
});
2021-11-19 17:44:10 +01:00
}