nix icon indicating copy to clipboard operation
nix copied to clipboard

Nix index unpack of nixpkgs is slow under macOs

Open vkravets opened this issue 1 year ago • 23 comments

Describe the bug

I have two notebooks. Late 2014 acer with nixOs and macbook Pro late 2021 and unpacking nixpkgs while nix os switch is very slow under macos (with new hardware) comparing to old acer later 2014

nix (Nix) 2.18.8

Steps To Reproduce

Just try to update system using the latest nixpkgs (make sure the latest nixpkgs is download while update process)

Expected behavior

The unpack indexes/nixpkgs is fast

nix-env --version output nix-env (Nix) 2.18.8

Additional context NA

Priorities

Add :+1: to issues you find important.

vkravets avatar Oct 11 '24 10:10 vkravets

Let me know which details information is need, since I don't know what I can put to description.

vkravets avatar Oct 11 '24 10:10 vkravets

This is definitely a big issue - it takes minutes to unpack nixpkgs on MacOS. It feels like it's doing something very different (and worse) than how NAR packages are downloaded; in the NAR case unpacks of the same directory are super fast. It's the github untar that's slow.

I'm wondering if the cause is that the tar is initially unpacked onto a different filesystem or something.

j-baker avatar Jan 02 '25 07:01 j-baker

while execute nix flake update --flake /Users/vkravets/.config/nix-darwin --debug got the following debug output:

