ha-now-playing/flake.nix

154 lines
3.9 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
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
2022-01-14 10:06:26 +01:00
};
2024-12-02 12:53:16 +01:00
crane.url = "github:ipetkov/crane";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-11-19 17:44:10 +01:00
};
2024-12-02 12:53:16 +01:00
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
pre-commit-hooks,
crane,
treefmt-nix,
}:
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; };
2024-12-02 12:53:16 +01:00
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
2022-11-18 09:49:45 +01:00
crane-lib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = crane-lib.cleanCargoSource ./.;
2024-12-02 12:53:16 +01:00
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 {
2024-12-02 12:53:16 +01:00
inherit
cargoArtifacts
src
buildInputs
nativeBuildInputs
;
};
2021-11-20 17:37:14 +01:00
in
2022-11-18 09:49:45 +01:00
{
2024-12-02 12:53:16 +01:00
formatter = self.checks.${system}.formatting.config.build.wrapper;
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 {
2024-12-02 12:53:16 +01:00
inherit
cargoArtifacts
src
buildInputs
nativeBuildInputs
;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
ha-now-playing-fmt = crane-lib.cargoFmt {
inherit src;
};
2024-12-02 12:53:16 +01:00
formatting = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
deadnix.enable = true;
rustfmt.enable = true;
};
};
2022-11-18 09:49:45 +01:00
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
2024-12-02 12:53:16 +01:00
nixfmt-rfc-style.enable = true;
2022-11-18 09:49:45 +01:00
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
};
2024-12-02 12:53:16 +01:00
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
];
};
2021-11-20 17:37:14 +01:00
2024-12-02 12:53:16 +01:00
}
);
2021-11-19 17:44:10 +01:00
}