From 7f1bb51d79def57bb901d541488612706d3d4df0 Mon Sep 17 00:00:00 2001 From: fusiled Date: Fri, 3 Jul 2026 15:20:32 -0500 Subject: [PATCH] Rework CLion support. Just easier to use nix develop. --- .gitignore | 3 --- flake.nix | 11 ++++++++--- support/ides/clion/README.md | 13 ++++++------- support/ides/clion/nix-cmake.sh | 29 ---------------------------- support/ides/clion/nix-run.sh | 19 ------------------ support/ides/clion/setup-symlinks.sh | 26 ------------------------- 6 files changed, 14 insertions(+), 87 deletions(-) delete mode 100755 support/ides/clion/nix-cmake.sh delete mode 100755 support/ides/clion/nix-run.sh delete mode 100755 support/ides/clion/setup-symlinks.sh diff --git a/.gitignore b/.gitignore index b97b08f..57b6c38 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,6 @@ /docs/guided_examples/*/build* /docs/guided_examples/flake.lock -# Avoid adding symlinks -/support/ides/clion/* - # Products of SimoSim Simo.log statistics.yaml diff --git a/flake.nix b/flake.nix index c39ed77..8c7daa0 100644 --- a/flake.nix +++ b/flake.nix @@ -87,9 +87,9 @@ }; derivationAttributes = { - default = pkgs.clangStdenv.mkDerivation simoBaseAttributes; - clang = pkgs.clangStdenv.mkDerivation simoBaseAttributes; - gcc = pkgs.gccStdenv.mkDerivation simoBaseAttributes; + default = pkgs.clangStdenv.mkDerivation simoBaseAttributes; + clang = pkgs.clangStdenv.mkDerivation simoBaseAttributes; + gcc = pkgs.gccStdenv.mkDerivation simoBaseAttributes; }; in { @@ -106,11 +106,16 @@ { inputsFrom = [ derivationAttributes.default ]; packages = with pkgs; [ + git + bashInteractive clang-tools ast-grep # For llvm-cov llvmPackages.llvm ]; + shellHook = '' + export SHELL="${pkgs.bashInteractive}/bin/bash" + ''; }; } ); diff --git a/support/ides/clion/README.md b/support/ides/clion/README.md index 66678d1..0c964f2 100644 --- a/support/ides/clion/README.md +++ b/support/ides/clion/README.md @@ -1,11 +1,10 @@ # Use Nix packages in CLion -Based on [this](https://gist.github.com/pmenke-de/2fed80213c48c2fe80891678f4fa3b42), -but reworked to use flakes. +From the terminal, open a development environment with `nix develop`. -1. Run `support/ides/clion/setup-symlinks.sh` to expose some nix binaries -2. In `Settings` -> `Build, Execution, Deployment` -> `Toolchains`, create a new toolchain -3. Set CMake executable to `support/ides/clion/nix-cmake.sh` and the other elements of the -toolchain to the symlinks created in step 1. +Inside the development environment, launch CLion. -Note it is important to set the symlink of ctest to be able to run unit-tests from CLion. \ No newline at end of file +On macOS, this can be done with `open -na "CLion.app"`. + +One issue is that the integrated terminal may complain about `bash: bind: command not found` +and show escape symbol. The solution is to run `nix develop` in the terminal. \ No newline at end of file diff --git a/support/ides/clion/nix-cmake.sh b/support/ides/clion/nix-cmake.sh deleted file mode 100755 index d5fcb49..0000000 --- a/support/ides/clion/nix-cmake.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright 2026 Matteo Fusi and Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Use the cmakeFlags set by Nix - this doesn't work with --build -#FLAGS=$(echo "$@" | grep -e '--build' > /dev/null || echo "$cmakeFlags") -#"$(dirname "$0")"/nix-run.sh cmake ${FLAGS:+"$FLAGS"} "$@" - - -SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd) -PROJECT_DIR=$SCRIPT_DIR/../../../ -set -x -nix develop "$PROJECT_DIR" --command "$SCRIPT_DIR/nix-run.sh" cmake "$@" -exit $? - - diff --git a/support/ides/clion/nix-run.sh b/support/ides/clion/nix-run.sh deleted file mode 100755 index 2486b78..0000000 --- a/support/ides/clion/nix-run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright 2026 Matteo Fusi and Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -set -x -"$@" \ No newline at end of file diff --git a/support/ides/clion/setup-symlinks.sh b/support/ides/clion/setup-symlinks.sh deleted file mode 100755 index 2d426a7..0000000 --- a/support/ides/clion/setup-symlinks.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright 2026 Matteo Fusi and Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd) - -# Run bash inside dev shell to create symlinks -nix develop --command bash -c " - ln -sf $(which ninja) $SCRIPT_DIR/ - ln -sf $(which clang) $SCRIPT_DIR/ - ln -sf $(which clang++) $SCRIPT_DIR/ - ln -sf $(which ctest) $SCRIPT_DIR/ -"