Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nix shell #16359

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
fi

use flake --impure
7 changes: 4 additions & 3 deletions AppRun
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
APPDIR="$(dirname "$(readlink -f "${0}")")"
export GST_PLUGIN_SCANNER="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
export GST_PLUGIN_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH_1_0="${GST_PLUGIN_PATH}"
export GST_PLUGIN_SYSTEM_PATH="${GST_PLUGIN_PATH}"
export GST_PLUGIN_SYSTEM_PATH_1_0="${GST_PLUGIN_PATH}"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib/:${APPDIR}/usr/lib/nss:${LD_LIBRARY_PATH}"
export QT_QPA_PLATFORM="xcb"
# TODO: Remove once qt 5.15.2 support is dropped
# Fixing bug: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1944468
export QTWEBENGINE_CHROMIUM_FLAGS="${QTWEBENGINE_CHROMIUM_FLAGS} --disable-seccomp-filter-sandbox"
export QTWEBENGINEPROCESS_PATH="${APPDIR}/usr/bin/QtWebEngineProcess"

DEFAULT_LANG=en_US.UTF-8
if [[ "$LANG" == "C.UTF-8" ]]
Expand Down
12 changes: 8 additions & 4 deletions AppRun-cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
APPDIR="$(dirname "$(readlink -f "${0}")")"
export GST_PLUGIN_SCANNER="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
export GST_PLUGIN_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib/:${LD_LIBRARY_PATH}"
export GST_PLUGIN_PATH_1_0="${GST_PLUGIN_PATH}"
export GST_PLUGIN_SYSTEM_PATH="${GST_PLUGIN_PATH}"
export GST_PLUGIN_SYSTEM_PATH_1_0="${GST_PLUGIN_PATH}"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib/:${APPDIR}/usr/lib/nss:${LD_LIBRARY_PATH}"
export QT_QPA_PLATFORM="xcb"
# TODO: Remove once qt 5.15.2 support is dropped
# Fixing bug: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1944468
export QTWEBENGINE_CHROMIUM_FLAGS="${QTWEBENGINE_CHROMIUM_FLAGS} --disable-seccomp-filter-sandbox"
export QTWEBENGINEPROCESS_PATH="${APPDIR}/usr/bin/QtWebEngineProcess"

DEFAULT_LANG=en_US.UTF-8
if [[ "$LANG" == "C.UTF-8" ]]
Expand Down
73 changes: 60 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BUILD_SYSTEM_DIR := vendor/nimbus-build-system
all \
nix-shell \
bottles \
check-nix-shell \
check-qt-dir \
check-pkg-target-linux \
check-pkg-target-macos \
Expand Down Expand Up @@ -48,6 +49,31 @@ BUILD_SYSTEM_DIR := vendor/nimbus-build-system
run-storybook-tests \
update

# This is a code for automatic help generator.
# It supports ANSI colors and categories.
# To add new item into help output, simply add comments
# starting with '##'. To add category, use @category.
GREEN := $(shell echo "\e[32m")
WHITE := $(shell echo "\e[37m")
YELLOW := $(shell echo "\e[33m")
RESET := $(shell echo "\e[0m")
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z0-9\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "Usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; \
}

help: SHELL := /bin/sh
help: ##@other Show this help
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)

ifeq ($(NIM_PARAMS),)
# "variables.mk" was not included, so we update the submodules.
GIT_SUBMODULE_UPDATE := git submodule update --init --recursive
Expand All @@ -65,9 +91,14 @@ else # "variables.mk" was included. Business as usual until the end of this file

all: nim_status_client

nix-shell: export NIX_USER_CONF_FILES := $(PWD)/nix/nix.conf
nix-shell:
nix-shell
shell: export NIX_USER_CONF_FILES := $(shell pwd)/nix/nix.conf
shell: ##@prepare Enter into a pre-configured shell
shell:
ifndef IN_NIX_SHELL
nix develop --impure # nixGL needs currentTime
else
@echo "${YELLOW}Nix shell is already active$(RESET)"
endif