evaluating file '<nix/derivation-internal.nix>'
using cache entry 'gitRevCount:{"rev":"45a621a549dc4bb74f465f7fd44459de2fb81bda"}' -> '{"revCount":19}'
using cache entry 'gitLastModified:{"rev":"45a621a549dc4bb74f465f7fd44459de2fb81bda"}' -> '{"lastModified":1735899541}'
using cache entry 'fetchToStore:{"fingerprint":"45a621a549dc4bb74f465f7fd44459de2fb81bda","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> '{"storePath":"n70mz96lf60x5bxyrdlgansdc5dm82kc-source"}'
performing daemon worker op: 11
acquiring write lock on '/nix/var/nix/temproots/73197'
performing daemon worker op: 1
using cache entry 'fetchToStore:{"fingerprint":"45a621a549dc4bb74f465f7fd44459de2fb81bda","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> 'null', '/nix/store/n70mz96lf60x5bxyrdlgansdc5dm82kc-source'
store path cache hit for '/Users/vkravets/.config/nix-darwin/Users/vkravets/.config/nix-darwin/'
performing daemon worker op: 26
got tree '/nix/store/n70mz96lf60x5bxyrdlgansdc5dm82kc-source' from 'git+file:///Users/vkravets/.config/nix-darwin?ref=refs/heads/main&rev=45a621a549dc4bb74f465f7fd44459de2fb81bda'
evaluating file '/nix/store/n70mz96lf60x5bxyrdlgansdc5dm82kc-source/flake.nix'
performing daemon worker op: 19
old lock file: {
  "nodes": {
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1735344290,
        "narHash": "sha256-oJDtWPH1oJT34RJK1FSWjwX4qcGOBRkcNQPD0EbSfNM=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "613691f285dad87694c2ba1c9e6298d04736292d",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "ref": "release-24.11",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "nh-darwin": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs-unstable"
        ]
      },
      "locked": {
        "lastModified": 1735816258,
        "narHash": "sha256-7zBiXoC43piFocq0wHvNm5KgzolCi3axD4QhWfsw4DU=",
        "owner": "viperML",
        "repo": "nh",
        "rev": "b7a857066e726dafe9c5f00a8af6ab3f25036ee1",
        "type": "github"
      },
      "original": {
        "owner": "viperML",
        "repo": "nh",
        "type": "github"
      }
    },
    "nix-darwin": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1735685839,
        "narHash": "sha256-62xAPSs5VRZoPH7eRanUn5S5vZEd+8vM4bD5I+zxokc=",
        "owner": "LnL7",
        "repo": "nix-darwin",
        "rev": "6a1fdb2a1204c0de038847b601cff5012e162b5e",
        "type": "github"
      },
      "original": {
        "owner": "LnL7",
        "repo": "nix-darwin",
        "type": "github"
      }
    },
    "nix-index-database": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1735443188,
        "narHash": "sha256-AydPpRBh8+NOkrLylG7vTsHrGO2b5L7XkMEL5HlzcA8=",
        "owner": "nix-community",
        "repo": "nix-index-database",
        "rev": "55ab1e1df5daf2476e6b826b69a82862dcbd7544",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "nix-index-database",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1735595149,
        "narHash": "sha256-6jNmY7BaooArDpOhT8QbGxR0x8as43AJUoHfm1rJY1M=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "464fe85c27bd5761781a2773526ef9c1b0184dda",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-24.11-darwin",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs-unstable": {
      "locked": {
        "lastModified": 1735821806,
        "narHash": "sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "d6973081434f88088e5321f83ebafe9a1167c367",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "home-manager": "home-manager",
        "nh-darwin": "nh-darwin",
        "nix-darwin": "nix-darwin",
        "nix-index-database": "nix-index-database",
        "nixpkgs": "nixpkgs",
        "nixpkgs-unstable": "nixpkgs-unstable"
      }
    }
  },
  "root": "root",
  "version": 7
}
computing lock file node ''
computing input 'home-manager'
creating new input 'home-manager'
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/nix-community/home-manager/commits/release-24.11"}' -> '{"etag":"W/\"6169bf5cea9cf1febfee3012d0dad7da0abef5941a8b934a8c7ab5bf50843b8e\"","storePath":"lmhcqjii266hp3c0d3zvasfjr9f1s3hh-source","url":"https://api.github.com/repos/nix-community/home-manager/commits/release-24.11"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/nix-community/home-manager/commits/release-24.11"}' -> '{"etag":"W/\"6169bf5cea9cf1febfee3012d0dad7da0abef5941a8b934a8c7ab5bf50843b8e\"","url":"https://api.github.com/repos/nix-community/home-manager/commits/release-24.11"}', '/nix/store/lmhcqjii266hp3c0d3zvasfjr9f1s3hh-source'
downloading 'https://api.github.com/repos/nix-community/home-manager/commits/release-24.11'...
starting download of https://api.github.com/repos/nix-community/home-manager/commits/release-24.11
finished download of 'https://api.github.com/repos/nix-community/home-manager/commits/release-24.11'; curl status = 0, HTTP status = 304, body = 0 bytes, duration = 0.50 s
HEAD revision for 'github:nix-community/home-manager/release-24.11' is 613691f285dad87694c2ba1c9e6298d04736292d
using cache entry 'gitRevToTreeHash:{"rev":"613691f285dad87694c2ba1c9e6298d04736292d"}' -> '{"treeHash":"3fb02e5f6ead513556eceede42c60a2b971461e3"}'
using cache entry 'gitRevToLastModified:{"rev":"613691f285dad87694c2ba1c9e6298d04736292d"}' -> '{"lastModified":1735344290}'
using cache entry 'fetchToStore:{"fingerprint":"613691f285dad87694c2ba1c9e6298d04736292d","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> '{"storePath":"pq697d1bkix3hvrjkrxfhsa3zwykxkwb-source"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'fetchToStore:{"fingerprint":"613691f285dad87694c2ba1c9e6298d04736292d","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> 'null', '/nix/store/pq697d1bkix3hvrjkrxfhsa3zwykxkwb-source'
store path cache hit for '«github:nix-community/home-manager/613691f285dad87694c2ba1c9e6298d04736292d»/'
performing daemon worker op: 26
got tree '/nix/store/pq697d1bkix3hvrjkrxfhsa3zwykxkwb-source' from 'github:nix-community/home-manager/613691f285dad87694c2ba1c9e6298d04736292d?narHash=sha256-oJDtWPH1oJT34RJK1FSWjwX4qcGOBRkcNQPD0EbSfNM%3D'
evaluating file '/nix/store/pq697d1bkix3hvrjkrxfhsa3zwykxkwb-source/flake.nix'
computing lock file node 'home-manager'
computing input 'home-manager/nixpkgs'
input 'home-manager/nixpkgs' follows 'nixpkgs'
computing input 'nh-darwin'
creating new input 'nh-darwin'
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/viperML/nh/commits/HEAD"}' -> '{"etag":"W/\"c8cb3a2d4352ca029eb39dcca22dc70347954a3b05e42f9e3db63d3978f1ac0f\"","storePath":"f0vhw15bmbm0v4lzy64fbffjw2gkkvqk-source","url":"https://api.github.com/repos/viperML/nh/commits/HEAD"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/viperML/nh/commits/HEAD"}' -> '{"etag":"W/\"c8cb3a2d4352ca029eb39dcca22dc70347954a3b05e42f9e3db63d3978f1ac0f\"","url":"https://api.github.com/repos/viperML/nh/commits/HEAD"}', '/nix/store/f0vhw15bmbm0v4lzy64fbffjw2gkkvqk-source'
downloading 'https://api.github.com/repos/viperML/nh/commits/HEAD'...
starting download of https://api.github.com/repos/viperML/nh/commits/HEAD
finished download of 'https://api.github.com/repos/viperML/nh/commits/HEAD'; curl status = 0, HTTP status = 304, body = 0 bytes, duration = 0.21 s
HEAD revision for 'github:viperML/nh/HEAD' is b7a857066e726dafe9c5f00a8af6ab3f25036ee1
using cache entry 'gitRevToTreeHash:{"rev":"b7a857066e726dafe9c5f00a8af6ab3f25036ee1"}' -> '{"treeHash":"9ae85c10bd91ca2ff6823d5141672580e0751577"}'
using cache entry 'gitRevToLastModified:{"rev":"b7a857066e726dafe9c5f00a8af6ab3f25036ee1"}' -> '{"lastModified":1735816258}'
using cache entry 'fetchToStore:{"fingerprint":"b7a857066e726dafe9c5f00a8af6ab3f25036ee1","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> '{"storePath":"7a8n1n24xshb27qlrlmmqsyp2ksaq4qr-source"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'fetchToStore:{"fingerprint":"b7a857066e726dafe9c5f00a8af6ab3f25036ee1","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> 'null', '/nix/store/7a8n1n24xshb27qlrlmmqsyp2ksaq4qr-source'
store path cache hit for '«github:viperML/nh/b7a857066e726dafe9c5f00a8af6ab3f25036ee1»/'
performing daemon worker op: 26
got tree '/nix/store/7a8n1n24xshb27qlrlmmqsyp2ksaq4qr-source' from 'github:viperML/nh/b7a857066e726dafe9c5f00a8af6ab3f25036ee1?narHash=sha256-7zBiXoC43piFocq0wHvNm5KgzolCi3axD4QhWfsw4DU%3D'
evaluating file '/nix/store/7a8n1n24xshb27qlrlmmqsyp2ksaq4qr-source/flake.nix'
computing lock file node 'nh-darwin'
computing input 'nh-darwin/nixpkgs'
input 'nh-darwin/nixpkgs' follows 'nixpkgs-unstable'
computing input 'nix-darwin'
creating new input 'nix-darwin'
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/LnL7/nix-darwin/commits/HEAD"}' -> '{"etag":"W/\"88b533736a417c63c8092bd46b4ece4d50896d9f561016e53a7ff7bf6e43a14c\"","storePath":"kwbxxrg77fg4y2ginxk4gn9qhqvzfk2v-source","url":"https://api.github.com/repos/LnL7/nix-darwin/commits/HEAD"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/LnL7/nix-darwin/commits/HEAD"}' -> '{"etag":"W/\"88b533736a417c63c8092bd46b4ece4d50896d9f561016e53a7ff7bf6e43a14c\"","url":"https://api.github.com/repos/LnL7/nix-darwin/commits/HEAD"}', '/nix/store/kwbxxrg77fg4y2ginxk4gn9qhqvzfk2v-source'
downloading 'https://api.github.com/repos/LnL7/nix-darwin/commits/HEAD'...
starting download of https://api.github.com/repos/LnL7/nix-darwin/commits/HEAD
finished download of 'https://api.github.com/repos/LnL7/nix-darwin/commits/HEAD'; curl status = 0, HTTP status = 304, body = 0 bytes, duration = 0.18 s
HEAD revision for 'github:LnL7/nix-darwin/HEAD' is 6a1fdb2a1204c0de038847b601cff5012e162b5e
using cache entry 'gitRevToTreeHash:{"rev":"6a1fdb2a1204c0de038847b601cff5012e162b5e"}' -> '{"treeHash":"090cf15c425241231355eff7ea17be42f5d2a201"}'
using cache entry 'gitRevToLastModified:{"rev":"6a1fdb2a1204c0de038847b601cff5012e162b5e"}' -> '{"lastModified":1735685839}'
using cache entry 'fetchToStore:{"fingerprint":"6a1fdb2a1204c0de038847b601cff5012e162b5e","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> '{"storePath":"7jks15hc1z1kfqzg9a82d0rvscd8s52v-source"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'fetchToStore:{"fingerprint":"6a1fdb2a1204c0de038847b601cff5012e162b5e","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> 'null', '/nix/store/7jks15hc1z1kfqzg9a82d0rvscd8s52v-source'
store path cache hit for '«github:LnL7/nix-darwin/6a1fdb2a1204c0de038847b601cff5012e162b5e»/'
performing daemon worker op: 26
got tree '/nix/store/7jks15hc1z1kfqzg9a82d0rvscd8s52v-source' from 'github:LnL7/nix-darwin/6a1fdb2a1204c0de038847b601cff5012e162b5e?narHash=sha256-62xAPSs5VRZoPH7eRanUn5S5vZEd%2B8vM4bD5I%2Bzxokc%3D'
evaluating file '/nix/store/7jks15hc1z1kfqzg9a82d0rvscd8s52v-source/flake.nix'
computing lock file node 'nix-darwin'
computing input 'nix-darwin/nixpkgs'
input 'nix-darwin/nixpkgs' follows 'nixpkgs'
computing input 'nix-index-database'
creating new input 'nix-index-database'
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/nix-community/nix-index-database/commits/HEAD"}' -> '{"etag":"W/\"929dbd589a259b87033c2d2ea58c45bdb3e68d04a0c2c6b5f16aa65d9d2b72a7\"","storePath":"6pnh5qsw14vrzkmmv1cbvrjknvqyhg9k-source","url":"https://api.github.com/repos/nix-community/nix-index-database/commits/HEAD"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/nix-community/nix-index-database/commits/HEAD"}' -> '{"etag":"W/\"929dbd589a259b87033c2d2ea58c45bdb3e68d04a0c2c6b5f16aa65d9d2b72a7\"","url":"https://api.github.com/repos/nix-community/nix-index-database/commits/HEAD"}', '/nix/store/6pnh5qsw14vrzkmmv1cbvrjknvqyhg9k-source'
downloading 'https://api.github.com/repos/nix-community/nix-index-database/commits/HEAD'...
starting download of https://api.github.com/repos/nix-community/nix-index-database/commits/HEAD
finished download of 'https://api.github.com/repos/nix-community/nix-index-database/commits/HEAD'; curl status = 0, HTTP status = 304, body = 0 bytes, duration = 0.36 s
HEAD revision for 'github:nix-community/nix-index-database/HEAD' is 55ab1e1df5daf2476e6b826b69a82862dcbd7544
using cache entry 'gitRevToTreeHash:{"rev":"55ab1e1df5daf2476e6b826b69a82862dcbd7544"}' -> '{"treeHash":"7c729449a0e949836cb801d4323c457d3ce9bae5"}'
using cache entry 'gitRevToLastModified:{"rev":"55ab1e1df5daf2476e6b826b69a82862dcbd7544"}' -> '{"lastModified":1735443188}'
using cache entry 'fetchToStore:{"fingerprint":"55ab1e1df5daf2476e6b826b69a82862dcbd7544","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> '{"storePath":"6bly0ggwa6wch3nq777f2nnprqw1fn7c-source"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'fetchToStore:{"fingerprint":"55ab1e1df5daf2476e6b826b69a82862dcbd7544","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> 'null', '/nix/store/6bly0ggwa6wch3nq777f2nnprqw1fn7c-source'
store path cache hit for '«github:nix-community/nix-index-database/55ab1e1df5daf2476e6b826b69a82862dcbd7544»/'
performing daemon worker op: 26
got tree '/nix/store/6bly0ggwa6wch3nq777f2nnprqw1fn7c-source' from 'github:nix-community/nix-index-database/55ab1e1df5daf2476e6b826b69a82862dcbd7544?narHash=sha256-AydPpRBh8%2BNOkrLylG7vTsHrGO2b5L7XkMEL5HlzcA8%3D'
evaluating file '/nix/store/6bly0ggwa6wch3nq777f2nnprqw1fn7c-source/flake.nix'
computing lock file node 'nix-index-database'
computing input 'nix-index-database/nixpkgs'
input 'nix-index-database/nixpkgs' follows 'nixpkgs'
computing input 'nixpkgs'
creating new input 'nixpkgs'
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-24.11-darwin"}' -> '{"etag":"W/\"514e04e530e0c00af24bdc641692e91e5256e393e31c6851ec3a53e46fa78ce8\"","storePath":"51p0agbfgd96820hfnina2j8yd705j6a-source","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-24.11-darwin"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-24.11-darwin"}' -> '{"etag":"W/\"514e04e530e0c00af24bdc641692e91e5256e393e31c6851ec3a53e46fa78ce8\"","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-24.11-darwin"}', '/nix/store/51p0agbfgd96820hfnina2j8yd705j6a-source'
downloading 'https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-24.11-darwin'...
starting download of https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-24.11-darwin
finished download of 'https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-24.11-darwin'; curl status = 0, HTTP status = 304, body = 0 bytes, duration = 0.20 s
HEAD revision for 'github:NixOS/nixpkgs/nixpkgs-24.11-darwin' is 2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc
did not find cache entry for 'gitRevToTreeHash:{"rev":"2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc"}'
unpacking 'github:NixOS/nixpkgs/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc' into the Git cache...
downloading 'https://github.com/NixOS/nixpkgs/archive/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc.tar.gz'...
starting download of https://github.com/NixOS/nixpkgs/archive/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc.tar.gz
finished download of 'https://github.com/NixOS/nixpkgs/archive/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc.tar.gz'; curl status = 0, HTTP status = 200, body = 47582037 bytes, duration = 6.90 s
error:
       … while updating the lock file of flake 'git+file:///Users/vkravets/.config/nix-darwin?ref=refs/heads/main&rev=45a621a549dc4bb74f465f7fd44459de2fb81bda'

       … while updating the flake input 'nixpkgs'

       … while fetching the input 'github:NixOS/nixpkgs/nixpkgs-24.11-darwin'

       error: cannot read file 'nixpkgs-2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc/pkgs/development/python-modules/rns/unvendor-esptool.patch' from tarball
did not find cache entry for 'fetchToStore:{"fingerprint":"2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc","method":"nar","name":"source","path":"/","store":"/nix/store"}'
copying '«github:NixOS/nixpkgs/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc»/' to the store...
performing daemon worker op: 7
locking path '/nix/store/afj7adcd9zckwx8as77853pvxr2izlcm-source'
lock acquired on '/nix/store/afj7adcd9zckwx8as77853pvxr2izlcm-source.lock'
lock released on '/nix/store/afj7adcd9zckwx8as77853pvxr2izlcm-source.lock'
performing daemon worker op: 26
got tree '/nix/store/afj7adcd9zckwx8as77853pvxr2izlcm-source' from 'github:NixOS/nixpkgs/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc?narHash=sha256-bRTOYvKO4NQlWSk/v/2ayiPxNv/AqnEkgHPvhnWfkS8%3D'
evaluating file '/nix/store/afj7adcd9zckwx8as77853pvxr2izlcm-source/flake.nix'
computing lock file node 'nixpkgs'
computing input 'nixpkgs-unstable'
creating new input 'nixpkgs-unstable'
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}' -> '{"etag":"W/\"60e8113e3cbe61924bfe63fe6cee32d506cad115300b3567060afe8055895058\"","storePath":"jhjzya7s6hr5cfj12xfb1y48fbmn22fr-source","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'file:{"name":"source","store":"/nix/store","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}' -> '{"etag":"W/\"60e8113e3cbe61924bfe63fe6cee32d506cad115300b3567060afe8055895058\"","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}', '/nix/store/jhjzya7s6hr5cfj12xfb1y48fbmn22fr-source'
downloading 'https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable'...
starting download of https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable
finished download of 'https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable'; curl status = 0, HTTP status = 304, body = 0 bytes, duration = 0.32 s
HEAD revision for 'github:NixOS/nixpkgs/nixpkgs-unstable' is d6973081434f88088e5321f83ebafe9a1167c367
using cache entry 'gitRevToTreeHash:{"rev":"d6973081434f88088e5321f83ebafe9a1167c367"}' -> '{"treeHash":"3029926772a84e98ffb53a4675a903c555c541de"}'
using cache entry 'gitRevToLastModified:{"rev":"d6973081434f88088e5321f83ebafe9a1167c367"}' -> '{"lastModified":1735821806}'
using cache entry 'fetchToStore:{"fingerprint":"d6973081434f88088e5321f83ebafe9a1167c367","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> '{"storePath":"813bk6hvhfjjjmzlk2cxgxgd25yqq5f8-source"}'
performing daemon worker op: 11
performing daemon worker op: 1
using cache entry 'fetchToStore:{"fingerprint":"d6973081434f88088e5321f83ebafe9a1167c367","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> 'null', '/nix/store/813bk6hvhfjjjmzlk2cxgxgd25yqq5f8-source'
store path cache hit for '«github:NixOS/nixpkgs/d6973081434f88088e5321f83ebafe9a1167c367»/'
performing daemon worker op: 26
got tree '/nix/store/813bk6hvhfjjjmzlk2cxgxgd25yqq5f8-source' from 'github:NixOS/nixpkgs/d6973081434f88088e5321f83ebafe9a1167c367?narHash=sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8%3D'
evaluating file '/nix/store/813bk6hvhfjjjmzlk2cxgxgd25yqq5f8-source/flake.nix'
computing lock file node 'nixpkgs-unstable'
new lock file: {
  "nodes": {
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1735344290,
        "narHash": "sha256-oJDtWPH1oJT34RJK1FSWjwX4qcGOBRkcNQPD0EbSfNM=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "613691f285dad87694c2ba1c9e6298d04736292d",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "ref": "release-24.11",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "nh-darwin": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs-unstable"
        ]
      },
      "locked": {
        "lastModified": 1735816258,
        "narHash": "sha256-7zBiXoC43piFocq0wHvNm5KgzolCi3axD4QhWfsw4DU=",
        "owner": "viperML",
        "repo": "nh",
        "rev": "b7a857066e726dafe9c5f00a8af6ab3f25036ee1",
        "type": "github"
      },
      "original": {
        "owner": "viperML",
        "repo": "nh",
        "type": "github"
      }
    },
    "nix-darwin": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1735685839,
        "narHash": "sha256-62xAPSs5VRZoPH7eRanUn5S5vZEd+8vM4bD5I+zxokc=",
        "owner": "LnL7",
        "repo": "nix-darwin",
        "rev": "6a1fdb2a1204c0de038847b601cff5012e162b5e",
        "type": "github"
      },
      "original": {
        "owner": "LnL7",
        "repo": "nix-darwin",
        "type": "github"
      }
    },
    "nix-index-database": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1735443188,
        "narHash": "sha256-AydPpRBh8+NOkrLylG7vTsHrGO2b5L7XkMEL5HlzcA8=",
        "owner": "nix-community",
        "repo": "nix-index-database",
        "rev": "55ab1e1df5daf2476e6b826b69a82862dcbd7544",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "nix-index-database",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1735725507,
        "narHash": "sha256-bRTOYvKO4NQlWSk/v/2ayiPxNv/AqnEkgHPvhnWfkS8=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-24.11-darwin",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs-unstable": {
      "locked": {
        "lastModified": 1735821806,
        "narHash": "sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "d6973081434f88088e5321f83ebafe9a1167c367",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "home-manager": "home-manager",
        "nh-darwin": "nh-darwin",
        "nix-darwin": "nix-darwin",
        "nix-index-database": "nix-index-database",
        "nixpkgs": "nixpkgs",
        "nixpkgs-unstable": "nixpkgs-unstable"
      }
    }
  },
  "root": "root",
  "version": 7
}
warning: updating lock file '/Users/vkravets/.config/nix-darwin/flake.lock':
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/464fe85c27bd5761781a2773526ef9c1b0184dda?narHash=sha256-6jNmY7BaooArDpOhT8QbGxR0x8as43AJUoHfm1rJY1M%3D' (2024-12-30)
  → 'github:NixOS/nixpkgs/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc?narHash=sha256-bRTOYvKO4NQlWSk/v/2ayiPxNv/AqnEkgHPvhnWfkS8%3D' (2025-01-01)
