Trying to write a derivation for rust-analyser built it won't run

I am using nix-darwin, and I am trying to write a derivation for rust-analyzer. This is my code in the derivation file(There are many things missing and I guess I should not fetch the executable directly?):

{ config, lib, pkgs, ... }:

stdenv.mkDerivation {
  name = "rust-analyzer";
  src = builtins.fetchurl{
    url = "";
    sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
  installPhase = ''
    mkdir -p $out/bin
    mv rust-analyzer-aarch64-apple-darwin rust-analyzer
    cp rust-analyzer $out/bin

And this is my config file for nix-darwin, which I have imported the derivation file

{ config, pkgs, ... }:


  nixpkgs.overlays = [
    (import (builtins.fetchTarball {
      url =

  nixpkgs.config = {
    allowUnfree = true;

  environment.systemPackages = [
    import ./rust-analyzer.nix {}

But I got this error, and I have no idea how to debug it:

error: 'functionArgs' requires a function, at /nix/store/46lqa5vk43ldwql2vkdcsxs70139j22z-nixpkgs-21.11pre297787.1c203a23254/nixpkgs/lib/trivial.nix:337:42
(use '--show-trace' to show detailed location information)

The current rust-analyzer seems to support darwin, at least from a quick repl check:

nix-repl> rust-analyzer.meta.platforms
[ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mipsel-linux" "powerpc64-linux" "powerpc64le-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "x86_64-darwin" "i686-darwin" "aarch64-darwin" "armv7a-darwin" ]

Is there a reason you can’t use this version in nixpkgs?

1 Like

Thank you so much and I am ok with it. I have search the package with nix search rust-analyzer and search it in the GitHub of Nixpkgs, but I couldn’t find it. I thought it doesn’t exist there.

Although I am able to get the existing package, I would like to know why I got the error there, so I can try and make some derivation? I guess I did provided a function there?

This is the problem. Nix lists use a blank space as a delimiter, so while you inteded one package, you are actually passing in three list items, to fix simply wrap the expression in parens or use a let binding.