# must be included after the default target
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
Expand Down Expand Up @@ -104,6 +135,13 @@ else
RUN_TARGET := run-linux
endif

check-nix-shell:
ifeq ($(detected_OS),Linux)
ifndef IN_NIX_SHELL
$(error Running outside of Nix shell is not supported)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Harsh :D.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't say it wasn't necessary.

endif
endif

check-qt-dir:
ifeq ($(shell qmake -v 2>/dev/null),)
$(error Cannot find your Qt5 installation. Please make sure to export correct Qt installation binaries path to PATH env)
Expand Down Expand Up @@ -333,7 +371,7 @@ statusq-tests:
run-statusq-tests: export QTWEBENGINE_CHROMIUM_FLAGS := "${QTWEBENGINE_CHROMIUM_FLAGS} --disable-seccomp-filter-sandbox"
run-statusq-tests: statusq-tests
echo -e "\033[92mRunning:\033[39m StatusQ Unit Tests"
ctest -V --test-dir $(STATUSQ_BUILD_PATH) ${ARGS}
cd $(STATUSQ_BUILD_PATH) && nixGL ctest -V ${ARGS}

##
## Storybook
Expand Down Expand Up @@ -363,18 +401,21 @@ storybook-build: | storybook-configure
--config $(COMMON_CMAKE_BUILD_TYPE) \
$(HANDLE_OUTPUT)

# This will fix the issue on Ubuntu:
# (nim_status_client:11556): GLib-GIO-ERROR **: 14:15:07.064: Settings schema 'org.gnome.settings-daemon.plugins.xsettings' does not contain a key named 'antialiasing'
run-storybook: export GDK_BACKEND := x11
run-storybook: storybook-build
echo -e "\033[92mRunning:\033[39m Storybook"
$(STORYBOOK_BUILD_PATH)/bin/Storybook
nixGL $(STORYBOOK_BUILD_PATH)/bin/Storybook
caybro marked this conversation as resolved.
Show resolved Hide resolved

run-storybook-tests: storybook-build
echo -e "\033[92mRunning:\033[39m Storybook Tests"
ctest -V --test-dir $(STORYBOOK_BUILD_PATH) -E PagesValidator
cd $(STORYBOOK_BUILD_PATH) && nixGL ctest -V -E PagesValidator

# repeat because of https://bugreports.qt.io/browse/QTBUG-92236 (Qt < 5.15.4)
run-storybook-pages-validator: storybook-build
echo -e "\033[92mRunning:\033[39m Storybook Pages Validator"
ctest -V --test-dir $(STORYBOOK_BUILD_PATH) -R PagesValidator --repeat until-pass:3
cd $(STORYBOOK_BUILD_PATH) && nixGL ctest -V -R PagesValidator --repeat until-pass:3

storybook-clean:
echo -e "\033[92mCleaning:\033[39m Storybook"
Expand Down Expand Up @@ -453,7 +494,7 @@ status-go-clean:
rm -f $(STATUSGO)

export STATUSKEYCARDGO := vendor/status-keycard-go/build/libkeycard/libkeycard.$(LIBSTATUS_EXT)
export STATUSKEYCARDGO_LIBDIR := "$(shell pwd)/$(shell dirname "$(STATUSKEYCARDGO)")"
export STATUSKEYCARDGO_LIBDIR := $(shell pwd)/$(shell dirname "$(STATUSKEYCARDGO)")

status-keycard-go: $(STATUSKEYCARDGO)
$(STATUSKEYCARDGO): | deps
Expand Down Expand Up @@ -578,7 +619,7 @@ ifeq ($(detected_OS),Darwin)
bin/nim_status_client
endif

nim_status_client: force-rebuild-status-go $(NIM_STATUS_CLIENT)
nim_status_client: check-nix-shell force-rebuild-status-go $(NIM_STATUS_CLIENT)

