shell.nix 2.0 KB

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