shell.nix 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # This is a shell.nix file used to describe the environment that tailscale needs
  2. # for development. This includes a lot of the basic tools that you need in order
  3. # to get started. We hope this file will be useful for users of Nix on macOS or
  4. # Linux.
  5. #
  6. # For more information about this and why this file is useful, see here:
  7. # https://nixos.org/guides/nix-pills/developing-with-nix-shell.html
  8. #
  9. # Also look into direnv: https://direnv.net/, this can make it so that you can
  10. # automatically get your environment set up when you change folders into the
  11. # project.
  12. {
  13. pkgs ? import <nixpkgs> {},
  14. tailscale-go-rev ? "710a0d861098c07540ad073bb73a42ce81bf54a8",
  15. tailscale-go-sha ? "sha256-hnyddxiyqMFHGwV3I4wkBcYNd56schYFi0SL5/0PnMI=",
  16. }:
  17. let
  18. tailscale-go = pkgs.lib.overrideDerivation pkgs.go_1_18 (attrs: rec {
  19. name = "tailscale-go-${version}";
  20. version = tailscale-go-rev;
  21. src = pkgs.fetchFromGitHub {
  22. owner = "tailscale";
  23. repo = "go";
  24. rev = tailscale-go-rev;
  25. sha256 = tailscale-go-sha;
  26. };
  27. nativeBuildInputs = attrs.nativeBuildInputs ++ [ pkgs.git ];
  28. # Remove dependency on xcbuild as that causes iOS/macOS builds to fail.
  29. propagatedBuildInputs = [];
  30. checkPhase = "";
  31. # Our forked tailscale reads this env var to embed the git hash
  32. # into the Go build version.
  33. TAILSCALE_TOOLCHAIN_REV = tailscale-go-rev;
  34. });
  35. in
  36. pkgs.mkShell {
  37. # This specifies the tools that are needed for people to get started with
  38. # development. These tools include:
  39. # - The Go compiler toolchain (and all additional tooling with it)
  40. # - gotools for goimports, a robust formatting tool for Go source code
  41. # - gopls, the language server for Go to increase editor integration
  42. # - git, the version control program (used in some scripts)
  43. buildInputs = [
  44. pkgs.git
  45. pkgs.gotools pkgs.gopls
  46. tailscale-go
  47. ];
  48. }