From 240b43fbaffb85c6e479b9794062c9aac4d9710c Mon Sep 17 00:00:00 2001 From: Seggy Umboh Date: Sat, 21 Jun 2025 12:41:59 -0700 Subject: [PATCH 1/3] Added nix flake and direnv --- .envrc | 1 + .gitignore | 6 ++++ flake.lock | 26 ++++++++++++++++ flake.nix | 75 +++++++++++++++++++++++++++++++++++++++++++++ nix/go-override.nix | 10 ++++++ 5 files changed, 118 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/go-override.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 14713bfa..a193fa96 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,9 @@ /.vscode /.zed *~ + +# direnv +.direnv/ + +# nix +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..026fb6d8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1750400657, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b2485d56967598da068b5a6946dadda8bfcbcd37", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..26c49bb2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,75 @@ +{ + description = "Temporal Server"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + }; + + outputs = + inputs: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forEachSupportedSystem = + f: + inputs.nixpkgs.lib.genAttrs supportedSystems ( + system: + f { + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + (import ./nix/go-override.nix) # https://github.com/NixOS/nixpkgs/pull/414434/files + ]; + }; + } + ); + in + { + packages = forEachSupportedSystem ( + { pkgs }: + let + inherit (pkgs) lib; + in + { + default = pkgs.buildGoModule (finalAttrs: { + pname = "temporalcli"; + version = "1.3.0"; + + src = builtins.path { + path = ./.; + filter = lib.cleanSourceFilter; + name = "temporalcli-source"; + }; + + vendorHash = "sha256-nHLN8VTD4Zlc8kjjv4XLxgDe+/wN339nukl/VbhWchU="; + + doCheck = false; + + meta = { + description = "Command-line interface for running Temporal Server and interacting with Workflows, Activities, Namespaces, and other parts of Temporal"; + homepage = "https://github.com/temporalio/cli"; + license = lib.licenses.mit; + mainProgram = "temporal"; + }; + }); + } + ); + + devShells = forEachSupportedSystem ( + { pkgs }: + { + default = pkgs.mkShellNoCC { + packages = with pkgs; [ + go + gotools + golangci-lint + ]; + }; + } + ); + }; +} diff --git a/nix/go-override.nix b/nix/go-override.nix new file mode 100644 index 00000000..5713093b --- /dev/null +++ b/nix/go-override.nix @@ -0,0 +1,10 @@ +self: super: rec { + go_1_24 = super.go_1_24.overrideAttrs (old: rec { + version = "1.24.4"; + src = super.fetchurl { + url = "https://go.dev/dl/go${version}.src.tar.gz"; + hash = "sha256-WoaoOjH5+oFJC4xUIKw4T9PZWj5x+6Zlx7P5XR3+8rQ="; + }; + }); + go = go_1_24; +} From eaf70f7d480ceb93a85b40db9aa8daaea4d9ba8f Mon Sep 17 00:00:00 2001 From: Seggy Umboh Date: Sat, 21 Jun 2025 13:29:01 -0700 Subject: [PATCH 2/3] Explain nix dev env and package in README --- README.md | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fdf4f790..5992767b 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,11 @@ Reference [the documentation](https://docs.temporal.io/cli) for detailed install ### Install via download 1. Download the version for your OS and architecture: - - [Linux amd64](https://temporal.download/cli/archive/latest?platform=linux&arch=amd64) - - [Linux arm64](https://temporal.download/cli/archive/latest?platform=linux&arch=arm64) - - [macOS amd64](https://temporal.download/cli/archive/latest?platform=darwin&arch=amd64) - - [macOS arm64](https://temporal.download/cli/archive/latest?platform=darwin&arch=arm64) (Apple silicon) - - [Windows amd64](https://temporal.download/cli/archive/latest?platform=windows&arch=amd64) + - [Linux amd64](https://temporal.download/cli/archive/latest?platform=linux&arch=amd64) + - [Linux arm64](https://temporal.download/cli/archive/latest?platform=linux&arch=arm64) + - [macOS amd64](https://temporal.download/cli/archive/latest?platform=darwin&arch=amd64) + - [macOS arm64](https://temporal.download/cli/archive/latest?platform=darwin&arch=arm64) (Apple silicon) + - [Windows amd64](https://temporal.download/cli/archive/latest?platform=windows&arch=amd64) 2. Extract the downloaded archive. 3. Add the `temporal` binary to your `PATH` (`temporal.exe` for Windows). @@ -31,6 +31,27 @@ Reference [the documentation](https://docs.temporal.io/cli) for detailed install The executable will be at `temporal` (`temporal.exe` for Windows). +### Build with Nix + +1. [Install Nix](https://docs.determinate.systems/getting-started/individuals#install) +2. Clone repository +3. Switch to cloned directory, and run `nix build` + +The executable will be at `result/bin/temporal`. + +### Nix Development Environment + +1. [Install Nix](https://docs.determinate.systems/getting-started/individuals#install) +2. Clone repository +3. Switch to cloned directory, and run `nix develop` + +Go and related tools will be made available in this shell. This can be further automated by direnv: + +1. Install direnv: `nix profile add nixpkgs#direnv` +2. Run `direnv allow` in the project directory + +Now every time you enter the project directory, all the tools will be available. + ## Usage Reference [the documentation](https://docs.temporal.io/cli) for detailed usage information. From b3414338c05aa8f6c801b46ea54ace1d1a504d9c Mon Sep 17 00:00:00 2001 From: Seggy Umboh Date: Sat, 21 Jun 2025 15:55:20 -0700 Subject: [PATCH 3/3] Take advantage of the derivation in nixpkgs --- flake.nix | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index 26c49bb2..56e46b0d 100644 --- a/flake.nix +++ b/flake.nix @@ -35,27 +35,11 @@ inherit (pkgs) lib; in { - default = pkgs.buildGoModule (finalAttrs: { - pname = "temporalcli"; + default = pkgs.temporal-cli.overrideAttrs { version = "1.3.0"; - - src = builtins.path { - path = ./.; - filter = lib.cleanSourceFilter; - name = "temporalcli-source"; - }; - - vendorHash = "sha256-nHLN8VTD4Zlc8kjjv4XLxgDe+/wN339nukl/VbhWchU="; - - doCheck = false; - - meta = { - description = "Command-line interface for running Temporal Server and interacting with Workflows, Activities, Namespaces, and other parts of Temporal"; - homepage = "https://github.com/temporalio/cli"; - license = lib.licenses.mit; - mainProgram = "temporal"; - }; - }); + src = lib.cleanSource ./.; + vendorHash = "sha256-AO6djBGm4cUZ1p1h3AMskNnJSxV0OSyOkvTLrpiVw8g="; + }; } );