warning: Git tree '/Users/vkravets/.config/nix-darwin' is dirty
using cache entry 'gitLastModified:{"rev":"45a621a549dc4bb74f465f7fd44459de2fb81bda"}' -> '{"lastModified":1735899541}'
source path '/Users/vkravets/.config/nix-darwin/Users/vkravets/.config/nix-darwin/' is uncacheable
copying '/Users/vkravets/.config/nix-darwin/Users/vkravets/.config/nix-darwin/' to the store...
performing daemon worker op: 7
locking path '/nix/store/8zn595wglql59qsh4lnkzlpwf3isbrz1-source'
lock acquired on '/nix/store/8zn595wglql59qsh4lnkzlpwf3isbrz1-source.lock'
lock released on '/nix/store/8zn595wglql59qsh4lnkzlpwf3isbrz1-source.lock'
performing daemon worker op: 26
got tree '/nix/store/8zn595wglql59qsh4lnkzlpwf3isbrz1-source' from 'git+file:///Users/vkravets/.config/nix-darwin'
evaluating file '/nix/store/8zn595wglql59qsh4lnkzlpwf3isbrz1-source/flake.nix'
download thread shutting down

More time takes here

starting download of https://github.com/NixOS/nixpkgs/archive/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc.tar.gz
finished download of 'https://github.com/NixOS/nixpkgs/archive/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc.tar.gz'; curl status = 0, HTTP status = 200, body = 47582037 bytes, duration = 6.90 s
error:
       … while updating the lock file of flake 'git+file:///Users/vkravets/.config/nix-darwin?ref=refs/heads/main&rev=45a621a549dc4bb74f465f7fd44459de2fb81bda'

       … while updating the flake input 'nixpkgs'

       … while fetching the input 'github:NixOS/nixpkgs/nixpkgs-24.11-darwin'

       error: cannot read file 'nixpkgs-2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc/pkgs/development/python-modules/rns/unvendor-esptool.patch' from tarball
did not find cache entry for 'fetchToStore:{"fingerprint":"2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc","method":"nar","name":"source","path":"/","store":"/nix/store"}'
copying '«github:NixOS/nixpkgs/2dd3254fdc213bc0f3c8f05b6f0c610e0c1b3bdc»/' to the store...

vkravets avatar Jan 03 '25 20:01 vkravets

It seems to have something to do with the file system

vkravets avatar Jan 23 '25 10:01 vkravets

It seems it's related APFS... may be encryption is bottleneck here? Any thoughts?

vkravets avatar Jan 27 '25 10:01 vkravets

I have the same Problem on a 2021 M1 Pro Macbook with Sequoia 15.2.

Any nix operation involving unpacking nix packages takes ages, meaning 5 Minutes and up. For example, a simple devbox add ripgrep [email protected] (which runs nix underneath) took 15 Minutes to complete. Pure nix commands like nix flake update - same picture.

As it stands, this makes nix (and, by extension, devbox) unusable for me.

In addition to the above mentioned specs this machine runs Sophos (centrally managed, I cannot easily remove it) - maybe this has something to do with it, maybe not.

If there's more information needed or things to try, please let me know.

Edit: nix-store was excluded from spotlight indexing when I wrote the above.

nem75 avatar Jan 31 '25 07:01 nem75

I have this exact problem as well, and it makes my nix experience a lot worse than it could be. One suspicion I have is that it has something to do with Antivirus. Unfortunately, I cannot disable Antivirus (Microsoft Defender) because it's a company laptop. Can anybody confirm that this problem is not related to Antivirus?

My workaround is to use the same flake.lock in all projects, I only nix flake update when I know I have at least half an hour of time and then copy the new flake.lock to all my other projects. This way I can minimize the amount of times I have to unpack a new version of nixpkgs.

MacBook Pro M3 nix (Nix) 2.24.10 installed through Determinate Systems

Aaronmacaron avatar Feb 11 '25 17:02 Aaronmacaron

Had the same issue on a MacBook Pro M3 with MacOS 15.1, I also have a company laptop with Microsoft Defender. However after upgrading to MacOS 15.3 the issue went mostly away, I still think it's a bit slow when compared to my other machines running NixOS but at least it's usable now. If I had to guess I would say it's 3-5x slower on MacOS 15.3 than NixOS.

ruigouveiamaciel avatar Feb 16 '25 14:02 ruigouveiamaciel

Had the same issue on a MacBook Pro M3 with MacOS 15.1, I also have a company laptop with Microsoft Defender. However after upgrading to MacOS 15.3 the issue went mostly away, I still think it's a bit slow when compared to my other machines running NixOS but at least it's usable now. If I had to guess I would say it's 3-5x slower on MacOS 15.3 than NixOS.

Interesting. I'm already on MacOS 15.3, and I don't think it's significantly quicker since I updated. Can you roughly say how long unpacking takes on your machine? I measured it and it took around 14 minutes. Interestingly, the "Windows Defender Antivirus Daemon" (wdavdaemon_unprivileged) has around 65% CPU usage while unpacking and nix only takes around 30% of CPU. For me this looks a lot like this problem is related to Windows Defender.

I will try to somehow disable Windows Defender in the coming days and if I manage to do so I will report back if it makes a difference.

Aaronmacaron avatar Feb 16 '25 19:02 Aaronmacaron

Same here. Maybe @edolstra @grahamc have an idea.

heimalne avatar Feb 18 '25 11:02 heimalne

@Aaronmacaron what command do you want me to run to test it? I can tell that download new packages still takes a fair bit of time but once it's downloaded it's fast. My neovim config loads faster through neovim than through homebrew. Maybe our companies have different policies on Microsoft Defender.

I also wanted to try installing nix as a single-user install to see if it would be faster but I haven't gotten around to do that yet. My hopes is that building on userspace would be faster than running through nix daemon

ruigouveiamaciel avatar Feb 18 '25 12:02 ruigouveiamaciel

So, my company switched IT systems and I no longer have Microsoft Defender on the new system and this issue has gone away. Nix now runs extremly fast

ruigouveiamaciel avatar Mar 04 '25 20:03 ruigouveiamaciel

Have others ensured the nix store is excluded from spotlight indexing?

This seemed to help, but the experiments I tried so far could be confounded by caching. It certainly did not resolve the issue but mds_stores is a bit less noisy in the process list. Upgrading to 15.4 seemed to help as well.

cameronraysmith avatar Apr 25 '25 21:04 cameronraysmith

I finally managed to get rid of Microsoft Defender and now nix runs extremely fast for me.

Aaronmacaron avatar May 10 '25 13:05 Aaronmacaron

So, my company switched IT systems and I no longer have Microsoft Defender on the new system and this issue has gone away. Nix now runs extremly fast

Any ideas on what to set in the exclusion list, i hope i can talk the security team into allowing nix… Really annoying to wait an hour for something that should take less than 10 minutes… i tried to exclude /nix/ and the nix binary itself while i was still able to set exclusions myself but that didnt really help unfortuenetely

ojsef39 avatar Jun 12 '25 09:06 ojsef39

@ojsef39 I simply asked the IT to add /nix as an exception and the slowdowns vanished (recently they readded Microsoft Defender)

ruigouveiamaciel avatar Jun 16 '25 08:06 ruigouveiamaciel

@ojsef39 Did you fix this somehow? I currently have the same issue and we use Sophos Endpoint on MacOS. We also whitelisted /nix and the nix binary under /run/current-system/sw/bin/nix.

What takes ages for example is after nix develop:

[1/0/1 copied (177.2/177.2 MiB), 29.2 MiB DL] fetching source from https://cache.nixos.org

and

[1 copied (177.2 MiB), 29.2 MiB DL] copying '«github:nixos/nixpkgs/08f22084e6085d19bcfb4be30d1ca76ecb96fe54?narHash=sha256-XE/lFNhz5lsriMm/yjXkvSZz5DfvKJLUjsS6pP8EC50%3D»/' to the store

Keyruu avatar Aug 04 '25 08:08 Keyruu

@ojsef39 Did you fix this somehow? I currently have the same issue and we use Sophos Endpoint on MacOS. We also whitelisted /nix and the nix binary under /run/current-system/sw/bin/nix.

We're still working on it but we tried "/nix" (path) and "nix" (process) in Defender and that worked perfectly.

Could you try nix instead of /run/current-system/sw/bin/nix? Maybe that works better :)

Ig it wants the process name not where the binary is located.

ojsef39 avatar Aug 04 '25 10:08 ojsef39

Just to follow-up with this, I have the following marked as exclusions with Microsoft Defender for Mac

mdatp exclusion list
=====================================
Excluded folder
Path: "/etc/nix"
---
Excluded folder
Path: "/nix"
---
Excluded folder
Path: "/nix/store"
---
Excluded folder
Path: "/nix/var"
---
Excluded folder
Path: "/private/tmp"
---
Excluded folder
Path: "/private/var/folders"
---
Excluded folder
Path: "/tmp"
---
Excluded process
Process name: /nix/var/nix/profiles/default/bin/nix
---
Excluded process
Process name: /nix/var/nix/profiles/default/bin/nix-build
---
Excluded process
Process name: /nix/var/nix/profiles/default/bin/nix-store
---
Excluded process
Process name: /usr/local/bin/determinate-nixd
---
Excluded process
Process name: devenv
---
Excluded process
Process name: nix
---
Excluded process
Process name: nix-build
---
Excluded process
Process name: nix-daemon
---
Excluded process
Process name: nix-shell
---
Excluded process
Process name: nix-store

