-
Notifications
You must be signed in to change notification settings - Fork 50
Add nix flake and direnv #814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks! We will at the least need CI checks to confirm all of this |
Actually, I think I misunderstood the purpose of this PR. Is this to make developing and building the CLI easier in |
Thank you. It is indeed for development purposes. The nix package is already being maintained in nixpkgs so I am just pulling that and overriding the src to point to the local sources. As the development needs can deviate between projects, e.g. golang upgrades, different services, etc, it would be nice to just enter the directory and know that all the right tools are available at exactly the correct versions. |
It will be much more useful for the server, where we can create a nix flake with services so you can start postgres, cassandra, mysql, elasticsearch, otel-collector without setup and without using docker which, as noted on the README, is slow on MacOS. |
I am not sure any of the Temporal developers would leverage this and therefore it'd be a bit hard to maintain. Our goal is to be able to support
The goal is to have it all self-contained so Can you clarify a bit on how things are deviating when you're developing/building this? We're hoping it's nothing more than |
@cretz Thank you for taking the time to understand the purpose of this change. I use NixOS and nix-darwin myself, so I don't have go or any other language toolset installed globally, preferring to have a nix flake define the toolset and development environment for each project and direnv to automatically activate the environment upon entering each project directory. While I believe there is a growing set of devs with this preference, I can of course understand if the Temporal community does not, especially given how nice and consistent the go ecosystem is compared to python and ruby. The server one might be more valuable with the services running natively on MacOS. I'm happy to leave this here until you find value in it or feel free to close it if you don't think it is useful. |
For what it's worth, I'm a Temporal developer and I use NixOS exclusively on all my systems. I do it like this: Check out all Temporal repos underneath Put this in { pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
GOPATH = toString ./go;
nativeBuildInputs = with pkgs; [
go
protobuf
shellcheck
];
} Put this in use nix
PATH_add go/bin The This approach doesn't pin things as tightly as this PR, or build the cli as a Nix derivation itself, but actually I think those are benefits here: it keeps it closer to how other Temporal developers build things, and I get to take advantage of Go build caching (there are workarounds for this but they're not great). Also, most changes to the cli are probably going to end up touching other Temporal repos too, so having a single solution that works across repos is nicer. This PR pins the vendorHash for building the cli, which I think will be a big maintenance burden. |
@dnr That's a great solution for taking care of all these go repos in one fell swoop! I guess the question for this PR is: Do we want a one-liner setup for outside contributors who use Nix, given it does not interfere with the dev workflow of the rest of the contributors, but does introduce a couple of files that are not useful to those that don't use them. @cretz I get why you consider this "platform-specific contribution helpers" and the concern about them. I can imagine the repo would be cluttered if we also added a guix.scm, a Brewfile, asdf .tool-version, etc. I will only add that I wish there was some one-liner setup for a new contributor rather than none. |
What was changed
Added a nix flake with:
Why?
Checklist
How was this tested:
Follow the instructions in the README:
Make sure Nix is installed (https://docs.determinate.systems/getting-started/individuals/)
nix build
will build the executable inresult/bin/temporal
nix develop
will activate a dev shell with go 1.24.4 and related toolsdirenv allow
will automatically activate the dev shell when entering the directory (install it withnix profile add nixpkgs#direnv
)Any docs updates needed?
Only if the team decides to make the nix development environment a supported one.