@ -32,7 +32,7 @@
{
{
inputs = {
inputs = {
nixpkgs . url = " g i t h u b : N i x O S / n i x p k g s / n i x p k g s - u n s t a b l e " ;
nixpkgs . url = " g i t h u b : N i x O S / n i x p k g s / n i x p k g s - u n s t a b l e " ;
flake-util s. url = " g i t h u b : n um t i d e / f l a k e - u t i l s " ;
system s. url = " g i t h u b : n ix - s y s t e m s / d e f a u l t " ;
# Used by shell.nix as a compat shim.
# Used by shell.nix as a compat shim.
flake-compat = {
flake-compat = {
url = " g i t h u b : e d o l s t r a / f l a k e - c o m p a t " ;
url = " g i t h u b : e d o l s t r a / f l a k e - c o m p a t " ;
@ -43,13 +43,29 @@
outputs = {
outputs = {
self ,
self ,
nixpkgs ,
nixpkgs ,
flake-util s,
system s,
flake-compat ,
flake-compat ,
} : let
} : let
# tailscaleRev is the git commit at which this flake was imported,
go124Version = " 1 . 2 4 . 6 " ;
# or the empty string when building from a local checkout of the
goHash = " s h a 2 5 6 - 4 c t V g q q 1 i G a L w E w H 3 h h o g H D 2 u M m y q v N h + C H h m 9 R 8 / b 0 = " ;
# tailscale repo.
eachSystem = f :
nixpkgs . lib . genAttrs ( import systems ) ( system :
f ( import nixpkgs {
system = system ;
overlays = [
( final : prev : {
go_1_24 = prev . go_1_24 . overrideAttrs {
version = go124Version ;
src = prev . fetchurl {
url = " h t t p s : / / g o . d e v / d l / g o ${ go124Version } . s r c . t a r . g z " ;
hash = goHash ;
} ;
} ;
} )
] ;
} ) ) ;
tailscaleRev = self . rev or " " ;
tailscaleRev = self . rev or " " ;
in {
# tailscale takes a nixpkgs package set, and builds Tailscale from
# tailscale takes a nixpkgs package set, and builds Tailscale from
# the same commit as this flake. IOW, it provides "tailscale built
# the same commit as this flake. IOW, it provides "tailscale built
# from HEAD", where HEAD is "whatever commit you imported the
# from HEAD", where HEAD is "whatever commit you imported the
@ -67,16 +83,20 @@
# So really, this flake is for tailscale devs to dogfood with, if
# So really, this flake is for tailscale devs to dogfood with, if
# you're an end user you should be prepared for this flake to not
# you're an end user you should be prepared for this flake to not
# build periodically.
# build periodically.
tailscale = pkgs :
packages = eachSystem ( pkgs : rec {
pkgs. buildGo124Module rec {
default = pkgs. buildGo124Module {
name = " t a i l s c a l e " ;
name = " t a i l s c a l e " ;
pname = " t a i l s c a l e " ;
src = ./. ;
src = ./. ;
vendorHash = pkgs . lib . fileContents ./go.mod.sri ;
vendorHash = pkgs . lib . fileContents ./go.mod.sri ;
nativeBuildInputs = pkgs . lib . optionals pkgs . stdenv . isLinux [ pkgs . makeWrapper ] ;
nativeBuildInputs = [ pkgs . makeWrapper pkgs . installShellFiles ] ;
ldflags = [ " - X t a i l s c a l e . c o m / v e r s i o n . g i t C o m m i t S t a m p = ${ tailscaleRev } " ] ;
ldflags = [ " - X t a i l s c a l e . c o m / v e r s i o n . g i t C o m m i t S t a m p = ${ tailscaleRev } " ] ;
env . CGO_ENABLED = 0 ;
env . CGO_ENABLED = 0 ;
subPackages = [ " c m d / t a i l s c a l e " " c m d / t a i l s c a l e d " ] ;
subPackages = [
" c m d / t a i l s c a l e "
" c m d / t a i l s c a l e d "
" c m d / t s i d p "
] ;
doCheck = false ;
doCheck = false ;
# NOTE: We strip the ${PORT} and $FLAGS because they are unset in the
# NOTE: We strip the ${PORT} and $FLAGS because they are unset in the
@ -84,7 +104,8 @@
# point, there should be a NixOS module that allows configuration of these
# point, there should be a NixOS module that allows configuration of these
# things, but for now, we hardcode the default of port 41641 (taken from
# things, but for now, we hardcode the default of port 41641 (taken from
# ./cmd/tailscaled/tailscaled.defaults).
# ./cmd/tailscaled/tailscaled.defaults).
postInstall = pkgs . lib . optionalString pkgs . stdenv . isLinux ''
postInstall =
pkgs . lib . optionalString pkgs . stdenv . isLinux ''
wrapProgram $ out/bin/tailscaled - - prefix PATH : $ { pkgs . lib . makeBinPath [ pkgs . iproute2 pkgs . iptables pkgs . getent pkgs . shadow ] }
wrapProgram $ out/bin/tailscaled - - prefix PATH : $ { pkgs . lib . makeBinPath [ pkgs . iproute2 pkgs . iptables pkgs . getent pkgs . shadow ] }
wrapProgram $ out/bin/tailscale - - suffix PATH : $ { pkgs . lib . makeBinPath [ pkgs . procps ] }
wrapProgram $ out/bin/tailscale - - suffix PATH : $ { pkgs . lib . makeBinPath [ pkgs . procps ] }
@ -96,20 +117,18 @@
./cmd/tailscaled/tailscaled.service
./cmd/tailscaled/tailscaled.service
install - D - m0444 - t $ out/lib/systemd/system ./cmd/tailscaled/tailscaled.service
install - D - m0444 - t $ out/lib/systemd/system ./cmd/tailscaled/tailscaled.service
''
+ pkgs . lib . optionalString ( pkgs . stdenv . buildPlatform . canExecute pkgs . stdenv . hostPlatform ) ''
installShellCompletion - - cmd tailscale \
- - bash < ( $ out/bin/tailscale completion bash ) \
- - fish < ( $ out/bin/tailscale completion fish ) \
- - zsh < ( $ out/bin/tailscale completion zsh )
'' ;
'' ;
} ;
} ;
tailscale = default ;
} ) ;
# This whole blob makes the tailscale package available for all
devShells = eachSystem ( pkgs : {
# OS/CPU combos that nix supports, as well as a dev shell so that
# "nix develop" and "nix-shell" give you a dev env.
flakeForSystem = nixpkgs : system : let
pkgs = nixpkgs . legacyPackages . ${ system } ;
ts = tailscale pkgs ;
in {
packages = {
default = ts ;
tailscale = ts ;
} ;
devShell = pkgs . mkShell {
devShell = pkgs . mkShell {
packages = with pkgs ; [
packages = with pkgs ; [
curl
curl
@ -126,9 +145,8 @@
e2fsprogs
e2fsprogs
] ;
] ;
} ;
} ;
} ) ;
} ;
} ;
in
flake-utils . lib . eachDefaultSystem ( system : flakeForSystem nixpkgs system ) ;
}
}
# nix-direnv cache busting line: sha256- 4QTSspHLYJfzlontQ7msXyOB5gzq7ZwSvWmKuYY5klA =
# nix-direnv cache busting line: sha256-Ue1rD4m+rg/J84XhpNZAa3ni/r5FVQZTh6wZcbp7GsE=