mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-24 15:38:56 +00:00
use nix shell for nix-update-* targets
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
447d37e5ca
commit
7517f5235a
8
Makefile
8
Makefile
@ -60,19 +60,19 @@ nix-purge: SHELL := /bin/sh
|
|||||||
nix-purge: ##@nix Completely remove the complete Nix setup
|
nix-purge: ##@nix Completely remove the complete Nix setup
|
||||||
sudo rm -rf /nix ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots
|
sudo rm -rf /nix ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots
|
||||||
|
|
||||||
nix-add-gcroots: SHELL := /bin/sh
|
nix-add-gcroots: export TARGET_OS := none
|
||||||
nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected
|
nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected
|
||||||
scripts/add-nix-gcroots.sh
|
scripts/add-nix-gcroots.sh
|
||||||
|
|
||||||
nix-update-npm: SHELL := /bin/sh
|
nix-update-npm: export TARGET_OS := none
|
||||||
nix-update-npm: ##@nix Update node2nix expressions based on current package.json
|
nix-update-npm: ##@nix Update node2nix expressions based on current package.json
|
||||||
nix/desktop/realm-node/generate-nix.sh
|
nix/desktop/realm-node/generate-nix.sh
|
||||||
|
|
||||||
nix-update-gradle: SHELL := /bin/sh
|
nix-update-gradle: export TARGET_OS := android
|
||||||
nix-update-gradle: ##@nix Update maven nix expressions based on current gradle setup
|
nix-update-gradle: ##@nix Update maven nix expressions based on current gradle setup
|
||||||
nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh
|
nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh
|
||||||
|
|
||||||
nix-update-lein: SHELL := /bin/sh
|
nix-update-lein: export TARGET_OS := none
|
||||||
nix-update-lein: ##@nix Update maven nix expressions based on current lein setup
|
nix-update-lein: ##@nix Update maven nix expressions based on current lein setup
|
||||||
nix/tools/lein/generate-nix.sh nix/lein
|
nix/tools/lein/generate-nix.sh nix/lein
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
stage('Build jsbundle') {
|
stage('Build android jsbundle') {
|
||||||
steps { script {
|
steps { script {
|
||||||
/* build/fetch things required to produce a js-bundle for android
|
/* build/fetch things required to produce a js-bundle for android
|
||||||
* (e.g. maven and node repos) */
|
* (e.g. maven and node repos) */
|
||||||
@ -71,7 +71,6 @@ pipeline {
|
|||||||
stage('Build nix shell deps') {
|
stage('Build nix shell deps') {
|
||||||
steps { script {
|
steps { script {
|
||||||
/* build/fetch things required to instantiate shell.nix for TARGET_OS=all */
|
/* build/fetch things required to instantiate shell.nix for TARGET_OS=all */
|
||||||
nix.shell("nix-build ${args.join(' ')}", pure: false)
|
|
||||||
nix.build(
|
nix.build(
|
||||||
attr: 'shell',
|
attr: 'shell',
|
||||||
args: ['target-os': 'all'],
|
args: ['target-os': 'all'],
|
||||||
@ -83,9 +82,8 @@ pipeline {
|
|||||||
steps { script {
|
steps { script {
|
||||||
sshagent(credentials: ['nix-cache-ssh']) {
|
sshagent(credentials: ['nix-cache-ssh']) {
|
||||||
nix.shell("""
|
nix.shell("""
|
||||||
find /nix/store/ -mindepth 1 -maxdepth 1 \
|
find /nix/store/ -mindepth 1 -maxdepth 1 -type d \
|
||||||
-not -name '.links' -and -not -name '*.lock' \
|
-not -name '*.links' -and -not -name '*-status-react-*' \
|
||||||
-and -not -name '*-status-react-*' \
|
|
||||||
| xargs nix-copy-closure -v --to ${NIX_CACHE_USER}@${NIX_CACHE_HOST}
|
| xargs nix-copy-closure -v --to ${NIX_CACHE_USER}@${NIX_CACHE_HOST}
|
||||||
""",
|
""",
|
||||||
pure: false
|
pure: false
|
||||||
|
@ -17,7 +17,7 @@ The Nix shell is started in this repo via the [`nix/shell.sh`](/nix/shell.sh) sc
|
|||||||
By default the shell starts without any specific target platform, if you want to change that you should export the `TARGET_OS` env variable with the right value:
|
By default the shell starts without any specific target platform, if you want to change that you should export the `TARGET_OS` env variable with the right value:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
TARGET_OS=android make shell
|
make shell TARGET_OS=android
|
||||||
```
|
```
|
||||||
This way your shell and all other nix commands should run in a setup that is tailored towards Android development.
|
This way your shell and all other nix commands should run in a setup that is tailored towards Android development.
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ -z "${IN_NIX_SHELL}" ]]; then
|
||||||
|
echo "Remember to call 'make shell'!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Run this file to regenerate the Nix files in ./output.
|
# Run this file to regenerate the Nix files in ./output.
|
||||||
# Prerequisites: Node, npm, and node2nix (installed with npm i -g https://github.com/svanderburg/node2nix)
|
# Prerequisites: Node, npm, and node2nix (installed with npm i -g https://github.com/svanderburg/node2nix)
|
||||||
@ -38,6 +43,11 @@ EOF
|
|||||||
node_required_version=$($toolversion node)
|
node_required_version=$($toolversion node)
|
||||||
node_major_version=$(echo $node_required_version | cut -d. -f1,1)
|
node_major_version=$(echo $node_required_version | cut -d. -f1,1)
|
||||||
|
|
||||||
|
if ! which node2nix > /dev/null; then
|
||||||
|
echo "Installing node2nix..."
|
||||||
|
nix-env -f '<nixpkgs>' -iA nodePackages.node2nix
|
||||||
|
fi
|
||||||
|
|
||||||
node2nix --nodejs-${node_major_version} --bypass-cache \
|
node2nix --nodejs-${node_major_version} --bypass-cache \
|
||||||
--input $input \
|
--input $input \
|
||||||
--output $output_dir/node-packages.nix \
|
--output $output_dir/node-packages.nix \
|
||||||
|
@ -31,7 +31,7 @@ let
|
|||||||
reactNativeDepsDir = "$NIX_BUILD_TOP/deps"; # Use local writable deps, otherwise (probably due to some interaction between Nix sandboxing and Java) gradle will fail copying directly from the nix store
|
reactNativeDepsDir = "$NIX_BUILD_TOP/deps"; # Use local writable deps, otherwise (probably due to some interaction between Nix sandboxing and Java) gradle will fail copying directly from the nix store
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "gradle-install-android-archives-and-patched-npm-modules";
|
name = "android-gradle-and-npm-modules";
|
||||||
src =
|
src =
|
||||||
let path = ./../../../..; # Import the root /android and /mobile_files folders clean of any build artifacts
|
let path = ./../../../..; # Import the root /android and /mobile_files folders clean of any build artifacts
|
||||||
in builtins.path { # We use builtins.path so that we can name the resulting derivation, otherwise the name would be taken from the checkout directory, which is outside of our control
|
in builtins.path { # We use builtins.path so that we can name the resulting derivation, otherwise the name would be taken from the checkout directory, which is outside of our control
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ -z "${IN_NIX_SHELL}" ]]; then
|
||||||
|
echo "Remember to call 'make shell'!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# This script takes care of generating/updating the maven-sources.nix file
|
# This script takes care of generating/updating the maven-sources.nix file
|
||||||
# representing the offline Maven repo containing the dependencies
|
# representing the offline Maven repo containing the dependencies
|
||||||
@ -8,8 +13,6 @@
|
|||||||
|
|
||||||
set -Eeu
|
set -Eeu
|
||||||
|
|
||||||
. ~/.nix-profile/etc/profile.d/nix.sh
|
|
||||||
|
|
||||||
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
||||||
current_dir=$(cd "${BASH_SOURCE%/*}" && pwd)
|
current_dir=$(cd "${BASH_SOURCE%/*}" && pwd)
|
||||||
inputs_file_path="${current_dir}/maven-inputs.txt"
|
inputs_file_path="${current_dir}/maven-inputs.txt"
|
||||||
|
@ -41,8 +41,7 @@ shellArgs=(
|
|||||||
if [[ -n "${TARGET_OS}" ]]; then
|
if [[ -n "${TARGET_OS}" ]]; then
|
||||||
shellArgs+=("--argstr target-os ${TARGET_OS}")
|
shellArgs+=("--argstr target-os ${TARGET_OS}")
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}Env is missing TARGET_OS, assuming no target platform.${NC}"
|
echo -e "${YELLOW}Env is missing TARGET_OS, assuming no target platform.${NC} See nix/README.md for more details."
|
||||||
echo -e "See nix/README.md for more details."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$TARGET_OS" =~ (linux|windows|darwin|macos) ]]; then
|
if [[ "$TARGET_OS" =~ (linux|windows|darwin|macos) ]]; then
|
||||||
@ -62,7 +61,7 @@ fi
|
|||||||
# ENTER_NIX_SHELL is the fake command used when `make shell` is run.
|
# ENTER_NIX_SHELL is the fake command used when `make shell` is run.
|
||||||
# It is just a special string, not a variable, and a marker to not use `--run`.
|
# It is just a special string, not a variable, and a marker to not use `--run`.
|
||||||
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
|
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
|
||||||
echo -e "${GREEN}Configuring ${_NIX_ATTR:-default} Nix shell for target '${TARGET_OS}'...${NC}"
|
echo -e "${GREEN}Configuring ${_NIX_ATTR:-default} Nix shell for target '${TARGET_OS:-none}'...${NC}"
|
||||||
exec nix-shell ${shellArgs[@]} ${entryPoint}
|
exec nix-shell ${shellArgs[@]} ${entryPoint}
|
||||||
else
|
else
|
||||||
# Not all builds are ready to be run in a pure environment
|
# Not all builds are ready to be run in a pure environment
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ -z "${IN_NIX_SHELL}" ]]; then
|
||||||
|
echo "Remember to call 'make shell'!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# This script takes care of generating/updating the nix files in the directory passed as a single argument.
|
# This script takes care of generating/updating the nix files in the directory passed as a single argument.
|
||||||
# For this, we start with a clean cache (in ./.m2~/repository/) and call cljsbuild
|
# For this, we start with a clean cache (in ./.m2~/repository/) and call cljsbuild
|
||||||
# to cause it to download all the artifacts. At the same time, we note them
|
# to cause it to download all the artifacts. At the same time, we note them
|
||||||
@ -8,8 +13,6 @@
|
|||||||
|
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
. ~/.nix-profile/etc/profile.d/nix.sh
|
|
||||||
|
|
||||||
output_dir=$1
|
output_dir=$1
|
||||||
mkdir -p $output_dir
|
mkdir -p $output_dir
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -Eeu
|
if [[ -z "${IN_NIX_SHELL}" ]]; then
|
||||||
|
echo "Remember to call 'make shell'!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
. ~/.nix-profile/etc/profile.d/nix.sh
|
set -Eeu
|
||||||
|
|
||||||
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
||||||
|
|
||||||
|
39
shell.nix
39
shell.nix
@ -14,10 +14,8 @@ let
|
|||||||
platform = pkgs.callPackage ./nix/platform.nix { inherit target-os; };
|
platform = pkgs.callPackage ./nix/platform.nix { inherit target-os; };
|
||||||
# TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib)
|
# TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib)
|
||||||
stdenv = pkgs.stdenvNoCC;
|
stdenv = pkgs.stdenvNoCC;
|
||||||
|
# those should always be present in a shell
|
||||||
in mkShell {
|
coreInputs = with pkgs; [
|
||||||
name = "status-react-shell";
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
# utilities
|
# utilities
|
||||||
bash
|
bash
|
||||||
curl
|
curl
|
||||||
@ -25,17 +23,30 @@ in mkShell {
|
|||||||
git
|
git
|
||||||
gnumake
|
gnumake
|
||||||
jq
|
jq
|
||||||
ncurses
|
|
||||||
lsof # used in scripts/start-react-native.sh
|
|
||||||
ps # used in scripts/start-react-native.sh
|
|
||||||
unzip
|
|
||||||
wget
|
wget
|
||||||
|
|
||||||
clojure
|
|
||||||
leiningen
|
|
||||||
maven
|
|
||||||
watchman
|
|
||||||
];
|
];
|
||||||
inputsFrom = [ project.shell ];
|
|
||||||
|
in mkShell {
|
||||||
|
name = "status-react-shell";
|
||||||
|
# none means we shouldn't include project specific deps
|
||||||
|
buildInputs = if target-os == "none" then
|
||||||
|
coreInputs
|
||||||
|
else
|
||||||
|
with pkgs; [
|
||||||
|
unzip
|
||||||
|
ncurses
|
||||||
|
lsof # used in scripts/start-react-native.sh
|
||||||
|
ps # used in scripts/start-react-native.sh
|
||||||
|
clojure
|
||||||
|
leiningen
|
||||||
|
maven
|
||||||
|
watchman
|
||||||
|
] ++ coreInputs;
|
||||||
|
|
||||||
|
inputsFrom = if target-os == "none" then
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
[ project.shell ];
|
||||||
|
|
||||||
shellHook = project.shell.shellHook;
|
shellHook = project.shell.shellHook;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user