-
Notifications
You must be signed in to change notification settings - Fork 94
Add Nix build system for development #610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Note: This PR is tentative and I would completely understand if you want to close it as off-topic. I was originally trying to implement a feature, gave up on it, but ended up with this Nix build system as an artifact. I thought it might be useful for others, but no worries if it doesn't fit the project's direction. This PR adds Nix flake support to enable clean, isolated development without installing dependencies system-wide. Motivation Building Octopi currently requires manually cloning and installing alpm_octopi_utils, qt-sudo, Qt6 libraries, vala, and other tools system-wide. This makes it difficult to test changes without replacing your system installation of Octopi, pollutes the system with development dependencies, and complicates development on non-Arch systems. The Nix-based development environment solves this by providing isolated, reproducible builds with all dependencies managed automatically. What's included The flake provides a complete development shell with Qt6, CMake, vala, and all required libraries. It automatically builds alpm_octopi_utils and qt-sudo from source and sets up the environment for development. After entering the shell, you can build with CMake or qmake just like the existing instructions. Quick start curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install git clone https://github.com/aarnt/octopi cd octopi nix develop mkdir -p build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j\$(nproc) ./octopi Optional: use direnv for automatic environment loading when entering the directory. Code changes To make Octopi work in non-FHS environments like Nix, a few portable changes were needed: The code previously assumed executables were in /usr/bin/ and hardcoded /usr/local/bin/qt-sudo. Now hasTheExecutable() searches the entire PATH using QStandardPaths::findExecutable(), and a new findExecutable() function provides the full path to executables. This works across different Linux distributions and installation methods. For development, the build now checks the OCTOPI_ALLOWED_PATHS environment variable to allow running from build directories. Production installs are unaffected and still require /usr/bin/ for security. All existing build methods (qmake, CMake, PKGBUILD) continue to work unchanged.
|
Hi Fausto, thanks for this nice contrib! I've never used Nix before, but people use to say very good things about this project (both distro and pkg manager). I see you did not change "helper/octopihelper.cpp" in your PR. By the way, I was curious to know which feature you were trying to implement :-) |
I saw other hard-coded paths. I think they may need to be updated for things to work with Nix. Maybe the full functionality (as you suggest) is not working properly when building with Nix. I will try more things later today and report back! If there are incremental changes that can be upstreamed more slowly (e.g. using the standard paths helpers) maybe those are good contributions, too? |
|
Hi @fnune I merged most of your updates to make qt-sudo path agnostic. Thanks! |

This PR adds Nix flake support to enable clean, isolated development without installing dependencies system-wide.
Screencast_20251116_134654.webm
Motivation
Building Octopi currently requires manually cloning and installing
alpm_octopi_utils,qt-sudo, Qt6 libraries, vala, and other tools system-wide. This makes it difficult to test changes without replacing your system installation of Octopi, pollutes the system with development dependencies, etc. This Nix-based development environment solves this by providing isolated, reproducible builds with all dependencies managed automatically in a development shell with Qt6, CMake, vala, and all required libraries. It automatically buildsalpm_octopi_utilsandqt-sudofrom source and sets up the environment for development. After entering the shell, you can build with CMake or qmake just like the existing instructions.Quick start
Optional: use
direnvfor automatic environment loading when entering the directory by creating an.envrcfile with the contentsuse flake.Code changes
To make Octopi work in non-FHS environments like Nix, a few portable changes were needed:
The code previously assumed executables were in
/usr/bin/and hardcoded/usr/local/bin/qt-sudo. NowhasTheExecutable()searches the entirePATHusingQStandardPaths::findExecutable(), and a newfindExecutable()function provides the full path to executables. This works across different Linux distributions and installation methods.For development, the build now checks the
OCTOPI_ALLOWED_PATHSenvironment variable to allow running from build directories. Production installs are unaffected and still require/usr/bin/for security.All existing build methods (
qmake,CMake,PKGBUILD) should continue to work unchanged.