Skip to content

feat: nix flake to build this on nix.#2

Open
dzuberi wants to merge 9 commits into
sobalap:mainfrom
dzuberi:main
Open

feat: nix flake to build this on nix.#2
dzuberi wants to merge 9 commits into
sobalap:mainfrom
dzuberi:main

Conversation

@dzuberi
Copy link
Copy Markdown

@dzuberi dzuberi commented Apr 18, 2026

The flake creates and adds the package, automatically adds the udev rule, fixes the binary location for the systemd service, and enables the systemd service. It worked on my system.

@dzuberi
Copy link
Copy Markdown
Author

dzuberi commented Apr 18, 2026

Fixes #1

@dzuberi
Copy link
Copy Markdown
Author

dzuberi commented Apr 18, 2026

Possible limitation: assumes pipewire and wireplumber are enabled since the service depends on it. Whether to force enable them in the default nixosModule or to just note this in documentation is an open topic.

@sobalap
Copy link
Copy Markdown
Owner

sobalap commented Apr 19, 2026

Hello, appreciate you taking interest in the project.

Possible limitation: assumes pipewire and wireplumber are enabled since the service depends on it. Whether to force enable them in the default nixosModule or to just note this in documentation is an open topic.

I think an assertion or a warning in the flake if pipewire/wireplumber is absent would be ideal.

Then we could merge.

@dzuberi
Copy link
Copy Markdown
Author

dzuberi commented Apr 19, 2026

Assertions added

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Nix flake packaging and a NixOS module to build/install btd700ctl artifacts and integrate udev + systemd user service enablement, plus README documentation for Nix usage.

Changes:

  • Introduce flake.nix with a packages output and nixosModules.default for NixOS integration.
  • Package udev rules and patch/wrap the btd700d systemd user service for Nix store paths.
  • Document Nix flake/module usage in README.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
flake.nix Defines a Nix package derivation, installs udev rules, patches/wraps btd700d, and adds a NixOS module intended to enable the user service.
README.md Adds a Nix configuration snippet showing how to consume the flake’s NixOS module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread flake.nix
homepage = "https://github.com/sobalap/btd700ctl";
license = licenses.lgpl21Only;
platforms = platforms.linux;
mainProgram = "btd700ctl";
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta.mainProgram is set to "btd700ctl", but this project doesn't install an executable with that name (CMake installs btd700d and btd700_example). This will break nix run/nix bundle expectations; set mainProgram to an actually-installed binary or remove it.

Suggested change
mainProgram = "btd700ctl";
mainProgram = "btd700d";

Copilot uses AI. Check for mistakes.
Comment thread flake.nix
buildInputs = with pkgs; [ hidapi ];

postInstall = ''
install -Dm644 ../udev/99-btd700.rules -t $out/lib/udev/rules.d/
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install -Dm644 ... -t $out/lib/udev/rules.d/ relies on the destination directory already existing; with -t this is not guaranteed, so the build can fail on a clean $out. Install directly to the full destination path (or explicitly mkdir -p the directory) to ensure the directory is created.

Suggested change
install -Dm644 ../udev/99-btd700.rules -t $out/lib/udev/rules.d/
install -Dm644 ../udev/99-btd700.rules $out/lib/udev/rules.d/99-btd700.rules

Copilot uses AI. Check for mistakes.
Comment thread flake.nix
buildInputs = with pkgs; [ hidapi ];

postInstall = ''
install -Dm644 ../udev/99-btd700.rules -t $out/lib/udev/rules.d/
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The udev rules source path ../udev/99-btd700.rules is tied to the CMake build directory layout (e.g., $sourceRoot/build). This is brittle and can break if the build directory changes; prefer referencing the source via $src/$sourceRoot (or ${./udev/99-btd700.rules}) so the path is stable.

Suggested change
install -Dm644 ../udev/99-btd700.rules -t $out/lib/udev/rules.d/
install -Dm644 ${./udev/99-btd700.rules} -t $out/lib/udev/rules.d/

Copilot uses AI. Check for mistakes.
Comment thread flake.nix
Comment on lines +64 to +67
systemd.user.services.btd700d = {
wantedBy = [ "default.target" ];
enable = true;
};
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

systemd.user.services.btd700d is enabled without defining serviceConfig.ExecStart/script (or another mechanism) to actually start the daemon. Unless NixOS is meant to enable a unit file provided by systemd.user.packages, this will produce an incomplete unit and fail to start. Either define the unit contents here (ExecStart pointing at ${pkg}/bin/btd700d) or install the packaged user unit via the appropriate systemd.user.packages/unit-enabling pattern.

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines +42 to +53
# nix
inputs = {
btd700ctl = {
url = "github:sobalap/btd700ctl";
inputs.nixpkgs.follows = "nixpkgs";
};
}

modules = [
inputs.btd700ctl.nixosModules.default
]

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new Nix configuration snippet is inside a ```bash code block and is not valid Nix as written (missing trailing semicolons like inputs = { ... }; / `modules = [ ... ];`). Move it to a dedicated `nix` (or untyped) fenced block and make the snippet syntactically correct so users can copy/paste it.

Copilot uses AI. Check for mistakes.
@sobalap
Copy link
Copy Markdown
Owner

sobalap commented Apr 20, 2026

@dzuberi can you address these comments? I'm not particularly familiar with Nix, but they seem reasonable enough for me to care

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.

3 participants