From 813cd12a799876da8179811d9ea998b2ab1413cf Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Mon, 5 Jan 2026 14:44:01 -0500 Subject: [PATCH] Add nsd-pixi-shell.sh script for activating an env Also modified the function to get the path to a manifest to allow for directories to be specified. This makes testing on other systems easier. *To test:* 1. `nsd-pixi-wrap.sh` prints an error an usage message 2. `nsd-pixi-wrap.sh --help` prints the usage message 3. `nsd-pixi-wrap.sh /path/to/dir/with/pixi.toml` runs `pixi shell` with that environment 4. `nsd-pixi-wrap.sh envname` runs `pixi shell` with that environment that is installed in `/usr/local/pixi` 5. `nsd-pixi-wrap.sh garbageenv` prints an error message --- rpm/nsd-app-wrap.spec | 6 +++++- src/nsd-app-wrap.sh | 7 ++++++- src/nsd-pixi-shell.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100755 src/nsd-pixi-shell.sh diff --git a/rpm/nsd-app-wrap.spec b/rpm/nsd-app-wrap.spec index 634294f..c330d0d 100644 --- a/rpm/nsd-app-wrap.spec +++ b/rpm/nsd-app-wrap.spec @@ -1,5 +1,5 @@ Name: nsd-app-wrap -Version: 2.16 +Version: 2.17 Release: 1%{?dist} Summary: Wrapper scripts to launch python applications installed via anaconda Vendor: Peter F. Peterson @@ -47,6 +47,7 @@ install -m 755 mcstas %{buildroot}%{_bindir}/ install -m 755 nr_launcher %{buildroot}%{_bindir}/ install -m 755 nsd-app-wrap.sh %{buildroot}%{_bindir}/ install -m 755 nsd-conda-wrap.sh %{buildroot}%{_bindir}/ +install -m 755 nsd-pixi-shell.sh %{buildroot}%{_bindir}/ install -m 755 nseplot %{buildroot}%{_bindir}/ install -m 755 nxs2taco %{buildroot}%{_bindir}/ install -m 755 paraview %{buildroot}%{_bindir}/ @@ -107,6 +108,9 @@ install -m 644 desktop/ibeatles.desktop %{buildroot}%{_datadir}/a %{_prefix}/share/applications/* %changelog +* Mon Jan 05 2026 Pete Peterson +- Add nsd-pixi-shell.sh for activating an environment + * Tue Dec 16 2025 John Hetrick - Added nxs2taco, a pysen utility diff --git a/src/nsd-app-wrap.sh b/src/nsd-app-wrap.sh index c75a94e..f21218b 100755 --- a/src/nsd-app-wrap.sh +++ b/src/nsd-app-wrap.sh @@ -19,7 +19,11 @@ _get_pixi_manifest_path() { # pixi environment PIXI_ENV="${1}" - echo "${PIXI_PREFIX%/}/${PIXI_ENV}" + if [ -d "${PIXI_ENV}" ]; then + echo "${PIXI_ENV}" + else + echo "${PIXI_PREFIX%/}/${PIXI_ENV}" + fi } ########## Activate the environment in the central pixi install @@ -36,6 +40,7 @@ activate_pixi_environment () { fi # activate the environment + echo "Activating ${PIXI_ENV} environment. Type 'exit' to exit." pixi shell --frozen --manifest-path "${_path_to_manifest}" } diff --git a/src/nsd-pixi-shell.sh b/src/nsd-pixi-shell.sh new file mode 100755 index 0000000..cafbd43 --- /dev/null +++ b/src/nsd-pixi-shell.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +_usage() { + echo "usage: $0 [tool arguments]" +} + +# select the environment to use +if [ -n "$1" ]; then + if [ "$1" == "--help" ]; then + _usage + exit 0 + elif [ "$1" == "-h" ]; then + _usage + exit 0 + fi + PIXI_ENVIRON="$1" + shift # drop this argument +else + echo "Must specify a conda environment to activate" + _usage + exit 255 +fi + +# import library to do the real work +# shellcheck disable=SC1091 +. "$(dirname "$(realpath "$0")")/nsd-app-wrap.sh" || + . /bin/nsd-app-wrap.sh + +activate_pixi_environment "${PIXI_ENVIRON}" -- GitLab