153 lines
3.9 KiB
Nix
153 lines
3.9 KiB
Nix
{
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
pre-commit-hooks = {
|
|
url = "github:cachix/pre-commit-hooks.nix";
|
|
};
|
|
|
|
crane.url = "github:ipetkov/crane";
|
|
|
|
treefmt-nix = {
|
|
url = "github:numtide/treefmt-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
flake-utils,
|
|
rust-overlay,
|
|
pre-commit-hooks,
|
|
crane,
|
|
treefmt-nix,
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system:
|
|
let
|
|
overlays = [ (import rust-overlay) ];
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
|
|
crane-lib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
|
src = crane-lib.cleanCargoSource ./.;
|
|
buildInputs =
|
|
with pkgs;
|
|
[
|
|
]
|
|
++ 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
|
|
;
|
|
};
|
|
|
|
in
|
|
{
|
|
formatter = self.checks.${system}.formatting.config.build.wrapper;
|
|
|
|
packages = {
|
|
inherit ha-now-playing;
|
|
};
|
|
packages.default = self.packages.${system}.ha-now-playing;
|
|
|
|
apps.ha-now-playing = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.default;
|
|
};
|
|
apps.default = self.apps.${system}.ha-now-playing;
|
|
|
|
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;
|
|
};
|
|
|
|
formatting = treefmt-nix.lib.evalModule pkgs {
|
|
projectRootFile = "flake.nix";
|
|
programs = {
|
|
nixfmt.enable = true;
|
|
deadnix.enable = true;
|
|
rustfmt.enable = true;
|
|
};
|
|
};
|
|
|
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
|
src = ./.;
|
|
hooks = {
|
|
nixfmt-rfc-style.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;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
devShells.default =
|
|
with pkgs;
|
|
mkShell {
|
|
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
|
|
|
name = "ha-now-playing";
|
|
inputsFrom = [ self.packages.${system}.ha-now-playing ];
|
|
packages = [
|
|
rustToolchain
|
|
cargo-edit
|
|
cargo-diet
|
|
cargo-feature
|
|
cargo-outdated
|
|
pre-commit
|
|
rust-analyzer
|
|
taplo
|
|
gitflow
|
|
|
|
dsniff # has the tcpkill command to test dropped connections
|
|
];
|
|
};
|
|
|
|
}
|
|
);
|
|
|
|
}
|