includeos / IncludeOS

A minimal, resource efficient unikernel for cloud services
https://includeos.github.io/
Apache License 2.0
4.93k stars 365 forks source link

nix: add optional ccache support #2271

Closed MagnusS closed 2 months ago

MagnusS commented 2 months ago

Adds a new attribute withCcache that defaults to false. When enabled, a wrapper around clang/clang++ will be added to the IncludeOS build environment.

With an existing cache, this reduces the service build time to about 1/5 on my server when the kernel also has to be rebuilt.

The directory used for caching is /nix/var/cache/ccache and it has to exist with the right permissions. See overlay.nix for additional details.

To enable ccache, pass "--arg withCcache true" to either nix-build or nix-shell.

To manage the ccache, install "ccache" locally. Then "sudo ccache --dir /nix/var/cache/ccache --show-stats" will show cache statistics and "sudo ccache --dir /nix/var/cache/ccache --clear" will clear the cache.

Ccache is currently disabled on unittests and integration tests to make sure that these are built from a clean environment.

fwsGonzo commented 2 months ago

What's the reason behind having to run sudo to interact with ccache here? It hasn't been required for my own projects.

MagnusS commented 2 months ago

What's the reason behind having to run sudo to interact with ccache here? It hasn't been required for my own projects.

It's only required when nix is installed in multiuser mode. Then the cache directory will be owned by the nix user.

MagnusS commented 2 months ago

I've used this for a few days now and it saves a lot of time, so I'll merge this