From c693637fafd48d05f8825c101aa5d1cf355bb6c7 Mon Sep 17 00:00:00 2001 From: Egor Savkin Date: Tue, 20 Jun 2023 16:18:45 +0800 Subject: [PATCH 1/2] Add booster add-on configuration Signed-off-by: Egor Savkin --- README | 5 +++++ booster/booster_shell.nix | 27 +++++++++++++++++++++++++++ booster/gmqtt.nix | 32 ++++++++++++++++++++++++++++++++ booster/miniconf.nix | 22 ++++++++++++++++++++++ booster/mqtt-explorer.nix | 20 ++++++++++++++++++++ 5 files changed, 106 insertions(+) create mode 100644 booster/booster_shell.nix create mode 100644 booster/gmqtt.nix create mode 100644 booster/miniconf.nix create mode 100644 booster/mqtt-explorer.nix diff --git a/README b/README index 24d732a..b97353d 100644 --- a/README +++ b/README @@ -8,3 +8,8 @@ * sudo nixos-rebuild boot * sudo nix-collect-garbage -d * history clear + +Add-on for Boosters: +* copy `booster` to the /opt +* mkdir -p ~/.config/nixpkgs && echo '{permittedInsecurePackages = ["electron-9*"];}' > ~/.config/nixpkgs/config.nix +* echo 'For Booster-related apps, use `nix-shell /opt/booster/booster_shell.nix`' > ~/README.md \ No newline at end of file diff --git a/booster/booster_shell.nix b/booster/booster_shell.nix new file mode 100644 index 0000000..11a2e0c --- /dev/null +++ b/booster/booster_shell.nix @@ -0,0 +1,27 @@ +let + + pkgs = import { }; + + mqtt-explorer = pkgs.callPackage /opt/booster/mqtt-explorer.nix {} ; + gmqtt = pkgs.callPackage /opt/booster/gmqtt.nix {}; + miniconf = pkgs.callPackage /opt/booster/miniconf.nix {}; + +in + pkgs.mkShell { + buildInputs = [ + (pkgs.python3.withPackages(ps: [ + ps.numpy + ps.setuptools + ps.matplotlib + gmqtt + miniconf + ])) + pkgs.libtool + pkgs.libusb1 + pkgs.mosquitto + pkgs.libftdi + pkgs.cutecom + mqtt-explorer + ]; + } + diff --git a/booster/gmqtt.nix b/booster/gmqtt.nix new file mode 100644 index 0000000..73b8f76 --- /dev/null +++ b/booster/gmqtt.nix @@ -0,0 +1,32 @@ +{ stdenv, lib, python3Packages, fetchFromGitHub, fetchgit, makeWrapper, pkgs }: + +python3Packages.buildPythonPackage rec { + name = "gmqtt"; + version = "v0.6.12"; + src = fetchFromGitHub { + owner = "wialon" ; + repo = "gmqtt"; + rev = "190d12156890efcfc5099fea0f7ef3ce072c4a27" ; + sha256 = "sha256-lhvRRZsrJy2U7b705GTlquAP/LwKEmInuVC4zzivmKk="; + }; + + buildInputs = [ + (pkgs.python3.withPackages(ps: [ + ps.codecov + ps.pytest-asyncio + ps.pytest + ps.pytestcov + ps.six + ps.uvloop + ps.more-itertools + ps.atomicwrites + ])) + ]; + + propagatedBuildInputs = with pkgs.python3Packages; [ setproctitle ]; + + meta = { + homepage = "https://github.com/wialon/gmqtt"; + description = "gmqtt"; + }; +} \ No newline at end of file diff --git a/booster/miniconf.nix b/booster/miniconf.nix new file mode 100644 index 0000000..94fe88b --- /dev/null +++ b/booster/miniconf.nix @@ -0,0 +1,22 @@ +{ stdenv, lib, python3Packages, callPackage, fetchgit, makeWrapper }: + +let +gmqtt = callPackage /opt/booster/gmqtt.nix {}; +in +python3Packages.buildPythonPackage rec { + pname = "miniconf"; + version = "0.1.0"; + src = fetchgit { + url = "https://github.com/quartiq/miniconf"; + rev = "01caac4adb3f81cbcd34d8a48087f5df962c096f"; + sha256 = "sha256-ssRV4FtdMehPA4+mKQ4Ub+wtEakpKX5jXRubFtHpanA="; + }; + prePatch = '' + cd py/miniconf-mqtt + ''; + doCheck = false; + propagatedBuildInputs = [ + # Specify dependencies + gmqtt + ]; +} \ No newline at end of file diff --git a/booster/mqtt-explorer.nix b/booster/mqtt-explorer.nix new file mode 100644 index 0000000..2b17bda --- /dev/null +++ b/booster/mqtt-explorer.nix @@ -0,0 +1,20 @@ +{ stdenv, lib, fetchurl, appimageTools, electron_9, makeWrapper }: + +stdenv.mkDerivation rec { + pname = "MQTT-Explorer"; + version = "0.4.0-beta1"; + src = appimageTools.extract { + name = pname; + src = fetchurl { + url = "https://github.com/thomasnordquist/${pname}/releases/download/0.0.0-${version}/${pname}-${version}.AppImage"; + sha256 = "0x9ava13hn1nkk2kllh5ldi4b3hgmgwahk08sq48yljilgda4ppn"; + }; + }; + buildInputs = [ makeWrapper ]; + installPhase = '' + install -m 444 -D resources/app.asar $out/libexec/app.asar + install -m 444 -D mqtt-explorer.png $out/share/icons/mqtt-explorer.png + install -m 444 -D mqtt-explorer.desktop $out/share/applications/mqtt-explorer.desktop + makeWrapper ${electron_9}/bin/electron $out/bin/mqtt-explorer --add-flags $out/libexec/app.asar + ''; +} \ No newline at end of file -- 2.47.0 From 2b5e037a471114043fed49ec964443792b68fe7a Mon Sep 17 00:00:00 2001 From: Egor Savkin Date: Thu, 13 Jul 2023 17:40:23 +0800 Subject: [PATCH 2/2] Make booster packages system-wide Signed-off-by: Egor Savkin --- README | 5 +---- booster/booster_shell.nix | 27 --------------------------- booster/gmqtt.nix | 28 ++++++++++++++-------------- booster/miniconf.nix | 34 ++++++++++++++++------------------ booster/mqtt-explorer.nix | 24 +++++++++++------------- default.nix | 1 + final/configuration.nix | 9 +++++++++ 7 files changed, 52 insertions(+), 76 deletions(-) delete mode 100644 booster/booster_shell.nix diff --git a/README b/README index b97353d..8de69f5 100644 --- a/README +++ b/README @@ -9,7 +9,4 @@ * sudo nix-collect-garbage -d * history clear -Add-on for Boosters: -* copy `booster` to the /opt -* mkdir -p ~/.config/nixpkgs && echo '{permittedInsecurePackages = ["electron-9*"];}' > ~/.config/nixpkgs/config.nix -* echo 'For Booster-related apps, use `nix-shell /opt/booster/booster_shell.nix`' > ~/README.md \ No newline at end of file +Add-on for Boosters: uncomment packages in configuration.nix before auto-install. diff --git a/booster/booster_shell.nix b/booster/booster_shell.nix deleted file mode 100644 index 11a2e0c..0000000 --- a/booster/booster_shell.nix +++ /dev/null @@ -1,27 +0,0 @@ -let - - pkgs = import { }; - - mqtt-explorer = pkgs.callPackage /opt/booster/mqtt-explorer.nix {} ; - gmqtt = pkgs.callPackage /opt/booster/gmqtt.nix {}; - miniconf = pkgs.callPackage /opt/booster/miniconf.nix {}; - -in - pkgs.mkShell { - buildInputs = [ - (pkgs.python3.withPackages(ps: [ - ps.numpy - ps.setuptools - ps.matplotlib - gmqtt - miniconf - ])) - pkgs.libtool - pkgs.libusb1 - pkgs.mosquitto - pkgs.libftdi - pkgs.cutecom - mqtt-explorer - ]; - } - diff --git a/booster/gmqtt.nix b/booster/gmqtt.nix index 73b8f76..d6a8312 100644 --- a/booster/gmqtt.nix +++ b/booster/gmqtt.nix @@ -4,23 +4,23 @@ python3Packages.buildPythonPackage rec { name = "gmqtt"; version = "v0.6.12"; src = fetchFromGitHub { - owner = "wialon" ; - repo = "gmqtt"; - rev = "190d12156890efcfc5099fea0f7ef3ce072c4a27" ; - sha256 = "sha256-lhvRRZsrJy2U7b705GTlquAP/LwKEmInuVC4zzivmKk="; + owner = "wialon"; + repo = "gmqtt"; + rev = "190d12156890efcfc5099fea0f7ef3ce072c4a27"; + sha256 = "sha256-lhvRRZsrJy2U7b705GTlquAP/LwKEmInuVC4zzivmKk="; }; buildInputs = [ - (pkgs.python3.withPackages(ps: [ - ps.codecov - ps.pytest-asyncio - ps.pytest - ps.pytestcov - ps.six - ps.uvloop - ps.more-itertools - ps.atomicwrites - ])) + (pkgs.python3.withPackages (ps: [ + ps.codecov + ps.pytest-asyncio + ps.pytest + ps.pytestcov + ps.six + ps.uvloop + ps.more-itertools + ps.atomicwrites + ])) ]; propagatedBuildInputs = with pkgs.python3Packages; [ setproctitle ]; diff --git a/booster/miniconf.nix b/booster/miniconf.nix index 94fe88b..2f54f31 100644 --- a/booster/miniconf.nix +++ b/booster/miniconf.nix @@ -1,22 +1,20 @@ { stdenv, lib, python3Packages, callPackage, fetchgit, makeWrapper }: -let -gmqtt = callPackage /opt/booster/gmqtt.nix {}; -in -python3Packages.buildPythonPackage rec { - pname = "miniconf"; - version = "0.1.0"; - src = fetchgit { - url = "https://github.com/quartiq/miniconf"; - rev = "01caac4adb3f81cbcd34d8a48087f5df962c096f"; - sha256 = "sha256-ssRV4FtdMehPA4+mKQ4Ub+wtEakpKX5jXRubFtHpanA="; - }; - prePatch = '' - cd py/miniconf-mqtt - ''; - doCheck = false; - propagatedBuildInputs = [ +let gmqtt = callPackage ./gmqtt.nix { }; +in python3Packages.buildPythonPackage rec { + pname = "miniconf"; + version = "0.1.0"; + src = fetchgit { + url = "https://github.com/quartiq/miniconf"; + rev = "01caac4adb3f81cbcd34d8a48087f5df962c096f"; + sha256 = "sha256-Gco56sl2mQ2y+M1evzLhtuFvrhJZbAvbIq7N6J9uiFE="; + }; + prePatch = '' + cd py/miniconf-mqtt + ''; + doCheck = false; + propagatedBuildInputs = [ # Specify dependencies - gmqtt - ]; + gmqtt + ]; } \ No newline at end of file diff --git a/booster/mqtt-explorer.nix b/booster/mqtt-explorer.nix index 2b17bda..6a826b8 100644 --- a/booster/mqtt-explorer.nix +++ b/booster/mqtt-explorer.nix @@ -1,20 +1,18 @@ -{ stdenv, lib, fetchurl, appimageTools, electron_9, makeWrapper }: +{ stdenvNoCC, lib, fetchurl, appimage-run, makeWrapper, symlinkJoin }: -stdenv.mkDerivation rec { +let pname = "MQTT-Explorer"; version = "0.4.0-beta1"; - src = appimageTools.extract { - name = pname; - src = fetchurl { - url = "https://github.com/thomasnordquist/${pname}/releases/download/0.0.0-${version}/${pname}-${version}.AppImage"; - sha256 = "0x9ava13hn1nkk2kllh5ldi4b3hgmgwahk08sq48yljilgda4ppn"; - }; + mqtt-explorer = fetchurl { + url ="https://github.com/thomasnordquist/${pname}/releases/download/0.0.0-${version}/${pname}-${version}.AppImage"; + sha256 = "0x9ava13hn1nkk2kllh5ldi4b3hgmgwahk08sq48yljilgda4ppn"; }; +in symlinkJoin { + name = "mqtt-explorer"; + paths = [ appimage-run ]; buildInputs = [ makeWrapper ]; - installPhase = '' - install -m 444 -D resources/app.asar $out/libexec/app.asar - install -m 444 -D mqtt-explorer.png $out/share/icons/mqtt-explorer.png - install -m 444 -D mqtt-explorer.desktop $out/share/applications/mqtt-explorer.desktop - makeWrapper ${electron_9}/bin/electron $out/bin/mqtt-explorer --add-flags $out/libexec/app.asar + postBuild = '' + mv $out/bin/appimage-run $out/bin/mqtt-explorer + wrapProgram $out/bin/mqtt-explorer --add-flags "${mqtt-explorer}" ''; } \ No newline at end of file diff --git a/default.nix b/default.nix index 4ce3499..04ba339 100644 --- a/default.nix +++ b/default.nix @@ -40,6 +40,7 @@ let mount /dev/disk/by-label/boot /mnt/boot nixos-generate-config --root /mnt cp ${./final}/* /mnt/etc/nixos + cp ${./booster}/* /mnt/etc/nixos/ nixos-install --no-root-password --flake /mnt/etc/nixos#artiq ''; diff --git a/final/configuration.nix b/final/configuration.nix index 8cefd58..ef21d84 100644 --- a/final/configuration.nix +++ b/final/configuration.nix @@ -55,6 +55,9 @@ pyserial spyder artiq.packages.x86_64-linux.artiq + ## Booster python packages: + # (callPackage ./gmqtt.nix { }) + # (callPackage ./miniconf.nix { }) ])) artiq.packages.x86_64-linux.openocd-bscanspi texlive.combined.scheme-full @@ -69,6 +72,12 @@ gnome3.gnome-tweaks libreoffice-fresh vscode + ## Booster packages: + # mosquitto + # libftdi + # libusb1 + # cutecom + # (pkgs.callPackage ./mqtt-explorer.nix { }) ]; programs.wireshark.enable = true; programs.wireshark.package = pkgs.wireshark; -- 2.47.0