Skip to content

write-npins fails on macOS due to GNU mktemp incompatibility #103

Description

@anmayithap

Issue: write-npins fails on macOS due to GNU mktemp incompatibility

Description

The write-npins script is currently broken on macOS (and other BSD-based systems) because it relies on the GNU-specific --suffix flag for mktemp. The native BSD mktemp utility on macOS does not recognize this option, causing the script to crash.

Error Output

mktemp: unrecognized option `--suffix=.nix'
usage: mktemp [-d] [-p tmpdir] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-p tmpdir] [-q] [-u] -t prefix

Root Cause

The script uses writeShellApplication but does not guarantee that the GNU version of mktemp (from coreutils) is used over the host's system path. On macOS, /usr/bin/mktemp (BSD) often takes precedence or is called instead of the Nix-provided one if not explicitly handled.

Expected Behavior

The script should be hermetic and use the GNU mktemp from the Nix store to ensure consistent behavior across all platforms (Linux/Darwin).

Suggested Fix

In the writeShellApplication definition for write-npins:

  1. Ensure coreutils is present in runtimeInputs.
  2. Hardcode the path to mktemp using ${coreutils}/bin/mktemp inside the script text to avoid picking up the host's BSD version.
  3. Alternatively, use a portable mktemp syntax that works on both versions (e.g., mktemp /tmp/npins.XXXXXXXX.nix).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions