2023-03-05 03:50:04 +00:00
|
|
|
{ config, lib, sane-lib, ... }:
|
2023-03-05 01:03:59 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) mkIf mkOption types;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.sane.roles.build-machine = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.sane.roles.build-machine {
|
|
|
|
# serve packages to other machines that ask for them
|
|
|
|
sane.services.nixserve.enable = true;
|
|
|
|
|
|
|
|
# enable cross compilation
|
|
|
|
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
|
|
|
|
# nixpkgs.config.allowUnsupportedSystem = true;
|
2023-03-05 03:13:11 +00:00
|
|
|
|
|
|
|
# granular compilation cache
|
|
|
|
# docs: <https://nixos.wiki/wiki/CCache>
|
2023-03-05 03:50:04 +00:00
|
|
|
# investigate the cache with:
|
|
|
|
# - `nix-ccache --show-stats`
|
|
|
|
# - `build '.#ccache'
|
|
|
|
# - `sudo CCACHE_DIR=/var/cache/ccache ./result/bin/ccache --show-stats -v`
|
|
|
|
# TODO: whitelist `--verbose` in <nixpkgs:nixos/modules/programs/ccache.nix>
|
|
|
|
# TODO: configure without compression (leverage fs-level compression), and enable file-clone (i.e. hardlinks)
|
2023-03-05 03:13:11 +00:00
|
|
|
programs.ccache.enable = true;
|
|
|
|
sane.persist.sys.plaintext = [
|
|
|
|
{ group = "nixbld"; mode = "0775"; directory = config.programs.ccache.cacheDir; }
|
|
|
|
];
|
2023-03-05 03:50:04 +00:00
|
|
|
sane.fs."/var/cache/ccache/ccache.conf" = sane-lib.fs.wantedText ''
|
|
|
|
max_size = 50G
|
|
|
|
'';
|
2023-03-05 03:13:11 +00:00
|
|
|
nix.settings.extra-sandbox-paths = [ config.programs.ccache.cacheDir ];
|
|
|
|
programs.ccache.packageNames = [
|
|
|
|
# these have to exist in toplevel package set:
|
|
|
|
# nixpkgs config creates an overlay which overrides each of these packages to build with ccache
|
|
|
|
# note a potential bootstrapping problem: if the cache directory above hasn't yet been created, then this blocks deployment.
|
|
|
|
# solution is to manually disable all these entries on the first deployment
|
|
|
|
# TODO: distribute these elsewhere; make sure it works on cross-compiled builds
|
|
|
|
"firefox-esr"
|
|
|
|
# "qtwebengine"
|
|
|
|
"webkitgtk"
|
|
|
|
];
|
2023-03-05 01:03:59 +00:00
|
|
|
};
|
|
|
|
}
|