# Error: "unpacker produced multiple directories"

**URL:** https://discourse.nixos.org/t/error-unpacker-produced-multiple-directories/37378
**Category:** Help
**Created:** [December 27, 2023, 4:47pm UTC](https://discourse.nixos.org/t/error-unpacker-produced-multiple-directories/37378 "2023-12-27T16:47:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Marcc](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@Marcc](https://discourse.nixos.org/u/Marcc)
#### Post date: [December 27, 2023, 4:47pm UTC](https://discourse.nixos.org/t/error-unpacker-produced-multiple-directories/37378/1 "2023-12-27T16:47:54Z")

</div>

Hey everyone, I am trying to debug an issue with Nix, where I am trying to install a new package. I am using [opam-nix](https://github.com/tweag/opam-nix) to manage my dependencies automatically in Nix. However, I added a new package called timedesc and ran into the issue

```auto
error: builder for '/nix/store/2xrb8jjl70y9bph3340fhc6yp8yi5yfc-timedesc-tzdb-2.0.0.drv' failed with exit code 1;
       last 3 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/7vk36zdb2sfy4x6sv7grfm87jgq414hk-timedesc-2.0.0.tar.gz
       > unpacker produced multiple directories
       For full logs, run 'nix log /nix/store/2xrb8jjl70y9bph3340fhc6yp8yi5yfc-timedesc-tzdb-2.0.0.drv'.

```

My nix config looks like this:

```auto
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    opam-nix.url = "github:tweag/opam-nix";
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.follows = "opam-nix/nixpkgs";
  };
  outputs = { self, flake-utils, opam-nix, nixpkgs }@inputs:
    let package = "fixgen";
    in flake-utils.lib.eachDefaultSystem (system:
      let
        sourceRoot = ".";
        pkgs = nixpkgs.legacyPackages.${system};
        on = opam-nix.lib.${system};
        devPackagesQuery = {
          ocaml-lsp-server = "*";
          ocamlformat = "*";
          ocamlfind = "1.9.5";
          utop = "*";
        };
        query = devPackagesQuery // {
          ocaml-base-compiler = "*";
        };
        scope = on.buildOpamProject' { } ./. query;
        overlay = final: prev: {
          # You can add overrides here
          ${package} = prev.${package}.overrideAttrs (_: {
          });
        };
        scope' = scope.overrideScope' overlay;
        # The main package containing the executable
        main = scope'.${package};
        # Packages from devPackagesQuery
        devPackages = builtins.attrValues
          (pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
      in {
        legacyPackages = scope';

        packages.default = main;

        devShells.default = pkgs.mkShell {
          inputsFrom = [main];
          buildInputs = devPackages ++ [
          ];
        };
      });
}

```

Googling around, it seems it might have something to do with the sourceRoot=“.” parameter missing, but I am not sure where and how to add it when using something like opam-nix on top. Any pointers?

---

<div class="post-metadata">

### Author: ![brendanzab](https://discourse.nixos.org/user_avatar/discourse.nixos.org/brendanzab/32/5495_2.png) [@brendanzab](https://discourse.nixos.org/u/brendanzab)
#### Post date: [March 3, 2025, 1:22pm UTC](https://discourse.nixos.org/t/error-unpacker-produced-multiple-directories/37378/2 "2025-03-03T13:22:28Z")

</div>

For anyone else struggling with this, I managed to [fix a similar issue](https://github.com/brendanzab/language-garden/commit/6473dbeb65192c0a2840593065969a301c103e00) with `utop` by adding the following to the `overlay` field:

```nix
        overlay = final: prev: {
          utop = prev.utop.overrideAttrs (previousAttrs: {
            # Fix for "unpacker produced multiple directories"
            # See: https://stackoverflow.com/a/77161896
            sourceRoot = ".";
          });
        };

```

Thanks goes to [this stack overflow answer](https://stackoverflow.com/questions/77160863/nix-derivation-error-unpacker-produced-multiple-directories) for providing the `sourceRoot = "."` fix.
