|
| 1 | +{ |
| 2 | + description = "datumctl - A CLI for interacting with Datum Cloud"; |
| 3 | + |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 6 | + flake-utils.url = "github:numtide/flake-utils"; |
| 7 | + }; |
| 8 | + |
| 9 | + outputs = { self, nixpkgs, flake-utils }: |
| 10 | + flake-utils.lib.eachSystem [ |
| 11 | + "x86_64-linux" |
| 12 | + "aarch64-linux" |
| 13 | + "x86_64-darwin" |
| 14 | + "aarch64-darwin" |
| 15 | + ] (system: |
| 16 | + let |
| 17 | + pkgs = import nixpkgs { |
| 18 | + inherit system; |
| 19 | + }; |
| 20 | + |
| 21 | + # Get version from git, fallback to "dev" if not in a git repo |
| 22 | + version = |
| 23 | + if (builtins.pathExists ./.git) |
| 24 | + then builtins.replaceStrings ["\n"] [""] (builtins.readFile ( |
| 25 | + pkgs.runCommand "get-version" {} '' |
| 26 | + cd ${./.} |
| 27 | + ${pkgs.git}/bin/git describe --tags --always --dirty 2>/dev/null > $out || echo "dev" > $out |
| 28 | + '' |
| 29 | + )) |
| 30 | + else "dev"; |
| 31 | + |
| 32 | + in |
| 33 | + { |
| 34 | + packages = { |
| 35 | + default = pkgs.buildGoModule { |
| 36 | + pname = "datumctl"; |
| 37 | + inherit version; |
| 38 | + |
| 39 | + src = ./.; |
| 40 | + |
| 41 | + # Hash of Go module dependencies. |
| 42 | + # Update this after changing go.mod/go.sum: |
| 43 | + # task nix-update-hash |
| 44 | + vendorHash = "sha256-zbQ/K15d4R9eaghuAiblHhUptwXLyjVh3pvVg0BOP08="; |
| 45 | + |
| 46 | + ldflags = [ |
| 47 | + "-s" |
| 48 | + "-w" |
| 49 | + "-X main.version=${version}" |
| 50 | + ]; |
| 51 | + |
| 52 | + meta = with pkgs.lib; { |
| 53 | + description = "A CLI for interacting with the Datum platform"; |
| 54 | + homepage = "https://www.datum.net/docs/quickstart/datumctl/"; |
| 55 | + license = licenses.asl20; |
| 56 | + maintainers = [ ]; |
| 57 | + mainProgram = "datumctl"; |
| 58 | + }; |
| 59 | + }; |
| 60 | + }; |
| 61 | + |
| 62 | + devShells.default = pkgs.mkShell { |
| 63 | + buildInputs = with pkgs; [ |
| 64 | + go_1_25 |
| 65 | + gopls |
| 66 | + gotools |
| 67 | + go-task |
| 68 | + go-tools |
| 69 | + git |
| 70 | + ]; |
| 71 | + |
| 72 | + shellHook = '' |
| 73 | + echo "datumctl development environment" |
| 74 | + echo "Go version: $(go version)" |
| 75 | + ''; |
| 76 | + }; |
| 77 | + |
| 78 | + formatter = pkgs.nixpkgs-fmt; |
| 79 | + } |
| 80 | + ); |
| 81 | +} |
0 commit comments