diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..3550a30f2 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 14713bfa8..a193fa96d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,9 @@ /.vscode /.zed *~ + +# direnv +.direnv/ + +# nix +/result diff --git a/README.md b/README.md index fdf4f7903..5992767b7 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. diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..026fb6d8c --- /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 000000000..56e46b0d4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,59 @@ +{ + 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.temporal-cli.overrideAttrs { + version = "1.3.0"; + src = lib.cleanSource ./.; + vendorHash = "sha256-AO6djBGm4cUZ1p1h3AMskNnJSxV0OSyOkvTLrpiVw8g="; + }; + } + ); + + 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 000000000..5713093b5 --- /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; +}