# Permission denied inside nix build?

**URL:** https://discourse.nixos.org/t/permission-denied-inside-nix-build/80945
**Category:** Help
**Created:** [November 4, 2026, 6:22pm UTC](https://discourse.nixos.org/t/permission-denied-inside-nix-build/80945 "2026-11-04T18:22:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![pasqui23](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@pasqui23](https://discourse.nixos.org/u/pasqui23)
#### Post date: [November 4, 2026, 6:22pm UTC](https://discourse.nixos.org/t/permission-denied-inside-nix-build/80945/1 "2026-11-04T18:22:48Z")

</div>

When I build the following

```nix

 o = pkgs.runCommand "gdAddonsDir"{
    paths = with pkgs.inputs; [ #all flake inputs
      gdBlenderShort
      gdSpritePreview
      gdGizmo3D
      gdAllTrack
      (pkgs.fetchzip {
        url = "https://github.com/Terapixel-Games/spacemouse-godot/releases/download/v0.1.0/spacemouse-godot-linux-template_release-x86_64.zip";
        hash = "sha256-7YPPq6NeJl4Lg3WiNArXV5n5x82K/QiAmKWol3vk7b4=";
      })
      (pkgs.fetchzip {
        url = "https://github.com/vaner-org/viewpad/releases/download/1.0/viewpad-1.0.zip";
        hash = "sha256-T8dDAIw9StYWVjZ2JJZWgLMLQXUF0r4BmfuCgK9zvSw=";
      })
      gdAPRefact
      gdBlender
      gdFaveDock
      gdEyesee
      gdResWrangle
      gdAutoLay
      gdInsTabs
      # gdi18n
      gdMass
      gdModBake
      gdAuto
      gdPasteImg
      gdProcMode
      gdScatter
      gdSheet
      gdAnimSheet
      gdExtHelper
      gdSceneMesh
      gdMesh2Col
      gdVarEdit
      gdTileCp
      gdExtraSnaps
      gdGambare
      gdCC
      gdDist
      gdTodo
      gdTimeTraker
      gdMeshLib
      gdCsgTk
      gdAssets
      gdAssetMan
      gdNodeCp
      gdShaderView
    ];
  }''
    mkdir $out
    for p in $paths; do
      cat $p/*.gd
      cp -r $p/* $out
    done
  '';

```

I get `cp: cannot create directory ‘/nix/store/py0yn95izb9wvlwxcshfpsfx3bfva  
0n0-gdAddonsDir/addons/AnimatedSpritePreviewer’: Permission denied`

If I remove the flake inputs from the above derivation it work. How do I make it work with the flake inputs?

---

<div class="post-metadata">

### Author: ![MaxHearnden](https://discourse.nixos.org/user_avatar/discourse.nixos.org/maxhearnden/32/16760_2.png) [@MaxHearnden](https://discourse.nixos.org/u/MaxHearnden)
#### Post date: [November 4, 2026, 6:37pm UTC](https://discourse.nixos.org/t/permission-denied-inside-nix-build/80945/2 "2026-11-04T18:37:00Z")

</div>

Try adding `--no-preserve=mode` to cp.

Folders in the nix store have the mode 0555 which prevents writing (creating files/folders within it), cp preserves this by default which causes the permission error.

---

<div class="post-metadata">

### Author: ![pasqui23](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/ee7513/32.png) [@pasqui23](https://discourse.nixos.org/u/pasqui23)
#### Post date: [November 4, 2026, 6:39pm UTC](https://discourse.nixos.org/t/permission-denied-inside-nix-build/80945/3 "2026-11-04T18:39:31Z")

</div>

> [@MaxHearnden](#):
>
> `--no-preserve=mode`

that is not the fix. Again something wed flakes is happening because if I remove the flake inputs from the build it work correctly

---

<div class="post-metadata">

### Author: ![MaxHearnden](https://discourse.nixos.org/user_avatar/discourse.nixos.org/maxhearnden/32/16760_2.png) [@MaxHearnden](https://discourse.nixos.org/u/MaxHearnden)
#### Post date: [November 4, 2026, 7:14pm UTC](https://discourse.nixos.org/t/permission-denied-inside-nix-build/80945/4 "2026-11-04T19:14:28Z")

</div>

Could you add `|| ls -l $out/addons` to the end of the cp command?
