馃尫 the cutsie hackatime helper
1{
2 description = "馃尫 the cutsie hackatime helper";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 };
7
8 outputs =
9 { self, nixpkgs }:
10 let
11 allSystems = [
12 "x86_64-linux" # 64-bit Intel/AMD Linux
13 "aarch64-linux" # 64-bit ARM Linux
14 "x86_64-darwin" # 64-bit Intel macOS
15 "aarch64-darwin" # 64-bit ARM macOS
16 ];
17 forAllSystems =
18 f:
19 nixpkgs.lib.genAttrs allSystems (
20 system:
21 f {
22 pkgs = import nixpkgs { inherit system; };
23 }
24 );
25 in
26 {
27 packages = forAllSystems (
28 { pkgs }:
29 let
30 akami = pkgs.buildGoModule {
31 pname = "akami";
32 version = "0.0.1";
33 subPackages = [ "." ]; # Build from root directory
34 src = self;
35 vendorHash = "sha256-9gO00c3D846SJl5dbtfj0qasmONLNxU/7V1TG6QEaxM=";
36
37 nativeBuildInputs = [ pkgs.installShellFiles ];
38
39 postInstall = ''
40 installShellCompletion --cmd crush \
41 --bash <($out/bin/crush completion bash) \
42 --fish <($out/bin/crush completion fish) \
43 --zsh <($out/bin/crush completion zsh)
44
45 # Generate and install man page
46 $out/bin/crush man > crush.1
47 installManPage crush.1
48 '';
49
50 meta = with pkgs.lib; {
51 description = "馃尫 the cutsie hackatime helper";
52 homepage = "https://github.com/taciturnaxolotl/akami";
53 license = licenses.mit;
54 maintainers = with maintainers; [ taciturnaxolotl ];
55 platforms = platforms.linux ++ platforms.darwin;
56 };
57 };
58 in
59 {
60 default = akami;
61 }
62 );
63
64 devShells = forAllSystems (
65 { pkgs }:
66 {
67 default = pkgs.mkShell {
68 buildInputs = with pkgs; [
69 go
70 gopls
71 gotools
72 go-tools
73 (pkgs.writeShellScriptBin "akami-dev" ''
74 go build -o ./bin/akami ./main.go
75 ./bin/akami "$@" || true
76 '')
77 (pkgs.writeShellScriptBin "akami-build" ''
78 echo "Building akami binaries for all platforms..."
79 mkdir -p $PWD/bin
80
81 # Build for Linux (64-bit)
82 echo "Building for Linux (x86_64)..."
83 GOOS=linux GOARCH=amd64 go build -o $PWD/bin/akami-linux-amd64 ./main.go
84
85 # Build for Linux ARM (64-bit)
86 echo "Building for Linux (aarch64)..."
87 GOOS=linux GOARCH=arm64 go build -o $PWD/bin/akami-linux-arm64 ./main.go
88
89 # Build for macOS (64-bit Intel)
90 echo "Building for macOS (x86_64)..."
91 GOOS=darwin GOARCH=amd64 go build -o $PWD/bin/akami-darwin-amd64 ./main.go
92
93 # Build for macOS ARM (64-bit)
94 echo "Building for macOS (aarch64)..."
95 GOOS=darwin GOARCH=arm64 go build -o $PWD/bin/akami-darwin-arm64 ./main.go
96
97 # Build for Windows (64-bit)
98 echo "Building for Windows (x86_64)..."
99 GOOS=windows GOARCH=amd64 go build -o $PWD/bin/akami-windows-amd64.exe ./main.go
100
101 echo "All binaries built successfully in $PWD/bin/"
102 ls -la $PWD/bin/
103 '')
104 ];
105
106 shellHook = ''
107 export PATH=$PATH:$PWD/bin
108 mkdir -p $PWD/bin
109 '';
110 };
111 }
112 );
113
114 apps = forAllSystems (
115 { pkgs }:
116 {
117 default = {
118 type = "app";
119 program = "${self.packages.${pkgs.system}.default}/bin/akami";
120 };
121 akami-dev = {
122 type = "app";
123 program = toString (
124 pkgs.writeShellScript "akami-dev" ''
125 go build -o ./bin/akami ./main.go
126 ./bin/akami $* || true
127 ''
128 );
129 };
130 akami-build = {
131 type = "app";
132 program = "${self.devShells.${pkgs.system}.default.inputDerivation}/bin/akami-build";
133 };
134 }
135 );
136
137 formatter = forAllSystems ({ pkgs }: pkgs.nixfmt-tree);
138 };
139}