From d38a348a067822125960b7aeba9b66722d5258cf Mon Sep 17 00:00:00 2001 From: Christoph Schmatzler Date: Mon, 9 Feb 2026 17:15:10 +0000 Subject: [PATCH] add openusage Signed-off-by: Christoph Schmatzler --- flake.lock | 18 ++++++ flake.nix | 4 ++ overlays/openusage.nix | 132 +++++++++++++++++++++++++++++++++++++++++ profiles/packages.nix | 1 + 4 files changed, 155 insertions(+) create mode 100644 overlays/openusage.nix diff --git a/flake.lock b/flake.lock index 6562d32..333367d 100644 --- a/flake.lock +++ b/flake.lock @@ -495,6 +495,23 @@ "type": "github" } }, + "openusage": { + "flake": false, + "locked": { + "lastModified": 1770543295, + "narHash": "sha256-DvgEPZhFm06igalUPgnQ8VLkl0gk/3rm+lbEJ2/s7gM=", + "owner": "robinebers", + "repo": "openusage", + "rev": "22a7bd5f7856397400e60dd787ad82b23c763969", + "type": "github" + }, + "original": { + "owner": "robinebers", + "ref": "v0.5.1", + "repo": "openusage", + "type": "github" + } + }, "overseer": { "flake": false, "locked": { @@ -526,6 +543,7 @@ "nixpkgs": "nixpkgs_2", "nixvim": "nixvim", "nono": "nono", + "openusage": "openusage", "overseer": "overseer", "sops-nix": "sops-nix", "zjstatus": "zjstatus" diff --git a/flake.nix b/flake.nix index 571f3eb..c5c9312 100644 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,10 @@ url = "github:dmmulroy/overseer"; flake = false; }; + openusage = { + url = "github:robinebers/openusage/v0.5.1"; + flake = false; + }; }; outputs = inputs @ {flake-parts, ...}: diff --git a/overlays/openusage.nix b/overlays/openusage.nix new file mode 100644 index 0000000..9f70130 --- /dev/null +++ b/overlays/openusage.nix @@ -0,0 +1,132 @@ +{inputs}: final: prev: let + version = "0.5.1"; +in { + openusage = + prev.rustPlatform.buildRustPackage (finalAttrs: { + pname = "openusage"; + inherit version; + + src = inputs.openusage; + + cargoRoot = "src-tauri"; + cargoLock = { + lockFile = "${inputs.openusage}/src-tauri/Cargo.lock"; + outputHashes = { + "tauri-nspanel-2.1.0" = "sha256-PLACEHOLDER"; + "tauri-plugin-aptabase-1.0.0" = "sha256-PLACEHOLDER"; + }; + }; + buildAndTestSubdir = finalAttrs.cargoRoot; + + node_modules = + prev.stdenv.mkDerivation { + inherit (finalAttrs) src version; + pname = "${finalAttrs.pname}-node_modules"; + + impureEnvVars = + prev.lib.fetchers.proxyImpureEnvVars + ++ [ + "GIT_PROXY_COMMAND" + "SOCKS_SERVER" + ]; + + nativeBuildInputs = [ + prev.bun + prev.writableTmpDirAsHomeHook + ]; + + dontConfigure = true; + dontFixup = true; + dontPatchShebangs = true; + + buildPhase = '' + runHook preBuild + + export BUN_INSTALL_CACHE_DIR=$(mktemp -d) + + bun install \ + --no-progress \ + --frozen-lockfile \ + --ignore-scripts + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + cp -R ./node_modules $out + runHook postInstall + ''; + + outputHash = "sha256-PLACEHOLDER"; + outputHashMode = "recursive"; + }; + + nativeBuildInputs = [ + prev.cargo-tauri.hook + prev.rustPlatform.bindgenHook + prev.bun + prev.nodejs + prev.pkg-config + prev.makeBinaryWrapper + ]; + + buildInputs = + prev.lib.optionals prev.stdenv.isDarwin ( + with prev.darwin.apple_sdk.frameworks; [ + AppKit + CoreFoundation + CoreServices + Security + WebKit + ] + ); + + # Disable updater artifact generation — we don't have signing keys. + tauriConf = builtins.toJSON {bundle.createUpdaterArtifacts = false;}; + passAsFile = ["tauriConf"]; + preBuild = '' + tauriBuildFlags+=( + "--config" + "$tauriConfPath" + ) + ''; + + configurePhase = '' + runHook preConfigure + + # Copy pre-fetched node_modules + cp -R ${finalAttrs.node_modules} node_modules/ + chmod -R u+rw node_modules + chmod -R u+x node_modules/.bin + patchShebangs node_modules + + export HOME=$TMPDIR + export PATH="$PWD/node_modules/.bin:$PATH" + + # Bundle plugins (copy from plugins/ to src-tauri/resources/bundled_plugins/) + ${prev.nodejs}/bin/node copy-bundled.cjs + + runHook postConfigure + ''; + + env = { + OPENSSL_NO_VENDOR = true; + }; + + doCheck = false; + + postInstall = + prev.lib.optionalString prev.stdenv.isDarwin '' + makeWrapper $out/Applications/OpenUsage.app/Contents/MacOS/OpenUsage $out/bin/openusage + ''; + + meta = { + description = "Track all your AI coding subscriptions in one place"; + homepage = "https://github.com/robinebers/openusage"; + license = prev.lib.licenses.mit; + platforms = prev.lib.platforms.darwin; + mainProgram = "openusage"; + }; + }); +} diff --git a/profiles/packages.nix b/profiles/packages.nix index 5350fb5..a92475c 100644 --- a/profiles/packages.nix +++ b/profiles/packages.nix @@ -52,6 +52,7 @@ with pkgs; alcove dockutil mas + openusage raycast tailscale xcodes