{ description = "lastfmpris"; inputs = { flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; rust-overlay.url = "github:oxalica/rust-overlay"; }; outputs = { self, nixpkgs, flake-utils, rust-overlay, }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; overlays = [rust-overlay.overlays.default]; }; package = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package; rustPlatform = pkgs.makeRustPlatform { cargo = pkgs.cargo; rustc = pkgs.rustc; }; toolchain = pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml; in rec { packages = flake-utils.lib.flattenTree { lastfmpris = rustPlatform.buildRustPackage { pname = package.name; inherit (package) version; # uncomment this and let the build fail, then get the current hash # very scuffed but endorsed! #cargoSha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; cargoSha256 = "sha256-KOMEvg3iGjmMEFxsrIqD4SaDw63ojiNNNqCfzRlbYLw="; buildInputs = with pkgs; [ pkg-config ]; nativeBuildInputs = with pkgs; [ openssl dbus ]; src = ./.; }; }; defaultPackage = packages.lastfmpris; devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ pkg-config ]; nativeBuildInputs = with pkgs; [ openssl dbus ]; packages = with pkgs; [ toolchain rust-analyzer-unwrapped ]; RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; }; }) // { homeManagerModules = { lastfmpris = { config, lib, pkgs, ... }: with lib; let cfg = config.services.lastfmpris; in { options.services.lastfmpris = { enable = mkEnableOption "enables the lastmpris scrobbler"; package = mkOption { type = types.package; default = pkgs.lastfmpris; }; }; config = mkIf cfg.enable { home.packages = [ cfg.package ]; systemd.user.services.lastfmpris = { Unit = { Description = "Lastfmpris scrobbling daemon"; After = [ "graphical-session-pre.target" ]; }; Service = { Type = "Simple"; ExecStart = "${lib.getExe cfg.package}"; Restart = "on-failure"; }; }; }; }; }; }; }