ifdef IN_NIX_SHELL
APPIMAGE_TOOL := appimagetool
Expand Down Expand Up @@ -825,15 +866,21 @@ ICON_TOOL := node_modules/.bin/fileicon
# STATUS_PORT ?= 30306
# WAKUV2_PORT ?= 30307

# This will fix the issue on Ubuntu:
# (nim_status_client:11556): GLib-GIO-ERROR **: 14:15:07.064: Settings schema 'org.gnome.settings-daemon.plugins.xsettings' does not contain a key named 'antialiasing'
run-linux: export GDK_BACKEND := x11
run-linux: export LD_LIBRARY_PATH := $(QT5_LIBDIR):$(STATUSGO_LIBDIR):$(STATUSKEYCARDGO_LIBDIR):$(LD_LIBRARY_PATH)
run-linux: nim_status_client
echo -e "\033[92mRunning:\033[39m bin/nim_status_client"
LD_LIBRARY_PATH="$(QT5_LIBDIR)":"$(STATUSGO_LIBDIR)":"$(STATUSKEYCARDGO_LIBDIR):$(LD_LIBRARY_PATH)" \
./bin/nim_status_client $(ARGS)
nixGL ./bin/nim_status_client $(ARGS)
caybro marked this conversation as resolved.
Show resolved Hide resolved

# This will fix the issue on Ubuntu:
# (nim_status_client:11556): GLib-GIO-ERROR **: 14:15:07.064: Settings schema 'org.gnome.settings-daemon.plugins.xsettings' does not contain a key named 'antialiasing'
run-linux: export GDK_BACKEND := x11
run-linux-gdb: export LD_LIBRARY_PATH := $(QT5_LIBDIR):$(STATUSGO_LIBDIR):$(STATUSKEYCARDGO_LIBDIR):$(LD_LIBRARY_PATH)
run-linux-gdb: nim_status_client
echo -e "\033[92mRunning:\033[39m bin/nim_status_client"
LD_LIBRARY_PATH="$(QT5_LIBDIR)":"$(STATUSGO_LIBDIR)":"$(STATUSKEYCARDGO_LIBDIR):$(LD_LIBRARY_PATH)" \
gdb -ex=r ./bin/nim_status_client $(ARGS)
nixGL gdb -ex=r ./bin/nim_status_client $(ARGS)

run-macos: nim_status_client
mkdir -p bin/StatusDev.app/Contents/{MacOS,Resources}
Expand Down
27 changes: 10 additions & 17 deletions ci/Jenkinsfile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ def isPRBuild = utils.isPRBuild()
def isNightlyBuild = utils.isNightlyBuild()

pipeline {
agent {
/* Necessary image with Ubuntu 20.04 for older Glibc. */
docker {
label 'linux'
image 'statusteam/nim-status-client-build:1.5.0-qt5.15.2'
/* allows jenkins use cat and mounts '/dev/fuse' for linuxdeployqt */
args '--entrypoint="" --cap-add SYS_ADMIN --security-opt apparmor:unconfined --device /dev/fuse'
}
}
agent { label 'linux && x86_64 && nix-2.19' }

parameters {
booleanParam(
Expand Down Expand Up @@ -77,21 +69,22 @@ pipeline {

stages {
stage('Deps') {
steps {
sh 'make update'
sh 'make deps'
}
steps { script {
nix.shell('make update', pure: true)
nix.shell('make deps', pure: true)
} }
}

stage('status-go') {
steps {
sh 'make status-go'
}
steps { script {
nix.shell('make status-go', pure: true)
} }
}

stage('Package') {
steps { script {
linux.bundle('tgz-linux')
//linux.bundle('tgz-linux', nixShell=true)
linux.bundle('tgz-linux', 0, true)
yakimant marked this conversation as resolved.
Show resolved Hide resolved
} }
}

Expand Down
119 changes: 0 additions & 119 deletions ci/Jenkinsfile.linux-nix

This file was deleted.

Loading