But still run into high CPU usage for wdavdaemon_enterprise when doing any nix operation. Our Defender is also managed via our IT team, but I would have thought adding these exclusions would supercede that..

ardens-jw avatar Dec 02 '25 10:12 ardens-jw

Would be great if anybody could test https://github.com/NixOS/nix/pull/14689 (already on master) and https://github.com/NixOS/nix/pull/14696 (not yet merged) with e.g.:

nix shell github:NixOS/nix/refs/pull/14696/head

That drastically reduces the amount (probably around 200x less for nixpkgs) of syscall our libgit2-backed tarball cache does and that might help.

xokdvium avatar Dec 02 '25 22:12 xokdvium

I took a stab at this using the command from the commit messages. I couldn't get dtruss -c to work, but with hyperfine:

hyperfine './result/bin/nix flake metadata "https://releases.nixos.org/nixos/25.05/nixos-25.05.813095.1c8ba8d3f763/nixexprs.tar.xz" --store "dummy://?read-only=false"' --warmup 1

#14689

Benchmark 1: ./result/bin/nix flake metadata "https://releases.nixos.org/nixos/25.05/nixos-25.05.813095.1c8ba8d3f763/nixexprs.tar.xz" --store "dummy://?read-only=false"                                                                                                                                                                                                                                                                  
  Time (mean ± σ):      1.350 s ±  0.004 s    [User: 1.313 s, System: 0.032 s]                                                                                                                                                                                                                                                                                                                                                            
  Range (min … max):    1.343 s ±  1.358 s    10 runs

#14696

Benchmark 1: ./result/bin/nix flake metadata "https://releases.nixos.org/nixos/25.05/nixos-25.05.813095.1c8ba8d3f763/nixexprs.tar.xz" --store "dummy://?read-only=false"
  Time (mean ± σ):      1.323 s ±  0.002 s    [User: 1.287 s, System: 0.031 s]
  Range (min … max):    1.320 s ±  1.326 s    10 runs

So, a small but measurable improvement on this command? Let me know if there's a better command to test.

thomasjm avatar Dec 03 '25 02:12 thomasjm

You do have to nuke the tarball cache first. This is probably just measuring just the time to copy everything in memory from an existing cache.

xokdvium avatar Dec 03 '25 10:12 xokdvium

Okay, now trying like this:

hyperfine 'rm -rf ~/.cache/nix && ./result/bin/nix flake metadata "https://releases.nixos.org/nixos/25.05/nixos-25.05.813095.1c8ba8d3f763/nixexprs.tar.xz" --store "dummy://?read-only=false"' --warmup 1

#14689

Benchmark 1: rm -rf ~/.cache/nix && ./result/bin/nix flake metadata "https://releases.nixos.org/nixos/25.05/nixos-25.05.813095.1c8ba8d3f763/nixexprs.tar.xz" --store "dummy://?read-only=false"
  Time (mean ± σ):     33.134 s ± 25.870 s    [User: 19.789 s, System: 2.121 s]
  Range (min … max):   14.988 s … 104.761 s    10 runs
 
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Let me try this again...a second time produced this:

Benchmark 1: rm -rf ~/.cache/nix && ./result/bin/nix flake metadata "https://releases.nixos.org/nixos/25.05/nixos-25.05.813095.1c8ba8d3f763/nixexprs.tar.xz" --store "dummy://?read-only=false"
  Time (mean ± σ):     14.342 s ±  1.134 s    [User: 18.139 s, System: 1.106 s]
  Range (min … max):   12.760 s … 16.006 s    10 runs

#14696

Benchmark 1: rm -rf ~/.cache/nix && ./result/bin/nix flake metadata "https://releases.nixos.org/nixos/25.05/nixos-25.05.813095.1c8ba8d3f763/nixexprs.tar.xz" --store "dummy://?read-only=false"
  Time (mean ± σ):     20.919 s ±  3.999 s    [User: 20.405 s, System: 0.723 s]
  Range (min … max):   17.761 s … 31.421 s    10 runs

Attempt 2:

Benchmark 1: rm -rf ~/.cache/nix && ./result/bin/nix flake metadata "https://releases.nixos.org/nixos/25.05/nixos-25.05.813095.1c8ba8d3f763/nixexprs.tar.xz" --store "dummy://?read-only=false"
  Time (mean ± σ):     14.710 s ±  0.955 s    [User: 18.727 s, System: 0.386 s]
  Range (min … max):   13.685 s … 16.779 s    10 runs

Conclusion: I'm getting some noisy results, not really able to discern an improvement on this command for #14696.

thomasjm avatar Dec 03 '25 23:12 thomasjm