I want to use both
jira-cli-go
and
go-jira
, but they both have “jira” as the binary name
Is there some way to have one called jira-cli-go and the other go-jira?
I want to use both
jira-cli-go
and
go-jira
, but they both have “jira” as the binary name
Is there some way to have one called jira-cli-go and the other go-jira?
Hah, awkward. I think the easiest solution is to just get their full paths, but if you want them to show up with different binary names in $PATH
you’ll have to make some kind of wrapper.
I think this should work:
environment.systemPackages = [
(pkgs.runCommand "jira-cli-go" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
mkdir -p $out/bin
makeWrapper --argv0 jira ${pkgs.jira-cli-go}/bin/jira $out/bin/jira-cli-go
'')
];
Hmm, no;)
(pkgs.runCommand "jira-cli-go" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
mkdir -p $out/bin
makeWrapper --argv0 jira ${pkgs.jira-cli-go}/bin/jira $out/bin/jira-cli-go
'')
(pkgs.runCommand "go-jira" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
mkdir -p $out/bin
makeWrapper --argv0 jira ${pkgs.go-jira}/bin/jira $out/bin/go-jira
'')
building Nix...
building the system configuration...
these 18 derivations will be built:
/nix/store/fd8cbnpf1qwy08bph7gj5qm0z7f7bdrw-go-jira.drv
/nix/store/yd1hhvrx5j3dkfapfckqmpgs7iq67d6g-jira-cli-go.drv
/nix/store/1r6r1wc8rb665sqar04w2kshsbfs5g7z-system-path.drv
/nix/store/kdy02l6m3x8x8x26xvin31xmcacps3mv-dbus-1.drv
/nix/store/iblz4aqgqi1vqjjdrqahzbzqf922pg84-X-Restart-Triggers.drv
/nix/store/fd75siaksn781cv1c3r5xl98iqv83iwd-unit-dbus.service.drv
/nix/store/820r3pvz0j90fbsdcn185mcbs4cnz73p-user-units.drv
/nix/store/dvcazc9bdcflysvwamk5mprvdf0zbh43-set-environment.drv
/nix/store/bhzifz06xi5ikcwxr83iz9b2q1ll3dcn-etc-profile.drv
/nix/store/l5bk5kmhgfp93mjn4bjwwlnp0alxqn0j-etc-environment.drv
/nix/store/35q462lxdmp4d3jn556f42bd45jv465s-unit-accounts-daemon.service.drv
/nix/store/j5fxxa1a5qf8xzg1fw3j02rmjxwfkni7-unit-dbus.service.drv
/nix/store/80mlxfrb1127pkshp499i8lmsd54ld4k-X-Restart-Triggers.drv
/nix/store/m2j1kg5v5xdmk3vajzrxdgn9xfhprgyg-unit-polkit.service.drv
/nix/store/zkbg16gd60b8invyjkm3m9p9cjgbi3gy-unit-systemd-fsck-.service.drv
/nix/store/q89sdnrpnwx1700g9bd13cw2743lkiyd-system-units.drv
/nix/store/dddk1ml2nr8bn671n9wyb6dialxm4cga-etc.drv
/nix/store/09v1dv376mmr4g7j6i67wzw08dw10fwc-nixos-system-ximian-23.05.4497.04f431fe64a5.drv
building '/nix/store/fd8cbnpf1qwy08bph7gj5qm0z7f7bdrw-go-jira.drv'...
building '/nix/store/yd1hhvrx5j3dkfapfckqmpgs7iq67d6g-jira-cli-go.drv'...
Builder called die: Cannot wrap '--argv0' because it is not an executable file
Backtrace:
7 assertExecutable /nix/store/pi4pikagdhj7vrb18z4g9h6v9qdvx95a-make-shell-wrapper-hook/nix-support/setup-hook
43 makeShellWrapper /nix/store/pi4pikagdhj7vrb18z4g9h6v9qdvx95a-make-shell-wrapper-hook/nix-support/setup-hook
36 makeWrapper /nix/store/pi4pikagdhj7vrb18z4g9h6v9qdvx95a-make-shell-wrapper-hook/nix-support/setup-hook
2 source /build/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90
1563 genericBuild /nix/store/9v8sc2q2dflxjcz1hsw84b10bvg0wand-stdenv-linux/setup
6 main /nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh
error: builder for '/nix/store/fd8cbnpf1qwy08bph7gj5qm0z7f7bdrw-go-jira.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/1r6r1wc8rb665sqar04w2kshsbfs5g7z-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/09v1dv376mmr4g7j6i67wzw08dw10fwc-nixos-system-ximian-23.05.4497.04f431fe64a5.drv' failed to build
Ah, whoops, looks like the non-flag argument position is mandatory:
makeWrapper ${pkgs.jira-cli-go}/bin/jira $out/bin/jira-cli-go --argv0 jira
Interesting. These derivations don’t have the original pacakges as inputs. Are you just placing them alongside the binaries and hoping that they already exist?
Would an alternative be to override postInstall
be neater? Doesn’t sound like it, as you’d have to know that package’s install step well.
I have go-task (taskfile.dev) and taskwarrior that use the same binary name
Nix does some black voodoo that means just referring to the package with ${pkgs.jira-cli-go}
is sufficient to create a dependency: Automatic Runtime Dependencies - Nix Pills
postInstall
is rarely used upstream and you could just append if you were scared that that could change/isn’t true for a specific package. However, you would need to rebuild the whole package if you changed part of its builder, whereas creating a wrapping derivation means you build a package whose build time is negligible instead.