Skip to content

Add Nix flake development shell#14562

Merged
daschuer merged 3 commits into
mixxxdj:mainfrom
yen3k:nix-flake-devshell
Jul 21, 2025
Merged

Add Nix flake development shell#14562
daschuer merged 3 commits into
mixxxdj:mainfrom
yen3k:nix-flake-devshell

Conversation

@yen3k
Copy link
Copy Markdown
Contributor

@yen3k yen3k commented Mar 28, 2025

I created a Nix flake that builds a development shell with all the tools nessecary to build Mixxx.

This is just a convenient way to create isolated environments for projects.

I also prepared changes for the "Compiling on Linux" section in the Wiki that updates the outdated Nix instructions.
I will post the wiki changes here

@github-actions github-actions Bot added the developer experience Issues, bugs and PRs related to the development process, development environment & developer docs label Mar 28, 2025
@yen3k yen3k force-pushed the nix-flake-devshell branch from b7d58a1 to 16e746c Compare March 28, 2025 13:53
@daschuer
Copy link
Copy Markdown
Member

Is there a was with an additional nix_buildenv.sh to match the guide in the readme?
https://github.com/mixxxdj/mixxx/blob/main/README.md

Comment thread tools/flake.nix Outdated
Comment thread tools/flake.nix
@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 29, 2025

Is there a was with an additional nix_buildenv.sh to match the guide in the readme? https://github.com/mixxxdj/mixxx/blob/main/README.md

Are you refering to the shell.nix file that was deleted in this PR? It was really outdated. The instructions on how to use it is still present in the Wiki, but I have also made a request to change that section here

@daschuer
Copy link
Copy Markdown
Member

I meant the instructions for all other targets.
It is

  1. Call xxxx_envionment.sh
  2. Use cnake as usual

Can we do this with nix as well?

@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 30, 2025

Looks to me like the xxx_buildenv.sh scripts install the required programs and libraries system wide.

Nix works a bit different. You can declare all the required programs and libraries that you need for a specific project in a flake, like I have done here, and the you can run nix develop which in this case will drop you into a shell that has everything you need.

I don't think it makes sense to create a script that would essentially just run nix develop. People that uses Nix with flakes would know exactly what to do with the flake.nix.

@daschuer
Copy link
Copy Markdown
Member

My Idea was to just keep the Linux description in the readme generic as possible.

@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 30, 2025

Yea, I see the point.

Just to be clear Nix is not a Linux distro, it is more like a package manager that is used on both Linux and Mac. Then there is NixOS which is a Linux distro that also uses Nix to configure the whole operating system.

So I understand that it can be a bit confusing that the instructions in the Wiki are under "Compiling on Linux", but since the old instructions for the shell.nix were there, I just updated those.

Do you think it would make more sense to add a separate "Compiling with Nix" like this:

Capture

@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 30, 2025

The new commit only installs the Qt6 libraries that are needed for actually getting Mixxx to build.

The debian_buildenv.sh installs additional Qt libraries such as libqt6opengl6-dev and qtkeychain-qt6-dev, but I can't find all the corresponding libraries in the Nix package manager, so I decided to just leave all of them out.

@daschuer
Copy link
Copy Markdown
Member

qtkeychain-qt6-dev
Is required to store the broadcast password in a secure way. Would it be possible that you contribute the nix package to the package manager.

The wiki suggestion looks good. Unfortunately we had to make it read only. I can copy it into the wiki if you propose the required change here.

How does a nix package compare to a flatpack or snap package? How does is compare to vs-code devcontainers #14018

@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 31, 2025

qtkeychain is available in the Nix package manager. But I can't find packages corresponding to libqt6opengl6-dev and libqt6sql6-sqlite. For Qt5 both of these are part of the qt5base package, but it is not clear to me wether they are also part of qt6base.

Figuring out how all the Qt libraries are packaged in the Nix package manager is too big of a task for me.

Don't know about flatpack or snap. But looks like vs-code devcontainers create a docker image and runs everything in there.
A nix shell is just a shell, where the packages and libraries that you need for a project is installed in an isolated fashion and made accessible only to this shell, so it doesn't pollute the system.

@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 31, 2025

Just noticed that there is a problem when the commit hook tries to run clang-format. That definately needs a fix.

@daschuer
Copy link
Copy Markdown
Member

Maybe they are already integrated? I don't think you will be able to compile not run Mixxx without. So if you can anyway, it confirms that they are not extra in nix.

@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 31, 2025

Yea, I just confirmed that MIXXX_USE_QOPENCL is indeed set on a minimal NixOS setup, using the flake.
Also the program is unconditionally including various QSql*** files, so the Qt SQL library seems to be included as well.

