-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
103 lines (90 loc) · 3.05 KB
/
flake.nix
File metadata and controls
103 lines (90 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
description = "A CLI tool that extracts Claude usage metrics as JSON";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
claude-code = {
url = "github:sadjow/claude-code-nix?ref=v2.1.17";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, claude-code ? null }:
let
# Read version from VERSION file (single source of truth)
version = builtins.replaceStrings [ "\n" ] [ "" ] (builtins.readFile ./VERSION);
# Build package for a given system
mkPackage = pkgs:
let
goPackage = pkgs.buildGoModule {
pname = "claude-o-meter";
inherit version;
src = ./.;
vendorHash = "sha256-NrU2dSnUQzWpc33BsjUCzesYsiEcMsdM3x3OJhpdVUs=";
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
dbus
];
ldflags = [
"-s" "-w"
"-X main.Version=${version}"
];
meta = with pkgs.lib; {
description = "A CLI tool that extracts Claude usage metrics as JSON";
homepage = "https://github.com/MartinLoeper/claude-o-meter";
license = licenses.mit;
maintainers = [ ];
mainProgram = "claude-o-meter";
};
};
in
# Wrap the package to include the icon in share/claude-o-meter/
pkgs.symlinkJoin {
name = "claude-o-meter-${version}";
paths = [ goPackage ];
postBuild = ''
mkdir -p $out/share/claude-o-meter
cp ${./assets/claude-icon.png} $out/share/claude-o-meter/claude-icon.png
'';
meta = goPackage.meta;
};
# System-agnostic outputs
systemAgnostic = {
homeManagerModules.default = { config, lib, pkgs, ... }:
let
system = pkgs.stdenv.hostPlatform.system;
# Import the actual module and pass the default package and claude-code
# claude-code input is optional - pass null if not provided
module = import ./nix/hm-module.nix {
defaultPackage = mkPackage pkgs;
claudeCodePackage =
if claude-code != null
then claude-code.packages.${system}.default
else null;
};
in
module { inherit config lib pkgs; };
homeManagerModules.claude-o-meter = self.homeManagerModules.default;
};
# Per-system outputs
perSystem = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.default = mkPackage pkgs;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
go
gopls
gotools
pkg-config
dbus
];
};
}
);
in
systemAgnostic // perSystem;
}