Skip to content

Hardcoded check for GNU Coreutils on MacOS #868

Description

@cloud8421

Environment

I'm running on MacOS Ventura, using a flake.nix file to provision the environment for the project.

Here's the file, which is adapted from the shell.nix file provided at https://hexdocs.pm/nerves/installation.html#for-nixos-or-nix-package-manager.

{
  description = "Robo Clock";

  outputs =
    { self
    , nixpkgs
    , flake-utils
    ,
    }:
    flake-utils.lib.eachDefaultSystem
      (
        system:
        let
          pkgs = import nixpkgs {
            inherit system;
          };

          # Set the Erlang version
          erlangVersion = "erlangR25";
          # Set the Elixir version
          elixirVersion = "elixir_1_14";

          erlang = pkgs.beam.interpreters.${erlangVersion};
          elixir = pkgs.beam.packages.${erlangVersion}.${elixirVersion};
          elixir-ls = pkgs.beam.packages.${erlangVersion}.elixir-ls;
          fwup = pkgs.fwup;
          squashfs = pkgs.squashfsTools;
          coreutils = pkgs.coreutils;
          pkg-config = pkgs.pkg-config;
          autoconf = pkgs.autoconf;
          automake = pkgs.automake;
          curl = pkgs.curl;

        in
        rec {

          devShells.default = pkgs.mkShell {
            buildInputs = [
              erlang
              elixir
              elixir-ls
              fwup
              squashfs
              coreutils
              pkg-config
              autoconf
              automake
              curl
            ];
          };
        }
      );
}

Current behavior

Running nix develop produces a valid environment, and I'm able to work on the project. Trying to build a firmware results in this error:

** (Mix) gstat (coreutils) is required by the Nerves tooling.

I traced this down to

ensure_available!("gstat", package: "gstat (coreutils)")
, where the preflight check on MacOS looks for gstat.

The problem is that on Nix the coreutils package doesn't prefix utils with g as there's no risk of clashing with system built-ins. In my environment, stat is the correct command that would need to be used.

I can work around this by creating a link so that the condition is satisfied, but I am wondering if the preflight check needs to be more sophisticated. If it's ok, we can discuss here and I can provide a PR as a follow-up?

Thanks for the great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions