Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3375915
D3274.id9874.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D3274.id9874.diff
View Options
diff --git a/.envrc b/.envrc
new file mode 100644
--- /dev/null
+++ b/.envrc
@@ -0,0 +1,11 @@
+# reload when these files change
+watch_file flake.nix
+watch_file flake.lock
+
+{
+ # shell gc root dir, to avoid nix cleaning up nix packages
+ mkdir -p "$(direnv_layout_dir)"
+
+ # load nix development environment
+ eval "$(nix print-dev-env --profile $(direnv_layout_dir)/flake-profile)"
+} || use nix
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,10 @@
server/facts
.eslintcache
.vscode
+
+# Nix
+result
+result-*
+
+# Direnv
+.direnv
diff --git a/docs/dev_environment.md b/docs/dev_environment.md
--- a/docs/dev_environment.md
+++ b/docs/dev_environment.md
@@ -2,6 +2,8 @@
Please note that our dev environment currently only works on macOS and Linux.
+For quickly setting up a dev environment using nix, please go to [nix development environment](./nix_dev_env.md).
+
For the Linux instructions [head to the Linux configuration steps](linux_dev_environment.md).
<details>
diff --git a/flake.lock b/flake.lock
new file mode 100644
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,43 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1641404362,
+ "narHash": "sha256-8j21rw0xwwuiz8uOybm6gbeQIfAga/cwovzr3z1xzOg=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "defafc9a220440180a34f923be9772d9c89a8197",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs",
+ "utils": "utils"
+ }
+ },
+ "utils": {
+ "locked": {
+ "lastModified": 1638122382,
+ "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,33 @@
+{
+ description = "Comm flake";
+
+ inputs = {
+ utils.url = "github:numtide/flake-utils";
+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+ };
+
+ outputs = { self, nixpkgs, utils, ... }:
+ let
+ # put devShell and any other required packages into local overlay
+ localOverlay = import ./nix/overlay.nix;
+ overlays = [
+ localOverlay
+ ];
+
+ pkgsForSystem = system: import nixpkgs {
+ # if you have additional overlays, you may add them here
+ overlays = [
+ localOverlay # this should expose devShell
+ ];
+ inherit system;
+ config.android_sdk.accept_license = true;
+ };
+ # https://github.com/numtide/flake-utils#usage for more examples
+ in utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ] (system: rec {
+ legacyPackages = pkgsForSystem system;
+ inherit (legacyPackages) devShell;
+ }) // {
+ inherit overlays;
+ overlay = nixpkgs.lib.composeManyExtensions overlays;
+ };
+}
diff --git a/nix/android-dev-env.nix b/nix/android-dev-env.nix
new file mode 100644
--- /dev/null
+++ b/nix/android-dev-env.nix
@@ -0,0 +1,22 @@
+{ androidenv }:
+
+androidenv.composeAndroidPackages {
+ toolsVersion = "26.1.1";
+ platformToolsVersion = "31.0.3";
+ buildToolsVersions = [ "31.0.0" ];
+ includeEmulator = false;
+ emulatorVersion = "30.9.0";
+ platformVersions = [ "30" ];
+ includeSources = false;
+ includeSystemImages = false;
+ systemImageTypes = [ "google_apis_playstore" ];
+ abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
+ cmakeVersions = [ "3.10.2" ];
+ includeNDK = true;
+ ndkVersions = ["22.0.7026061"];
+ useGoogleAPIs = false;
+ useGoogleTVAddOns = false;
+ includeExtras = [
+ "extras;google;gcm"
+ ];
+}
diff --git a/nix/dev-shell.nix b/nix/dev-shell.nix
new file mode 100644
--- /dev/null
+++ b/nix/dev-shell.nix
@@ -0,0 +1,46 @@
+{ mkShell
+, stdenv
+, lib
+, androidDevEnv
+, arcanist
+, darwin
+, flow
+, nodejs-16_x
+, openjdk11
+, protobuf3_15
+, yarn
+}:
+
+mkShell rec {
+
+ # programs which are meant to be executed should go here
+ nativeBuildInputs = [
+ arcanist
+ flow
+ nodejs-16_x
+ protobuf3_15
+ yarn
+ ] ++ lib.optionals stdenv.isx86_64 [
+ # aarch64-darwin tarballs are not available
+ androidDevEnv.androidsdk
+ ];
+
+ # include any libraries or programs in buildInputs
+ buildInputs = [
+ protobuf3_15
+ ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
+ CoreFoundation
+ CoreServices
+ Security
+ ]);
+
+ # if a package exposes many commands, libraries, shellhooks, etc. Add here
+ inputsFrom = [
+ openjdk11
+ ];
+
+ # shell commands to be ran upon entering shell
+ shellHook = ''
+ echo "Welcome to Comm dev environment! :)"
+ '';
+}
diff --git a/nix/overlay.nix b/nix/overlay.nix
new file mode 100644
--- /dev/null
+++ b/nix/overlay.nix
@@ -0,0 +1,6 @@
+prev: final: {
+ # add packages meant for just this repository
+ androidDevEnv = prev.callPackage ./android-dev-env.nix { };
+
+ devShell = final.callPackage ./dev-shell.nix { };
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 9:23 PM (19 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2591707
Default Alt Text
D3274.id9874.diff (5 KB)
Attached To
Mode
D3274: Add intial nix yarn dev env
Attached
Detach File
Event Timeline
Log In to Comment