{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; naersk = { url = "github:nmattia/naersk/master"; inputs.nixpkgs.follows = "nixpkgs"; }; 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"; }; }; outputs = { self, nixpkgs, flake-utils, naersk, rust-overlay, pre-commit-hooks }: flake-utils.lib.eachDefaultSystem (system: let overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; }; naersk-lib = pkgs.callPackage naersk { }; rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; in { formatter = pkgs.nixpkgs-fmt; packages = { ha-now-playing = (naersk-lib.override { cargo = rustToolchain; rustc = rustToolchain; }).buildPackage { pname = "ha-now-playing"; root = ./.; buildInputs = with pkgs; [ rustToolchain openssl ]; nativeBuildInputs = with pkgs; [ pkgconf cargo-edit cargo-expand cargo-diet cargo-feature cargo-outdated rust-analyzer pre-commit jq gitflow yaml-language-server ]; }; }; 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 = { 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 ]; }; }); }