Can you guide me on how to check if QtKeychain is working?

@daschuer
Copy link
Copy Markdown
Member

If you find the QtKeychain SO file in the CMakeCache.txt it works. You need to delete that file first, that cmake looks it up again.

@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 31, 2025

I don't see an so file but it looks like it is using QtKeychain as well

From CMakeCache.txt:

//Secure credentials storage support for Live Broadcasting profiles
QTKEYCHAIN:BOOL=ON
...
//The directory containing a CMake configuration file for Qt6Keychain.
Qt6Keychain_DIR:PATH=/nix/store/kj353kcy8d4gyrlpk05gbrifz4f5hivd-qtkeychain-0.14.3/lib/cmake/Qt6Keychain

@yen3k yen3k force-pushed the nix-flake-devshell branch from 7d09521 to c4c9d26 Compare April 2, 2025 20:51
@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Apr 2, 2025

I now tested the flake on a fresh NixOS and Ubuntu system, and it successfully runs the clang-format pre-commit hook and builds Mixxx.

I also updated the changes to the Wiki, explaining how to get the clang-format pre-commit hook working on NixOS.

@yen3k yen3k requested a review from daschuer April 5, 2025 14:03
@TheButlah
Copy link
Copy Markdown

having a nix flake would be quite nice. I wanted to build the project from source on NixOS, which is quite hard without something like this PR.

@Holzhaus
Copy link
Copy Markdown
Member

Thanks for the PR.

One of the reasons for removing the nix files is that we cannot reasonably maintain it when no core team member uses nix. And if a contributor submits a PR witblh changes, we also cannot properly review/test them ourselves.

Would it be possible to submit this to some Nix repo instead? For example, this looks like it might be a good fit:
https://github.com/nix-community/NUR

The then we may link to this repo from our docs/wiki, but the actual maintenance is done by the Nix community (who have the necessary expertise to maintain Nix package files - in contrast to the Mixxx team 🫣)

What do you think?

@TheButlah
Copy link
Copy Markdown

TheButlah commented Jul 17, 2025

Perhaps, mixxx could make a repo under the GitHub org to host the files there? So that maintainership can be handled perhaps by @yen3k but it's still at least discoverable.

The readme could have disclaimers that this is not officially endorsed and is community maintained.

The responsibility of mixxx then just becomes one of delegating ownership.

@TheButlah
Copy link
Copy Markdown

I even would volunteer to own it, as long as the SLA I am giving is:

  • I don't need to be immediately reachable
  • I don't need to provide something functional
  • I just do what I can which is something more than nothing XD

@daschuer
Copy link
Copy Markdown
Member

@TheButlah Thank you for offering to take care for this.

It looks like we have at least two contributors who are willing to maintain the file. The approach taken here is way more straight forward compared to the original nix file we have removed. If it breaks one day, it won't break anything else, so there is a low risk. I don't like the idea to maintain this file in another repository under mixxxdj, because that will increase the maintenance burden even more.
@Holzhaus Is this OK to merge this under these considerations?

@Holzhaus
Copy link
Copy Markdown
Member

Perhaps, mixxx could make a repo under the GitHub org to host the files there? So that maintainership can be handled perhaps by @yen3k but it's still at least discoverable.

I would have thought that something like the "NUR" would be more discoverable than a random repo in the mixxxdj org. But i'm not a Nix user, so this was just my assumption.

@Holzhaus Is this OK to merge this under these considerations?

I think some Nix specific repo makes more sense than our tree, but if you think it makes more sense to merge it here, go ahead 🙂

@daschuer
Copy link
Copy Markdown
Member

Ok, so let's merge it and hope it does not fall apart soon.

@daschuer daschuer merged commit 8185745 into mixxxdj:main Jul 21, 2025
@daschuer
Copy link
Copy Markdown
Member

daschuer commented Mar 8, 2026

@yen3k It looks like we have missed to ask you for permission to publish your work with Mixxx.
Let's do it now. Please sign the Mixxx Contributor Agreement and comment here when you have done so. It gives us permission to distribute your contribution under the GPL v2 or later license and the Apple Mac App Store. It is also helpful for us to have contact information for contributors in case we may need it in the future.

@yen3k
Copy link
Copy Markdown
Contributor Author

yen3k commented Mar 8, 2026

Signed it as yen3k @daschuer

@daschuer
Copy link
Copy Markdown
Member

daschuer commented Mar 9, 2026

Thank you

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

Labels

developer experience Issues, bugs and PRs related to the development process, development environment & developer docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants