Skip to content

Commit 0ec9167

Browse files
committed
flake.*: add Nix support for establishing a development environment
Nix is a package system similar to Go modules for creating predictable builds and environments. Nix builds are reproducible and a ligthweight alternative to Docker. This change makes the repository a Nix flake that includes a development environment. Use it with Nix 2.4 and later with flakes enabled: $ alias nix='nix --extra-experimental-features "nix-command flakes"' $ nix develop Signed-off-by: Elias Naur <[email protected]>
1 parent b803576 commit 0ec9167

File tree

3 files changed

+182
-2
lines changed

3 files changed

+182
-2
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,27 @@ This repository contains the open source Tailscale Android client.
2323
SDK](https://developer.android.com/studio/releases/platform-tools),
2424
the [Android NDK](https://developer.android.com/ndk) are required.
2525

26-
```
26+
```sh
2727
$ make tailscale-debug.apk
2828
$ adb install -r tailscale-debug.apk
2929
```
3030

3131
The `dockershell` target builds a container with the necessary
3232
dependencies and runs a shell inside it.
3333

34-
```
34+
```sh
3535
$ make dockershell
3636
# make tailscale-debug.apk
3737
```
3838

39+
If you have Nix 2.4 or later installed, a Nix development environment can
40+
be set up with
41+
42+
```sh
43+
$ alias nix='nix --extra-experimental-features "nix-command flakes"'
44+
$ nix develop
45+
```
46+
3947
Use `make tag_release` to bump the Android version code, update the version
4048
name, and tag the current commit.
4149

flake.lock

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
description = "Tailscale build environment";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs";
6+
android.url = "github:tadfisher/android-nixpkgs";
7+
android.inputs.nixpkgs.follows = "nixpkgs";
8+
};
9+
10+
outputs = { self, nixpkgs, android }:
11+
let
12+
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
13+
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
14+
in
15+
{
16+
devShells = forAllSystems
17+
(system:
18+
let
19+
pkgs = import nixpkgs {
20+
inherit system;
21+
};
22+
android-sdk = android.sdk.${system} (sdkPkgs: with sdkPkgs;
23+
[
24+
build-tools-30-0-2
25+
cmdline-tools-latest
26+
platform-tools
27+
platforms-android-31
28+
platforms-android-30
29+
ndk-23-1-7779620
30+
patcher-v4
31+
]);
32+
in
33+
{
34+
default = (with pkgs; buildFHSUserEnv {
35+
name = "tailscale";
36+
profile = ''
37+
export ANDROID_SDK_ROOT="${android-sdk}/share/android-sdk"
38+
export JAVA_HOME="${jdk8.home}"
39+
'';
40+
targetPkgs = pkgs: with pkgs; [
41+
android-sdk
42+
jdk8
43+
clang
44+
] ++ (if stdenv.isLinux then [
45+
vulkan-headers
46+
libxkbcommon
47+
wayland
48+
xorg.libX11
49+
xorg.libXcursor
50+
xorg.libXfixes
51+
libGL
52+
pkgconfig
53+
] else [ ]);
54+
}).env;
55+
}
56+
);
57+
};
58+
}

0 commit comments

Comments
 (0)