Always prefix package.nix path with ./ in overlay.nix

Without this, nixified package in the current directory fails to
evaluate with "error: undefined variable 'package'".
This commit is contained in:
Michal Sojka 2025-03-31 10:11:40 +02:00
parent dc2eef69c1
commit a78551449b
2 changed files with 9 additions and 3 deletions

View file

@ -2,7 +2,7 @@
# PYTHON_ARGCOMPLETE_OK
# Copyright 2019-2024 Ben Wolsieffer <benwolsieffer@gmail.com>
# Copyright 2024 Michal Sojka <michal.sojka@cvut.cz>
# Copyright 2024, 2025 Michal Sojka <michal.sojka@cvut.cz>
from os.path import dirname
import argcomplete, argparse
@ -105,9 +105,9 @@ def generate_overlay(expressions: dict[str, str], args):
expr = (
expressions[pkg]
if args.output_dir is None
else f"./{os.path.basename(expressions[pkg])}"
else os.path.basename(expressions[pkg])
)
print(f" {pkg} = final.callPackage {expr} {{}};", file=f)
print(f" {pkg} = final.callPackage ./{expr} {{}};", file=f)
print("}", file=f)

View file

@ -18,6 +18,12 @@ load common.bash
nix-build -A rosPackages.humble.ros-node -A rosPackages.jazzy.ros-node -A rosPackages.rolling.ros-node
}
@test "nixify package in the current directory" {
cd ws/src/library
ros2nix package.xml
nix-build -A rosPackages.jazzy.library
}
@test "--output-as-nix-pkg-name" {
ros2nix --output-as-nix-pkg-name $(find ws/src -name package.xml)
assert [ -f ros-node.nix ]