{ 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"; inputs.flake-utils.follows = "flake-utils"; }; pre-commit-hooks = { url = "github:cachix/pre-commit-hooks.nix"; inputs.flake-utils.follows = "flake-utils"; }; crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; inputs.rust-overlay.follows = "rust-overlay"; }; }; outputs = { self, nixpkgs, flake-utils, rust-overlay, pre-commit-hooks, crane }: 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 = pkgs.nixpkgs-fmt; 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; }; 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; }; }; }; }; 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 ]; }; }); }