Skip to content

Conversation

@fnune
Copy link

@fnune fnune commented Nov 16, 2025

ℹ️ 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.

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 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

# Install Nix (if needed)
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

# Clone and enter development environment
git clone https://github.com/aarnt/octopi
cd octopi
nix develop

# Build as usual
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 by creating an .envrc file with the contents use 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. 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) should continue to work unchanged.

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.
@aarnt
Copy link
Owner

aarnt commented Nov 16, 2025

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.
Did you try upgrading, installing or removing a package with the executables installed in "/path/to/your/build" ? I think helper will veto the transaction. Take a look at "bool OctopiHelper::isProcessRunningFromPath(pid_t pid)" method from "octopihelper.cpp".

By the way, I was curious to know which feature you were trying to implement :-)

@fnune
Copy link
Author

fnune commented Nov 16, 2025

By the way, I was curious to know which feature you were trying to implement :-)

This was my feature idea: showing a highlight if something within "news" is related to a package you have installed.

image

However, I realized that the data for news is not structured enough to be able to get a package name reliably. E.g. sometimes the message just says "Plasma 6.5 desktop" :/

@fnune
Copy link
Author

fnune commented Nov 16, 2025

I see you did not change "helper/octopihelper.cpp" in your PR. Did you try upgrading, installing or removing a package with the executables installed in "/path/to/your/build" ? I think helper will veto the transaction. Take a look at "bool OctopiHelper::isProcessRunningFromPath(pid_t pid)" method from "octopihelper.cpp".

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?

@aarnt
Copy link
Owner

aarnt commented Nov 24, 2025

Hi @fnune

I merged most of your updates to make qt-sudo path agnostic.
Did not merge *nix specific code. I'm waiting for your next tests.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants