⛳ alerts for any ctfd instance via ntfy
1{
2 description = "⛳ sending alerts for leaderboard changes and new challenges on any ctfd.io instance";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 };
7
8 outputs = { self, nixpkgs }:
9 let
10 allSystems = [
11 "x86_64-linux" # 64-bit Intel/AMD Linux
12 "aarch64-linux" # 64-bit ARM Linux
13 "x86_64-darwin" # 64-bit Intel macOS
14 "aarch64-darwin" # 64-bit ARM macOS
15 ];
16 forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
17 pkgs = import nixpkgs { inherit system; };
18 });
19 in
20 {
21 packages = forAllSystems ({ pkgs }: {
22 default = pkgs.buildGoModule {
23 pname = "ctfd-alerts";
24 version = "0.1.0";
25 subPackages = [ "." ]; # Build from root directory
26 src = self;
27 vendorHash = null;
28 };
29 });
30
31 devShells = forAllSystems ({ pkgs }: {
32 default = pkgs.mkShell {
33 buildInputs = with pkgs; [
34 go
35 gopls
36 gotools
37 go-tools
38 (pkgs.writeShellScriptBin "ctfd-alerts-dev" ''
39 go build -o ./bin/ctfd-alerts
40 ./bin/ctfd-alerts "$@" || true
41 '')
42 (pkgs.writeShellScriptBin "ctfd-alerts-build" ''
43 echo "Building ctfd-alerts binaries for all platforms..."
44 mkdir -p $PWD/bin
45
46 # Build for Linux (64-bit)
47 echo "Building for Linux (x86_64)..."
48 GOOS=linux GOARCH=amd64 go build -o $PWD/bin/ctfd-alerts-linux-amd64
49
50 # Build for Linux ARM (64-bit)
51 echo "Building for Linux (aarch64)..."
52 GOOS=linux GOARCH=arm64 go build -o $PWD/bin/ctfd-alerts-linux-arm64
53
54 # Build for macOS (64-bit Intel)
55 echo "Building for macOS (x86_64)..."
56 GOOS=darwin GOARCH=amd64 go build -o $PWD/bin/ctfd-alerts-darwin-amd64
57
58 # Build for macOS ARM (64-bit)
59 echo "Building for macOS (aarch64)..."
60 GOOS=darwin GOARCH=arm64 go build -o $PWD/bin/ctfd-alerts-darwin-arm64
61
62 # Build for Windows (64-bit)
63 echo "Building for Windows (x86_64)..."
64 GOOS=windows GOARCH=amd64 go build -o $PWD/bin/ctfd-alerts-windows-amd64.exe
65
66 echo "All binaries built successfully in $PWD/bin/"
67 ls -la $PWD/bin/
68 '')
69 ];
70
71 shellHook = ''
72 export PATH=$PATH:$PWD/bin
73 mkdir -p $PWD/bin
74 '';
75 };
76 });
77
78 apps = forAllSystems ({ pkgs }: {
79 default = {
80 type = "app";
81 program = "${self.packages.${pkgs.system}.default}/bin/ctfd-alerts";
82 };
83 ctfd-alerts-dev = {
84 type = "app";
85 program = toString (pkgs.writeShellScript "ctfd-alerts-dev" ''
86 go build -o ./bin/ctfd-alerts ./main.go
87 ./bin/ctfd-alerts $* || true
88 '');
89 };
90 ctfd-alerts-build = {
91 type = "app";
92 program = "${self.devShells.${pkgs.system}.default.inputDerivation}/bin/ctfd-alerts-build";
93 };
94 });
95 };
96}