shell.nix 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 ? "fabd769a3703c88780c5a7fb543577992d5074d1",
  15. tailscale-go-sha ? "sha256-BvwZ/90izw0Ip3lh8eNkJvU46LKnOOhEXF0axkBi/Es=",
  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. # Remove custom nix patches, which are all related to fixing up
  31. # tests. Some don't apply cleanly in 1.19.
  32. # TODO: revert this once nix upstream has formal 1.19 support.
  33. patches = [];
  34. checkPhase = "";
  35. # Our forked tailscale reads this env var to embed the git hash
  36. # into the Go build version.
  37. TAILSCALE_TOOLCHAIN_REV = tailscale-go-rev;
  38. });
  39. in
  40. pkgs.mkShell {
  41. # This specifies the tools that are needed for people to get started with
  42. # development. These tools include:
  43. # - The Go compiler toolchain (and all additional tooling with it)
  44. # - gotools for goimports, a robust formatting tool for Go source code
  45. # - gopls, the language server for Go to increase editor integration
  46. # - git, the version control program (used in some scripts)
  47. # - graphviz, for 'go tool pprof'
  48. buildInputs = [
  49. pkgs.git
  50. pkgs.gotools pkgs.gopls
  51. tailscale-go
  52. pkgs.graphviz
  53. ];
  54. }