status-react/nix
Icaro Motta b9890a9d44
Upgrade shadow-cljs and ClojureScript (#15417)
This commit upgrades Shadow CLJS from 2.11.16 (released on Feb/21) to latest
2.25.0 (Jul/23), so ~1.5 years worth of upgrades. By upgrading shadow we
can finally use the latest major Clojure version 1.11.x.

Why upgrade shadow?

- Shadow CLJS controls the ClojureScript version we can use. In order to use the
  latest major Clojure version we must upgrade Shadow CLJS.

- Shadow CLJS releases new versions very frequently, and if you take a look at
  its changelog https://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md, you'll see
  it had tons and tons of bug fixes over the years. I hope some of them help
  improve the DX for certain contributors who recently reported issues with
  it.

- Clojure 1.11 brings new features, bug fixes and even performance improvements
  (although I think the performance mostly impacts Clojure on the JVM). See the
  changelog https://github.com/clojure/clojure/blob/master/changes.md#changes-to-clojure-in-version-1110

Things that can be beneficial to us, or are interesting nonetheless:

- New :as-alias to be used in require, which is like :as but does not require
  the namespace to load. This means namespaced keywords using :as-alias can't
  cause circular dependency errors. This feature would very useful if we used
  namespaced keywords, but we don't, so...
  https://github.com/clojure/clojure/blob/master/changes.md#22-as-alias-in-require
- New macros run-test and run-test-var to run single test with fixtures and
  report.
- New iteration function, useful for processing paginated data.
  https://www.abhinavomprakash.com/posts/clojure-iteration/
- New update-keys function: applies a function to every key in a map.
- New update-vals function: applies a function to every value in a map.

Examples for update-vals and update-keys. They should perform better than the
common reduce-kv approach since they use a transient data structure.

    (let [m {:a 1 :b 2}]
      (update-vals m inc)) ; => {:a 2, :b 3}
    
    (let [m {:a 1 :b 2}]
      (update-keys m name)) ; => {"a" 1, "b" 2}

Why change namespaces within __tests__ directories?

Any namespace with the word --tests-- throws an error, like the one below. I
didn't bother investigating why, so I changed the guidelines to reflect the new
convention. It's probably related to the double dashes in the name.

    Namespace quo2.components.dividers.--tests--.divider-label-component-spec has a
    segment starting with an invalid JavaScript identifier at line 1
2023-07-28 13:40:54 -03:00
..
deps Upgrade shadow-cljs and ClojureScript (#15417) 2023-07-28 13:40:54 -03:00
lib nix: cleanup of unused variables 2022-05-31 12:03:20 +02:00
mobile upgrade `react-native` from 0.67.5 to 0.69.10 (#16016) 2023-06-14 07:17:41 +05:30
pkgs nix: downgrade watchman to 4.9.0 2023-07-02 08:46:28 +02:00
scripts nix: use Darwin stat command explicitly 2023-06-27 13:25:41 +02:00
status-go Upgrade `react-native` from 0.63.3 to 0.67.5 (#15486) 2023-04-12 15:25:19 +05:30
tools nix: cleanup of unused variables 2022-05-31 12:03:20 +02:00
DETAILS.md nix: use jsbundle derivation for iOS as well 2023-05-22 10:31:09 +02:00
KNOWN_ISSUES.md nix: fix applying nix.conf by using correct env var 2023-06-20 13:55:07 +02:00
README.md nix: build unsigned Android APK, sign separately 2022-05-21 11:10:11 +02:00
config.nix ci: use different IPFS gateway for release builds 2022-08-26 20:02:27 +02:00
default.nix Cleanup 2020-01-10 19:59:54 +01:00
nix.conf nix: build derivation from sources if cache fails 2023-06-25 23:34:59 +02:00
overlay.nix nix: downgrade watchman to 4.9.0 2023-07-02 08:46:28 +02:00
pkgs.nix nix: fix Android SDK on Darwin with nixpkgs system override 2023-06-26 17:33:44 +02:00
shell.nix nix: add missing Apple SDKs to fix make test on macOS 2023-06-24 10:56:21 +02:00
shells.nix nix: upgrade nixpkgs to latest nixos-22.11 2023-06-20 12:53:06 +02:00
targets.nix drop all desktop related files and references 2020-07-08 10:26:51 +02:00

README.md

Description

This folder contains configuration for Nix, a purely functional package manager used by the Status app for its build process.

Configuration

The main config file is nix/nix.conf and its main purpose is defining the binary caches which allow download of packages to avoid having to compile them yourself locally.

Build arguments

We leverage the config argument of standard nixpkgs for our own parameterization of the builds (e.g. to pass a build number or build type).

Here is a sample structure of the config attribute set:

{
  status-im = {
    build-type = "pr";     # Build type (influences which .env file gets used for feature flags)
    build-number = 9999;   # Used for versionCode and CFBundleVersion in Android and iOS respectively
    android = {
      gradle-opts = "";    # Gradle options passed for Android builds
      abi-split = false;   # If APKs should be split based on architectures
      abi-include = "x86"; # Android architectures to build for
    };
    status-go = {
      src-override = "$HOME/my/source/status-go"; # local source override
    };
  };
}

You can see the defaults in nix/config.nix.

Shell

In order to access an interactive Nix shell a user should run make shell.

The Nix shell is started in this repo via the nix/scripts/shell.sh script, which is a wrapper around the nix-shell command and is intended for use with our main Makefile. This allows for an implicit use of nix-shell as the default shell in the Makefile.

Normally the shell starts without any specific target platform, if you want to change that you should export the TARGET env variable with appropriate value:

make shell TARGET=android

This way your shell and all other nix commands should run in a setup that is tailored towards Android development.

For valid values you can check the nix/shells.nix file.

⚠️ WARNING: To have Nix pick up all changes a new nix-shell needs to be spawned.

Using a local status-go repository

If you need to use a locally checked-out status-go repository, you can achieve that by defining the STATUS_GO_SRC_OVERRIDE environment variable:

export STATUS_GO_SRC_OVERRIDE=$GOPATH/src/github.com/status-im/status-go
make release-android

Resources

You can learn more about Nix by watching these presentations:

And you can read nix/DETAILS.md for more information.

Known Issues

See KNOWN_ISSUES.md.