Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
/cmake-build-*
/docs/guided_examples/*/build*
/docs/guided_examples/flake.lock
# Avoid adding symlinks
/support/ides/clion/*


*.DS_Store
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ it is missing: a simple, easy to use library that does what you need.

## Documentation

Guides (Markdown files inside `docs` folder) and Doxygen built from the main branch are stored in **[GitHub Pages](https://fusiled.github.io/Simo/)** .

## Get and initialize the repository
**[GitHub Pages](https://fusiled.github.io/Simo/)** stores Doxygen documentation and guides (Markdown files inside `docs` folder).

## Get the repository and build in 3 commands
Assuming [nix](https://nixos.org/learn/):
```bash
git clone https://github.com/fusiled/Simo
cd Simo
nix build
```
The build is going to be accessible in the `result` folder.

## Build

Expand Down Expand Up @@ -67,6 +69,10 @@ This can be achieved with:
- Good documented code
- Proper unit-testing coverage

### IDEs
You can see [this guide](./support/ides/clion/README.md) on how to use nix
binaries to build in CLion.

## To Do
- Create a collector with periodic window collection functionality
- More documentation and examples
Expand Down
45 changes: 28 additions & 17 deletions docs/guided_examples/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,35 @@
simo.inputs.flake-utils.follows = "flake-utils";
};

outputs = { self, nixpkgs, flake-utils, simo }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
simo,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
devShells.default = pkgs.mkShell.override {
stdenv = pkgs.clangStdenv;
} {
packages = with pkgs; [
boost
cmake
ninja
llvm
glaze
doxygen
simo.packages.${system}.default
];
};
});
}
devShells.default =
pkgs.mkShell.override
{
stdenv = pkgs.clangStdenv;
}
{
packages = with pkgs; [
boost
cmake
ninja
llvm
glaze
doxygen
simo.packages.${system}.default
];
};
}
);
}
43 changes: 25 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
simo = pkgs.clangStdenv.mkDerivation {
Expand All @@ -29,6 +35,7 @@
src = ./.;

nativeBuildInputs = with pkgs; [
# Real build dependencies
cmake
ninja
doxygen
Expand All @@ -47,28 +54,28 @@

doCheck = true;
checkPhase = ''
ls *.so
ctest --output-on-failure
'';
};
in {
in
{
packages.default = simo;
checks.default = simo;

devShells.default = pkgs.mkShell.override {
stdenv = pkgs.clangStdenv;
} {
packages = with pkgs; [
boost
cmake
ninja
clang-tools
llvm
glaze
doxygen
ast-grep
];
};
formatter = nixpkgs.legacyPackages.${system}.nixfmt;

devShells.default =
pkgs.mkShell.override
{
stdenv = pkgs.clangStdenv;
}
{
inputsFrom = [ simo ];
packages = with pkgs; [
clang-tools
ast-grep
];
};
}
);
}
11 changes: 11 additions & 0 deletions support/ides/clion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Use Nix packages in CLion

Based on [this](https://gist.github.com/pmenke-de/2fed80213c48c2fe80891678f4fa3b42),
but reworked to use flakes.

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.

Note it is important to set the symlink of ctest to be able to run unit-tests from CLion.
29 changes: 29 additions & 0 deletions support/ides/clion/nix-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/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 $?


19 changes: 19 additions & 0 deletions support/ides/clion/nix-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/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
"$@"
26 changes: 26 additions & 0 deletions support/ides/clion/setup-symlinks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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/
"