Can't use `getoptions` on macOS

getoptions has a check phase that requires busybox. busybox is only usable on linux.

I can build the derivation if I disable the check phase. What’s the real solution here?

That sounds pretty reasonable to me for a downstream user.

Upstream you can add conditions to not run the test against the busybox shell on mac OS. Something like:

  checkInputs = [ shellcheck shellspec ksh mksh yash zsh ]
                ++ lib.lists.optional stdenv.isDarwin busybox-sandbox-shell;

  preCheck = ''
    sed -i '/shellspec -s posh/d' Makefile
  '' + lib.string.optionalString stdenv.isDarwin ''
    sed -i "/shellspec -s 'busyox ash'" Makefile
  '';

I like that upstream fix. I’ll submit a PR for that.

As far as downstream users, I hit my head on this when I tried to add getoptions to my packages list in devenv. I cloned nixpkgs and messed with the nix package to triage but I don’t yet know how I would even share the resulting derivation with my coworkers.

Nix excels at exactly this type of problem, little downstream fixes to upstream packages. Far better than other distros anyway. You can pretty easily write an override for this:

(pkgs.getoptions.overrideAttrs (old: {
  doCheck = false;
}))

Stick that in your devenv’s package list and it’ll work. The outer brackets are important if it’s in a list, otherwise the function and its argument will be treated as separate elements.

2 Likes

Wow! Thanks for that tip.

PR here: getoptions: Don't require busybox on macOS by ryansch · Pull Request #230869 · NixOS/nixpkgs · GitHub

Example copypasta for others who find this thread:

{ pkgs, ... }:

let
  getoptions = pkgs.getoptions.overrideAttrs (oldAttrs: {
    doCheck = false;
  });
in {
  # https://devenv.sh/packages/
  packages = with pkgs; [
    git
    nodejs-18_x
    yarn
    postgresql_14
    zlib
    libiconv
    tmux
    tmuxPlugins.sensible
    tmuxPlugins.yank
  ] ++ [
    getoptions
  ];
}
1 Like

Pull request was just merged!

1 Like