From b93b7c567c9b809c8946e04393db9ab01cb07edb Mon Sep 17 00:00:00 2001 From: Anton Iakimov Date: Thu, 10 Oct 2024 12:36:25 +0200 Subject: [PATCH] chore(nix)_: enforce nix shell for Linux --- Makefile | 22 +++++++++++++++------- flake.lock | 38 ++++++++++++++++++++++++++++++++++++++ flake.nix | 10 ++++++++-- nix/shell.nix | 6 ++++++ 4 files changed, 67 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8f94537279..c9f0546bc7 100644 --- a/Makefile +++ b/Makefile @@ -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 \ @@ -104,6 +105,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) + 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) @@ -365,7 +373,7 @@ storybook-build: | storybook-configure run-storybook: storybook-build echo -e "\033[92mRunning:\033[39m Storybook" - $(STORYBOOK_BUILD_PATH)/bin/Storybook + nixGL $(STORYBOOK_BUILD_PATH)/bin/Storybook run-storybook-tests: storybook-build echo -e "\033[92mRunning:\033[39m Storybook Tests" @@ -453,7 +461,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 @@ -578,7 +586,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 @@ -825,15 +833,15 @@ ICON_TOOL := node_modules/.bin/fileicon # STATUS_PORT ?= 30306 # WAKUV2_PORT ?= 30307 +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) +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} diff --git a/flake.lock b/flake.lock index f6f6ce7980..610c444a10 100644 --- a/flake.lock +++ b/flake.lock @@ -14,6 +14,43 @@ "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixgl": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1672992692, + "narHash": "sha256-/eLQLSNIa22ARTZbk+x8i0iE8khe1eiHWkuxgTVXZ7g=", + "owner": "nix-community", + "repo": "nixGL", + "rev": "643e730efb981ffaf8478f441ec9b9aeea1c89f5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixGL", + "rev": "643e730efb981ffaf8478f441ec9b9aeea1c89f5", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1651477912, @@ -33,6 +70,7 @@ "root": { "inputs": { "flake-compat": "flake-compat", + "nixgl": "nixgl", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 51e9e28c71..29ce16aa31 100644 --- a/flake.nix +++ b/flake.nix @@ -3,11 +3,17 @@ # for nix-shell support inputs.flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; - outputs = { self, nixpkgs, flake-compat }: + # pinned last commit which works with nixpkgs 20.09 + inputs.nixgl = { + inputs.nixpkgs.follows = "nixpkgs"; + url = "github:nix-community/nixGL/643e730efb981ffaf8478f441ec9b9aeea1c89f5"; + }; + + outputs = { self, nixpkgs, nixgl, flake-compat }: let pkgs = import nixpkgs { system = "x86_64-linux"; - overlays = [ (import ./nix/overlay.nix) ]; + overlays = [ (import ./nix/overlay.nix) nixgl.overlay ]; }; in { devShells.x86_64-linux.default = pkgs.callPackage ./nix/shell.nix { }; diff --git a/nix/shell.nix b/nix/shell.nix index 56bf21adde..046b5cd172 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -25,6 +25,7 @@ in pkgs.mkShell { # TODO:check the required packages buildInputs = with pkgs; [ + # dev and CI bash curl wget git file unzip jq lsb-release which cacert gnupg linuxdeployqt appimagekit libglvnd # TODO: Qt 5.15.2 fix, review after upgrade @@ -32,6 +33,10 @@ in pkgs.mkShell { go_1_21 go-bindata mockgen protobuf3_20 protoc-gen-go pcre nss pcsclite extra-cmake-modules xorg.libxcb xorg.libX11 libxkbcommon + # dev machine only + nixUnstable # for flake support TODO: remove with nixpkgs upgrade + nixgl.auto.nixGLDefault + gdb ] ++ (with gst_all_1; [ gst-libav gstreamer gst-plugins-bad gst-plugins-base @@ -62,6 +67,7 @@ in pkgs.mkShell { # TODO:check which deps are needed LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath ( [ + libudev0-shim # this only needed to run, not build alsaLib expat fontconfig