2024-02-20 14:11:00 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2023-06-06 07:49:52 +00:00
|
|
|
|
|
|
|
{
|
2024-02-20 18:35:03 +00:00
|
|
|
nix.settings = {
|
2024-02-20 12:16:00 +00:00
|
|
|
# see: `man nix.conf`
|
2024-02-20 18:35:03 +00:00
|
|
|
|
2024-02-26 15:00:07 +00:00
|
|
|
# useful when a remote builder has a faster internet connection than me.
|
|
|
|
# note that this also applies to `nix copy --to`, though.
|
|
|
|
# i think any time a remote machine wants a path, this means we ask them to try getting it themselves before we supply it.
|
2024-02-20 18:35:03 +00:00
|
|
|
builders-use-substitutes = true; # default: false
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# maximum seconds to wait when connecting to binary substituter
|
2024-02-20 18:35:03 +00:00
|
|
|
connect-timeout = 3; # default: 0
|
|
|
|
|
|
|
|
# download-attempts = 5; # default: 5
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# allow `nix flake ...` command
|
2024-02-20 18:35:03 +00:00
|
|
|
experimental-features = [ "nix-command" "flakes "];
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# whether to build from source when binary substitution fails
|
2024-02-20 18:35:03 +00:00
|
|
|
fallback = true; # default: false
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# whether to keep building dependencies if any other one fails
|
2024-02-20 18:35:03 +00:00
|
|
|
keep-going = true; # default: false
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# whether to keep build-only dependencies of GC roots (e.g. C compiler) when doing GC
|
2024-02-20 18:35:03 +00:00
|
|
|
keep-outputs = true; # default: false
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# how many lines to show from failed build
|
2024-02-20 18:35:03 +00:00
|
|
|
log-lines = 30; # default: 10
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# how many substitution downloads to perform in parallel.
|
|
|
|
# i wonder if parallelism is causing moby's substitutions to fail?
|
2024-02-20 18:35:03 +00:00
|
|
|
max-substitution-jobs = 6; # default: 16
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# narinfo-cache-negative-ttl = 3600 # default: 3600
|
|
|
|
# whether to use ~/.local/state/nix/profile instead of ~/.nix-profile, etc
|
2024-02-20 18:35:03 +00:00
|
|
|
use-xdg-base-directories = true; # default: false
|
|
|
|
|
2024-02-20 12:16:00 +00:00
|
|
|
# whether to warn if repository has uncommited changes
|
2024-02-20 18:35:03 +00:00
|
|
|
warn-dirty = false; # default: true
|
|
|
|
|
|
|
|
# hardlinks identical files in the nix store to save 25-35% disk space.
|
|
|
|
# unclear _when_ this occurs. it's not a service.
|
|
|
|
# does the daemon continually scan the nix store?
|
|
|
|
# does the builder use some content-addressed db to efficiently dedupe?
|
|
|
|
auto-optimise-store = true;
|
|
|
|
|
|
|
|
# allow #!nix-shell scripts to locate my patched nixpkgs & custom packages.
|
|
|
|
# this line might become unnecessary: see <https://github.com/NixOS/nixpkgs/pull/273170>
|
|
|
|
nix-path = config.nix.nixPath;
|
|
|
|
};
|
2024-02-20 12:16:00 +00:00
|
|
|
|
2024-02-20 14:11:00 +00:00
|
|
|
# allow `nix-shell` (and probably nix-index?) to locate our patched and custom packages.
|
|
|
|
# this is actually a no-op, and the real action happens in assigning `nix.settings.nix-path`.
|
2024-04-09 20:20:36 +00:00
|
|
|
nix.nixPath = (lib.optionals (config.sane.maxBuildCost >= 2) [
|
2023-06-06 07:49:52 +00:00
|
|
|
"nixpkgs=${pkgs.path}"
|
2024-03-03 03:53:13 +00:00
|
|
|
]) ++ [
|
2023-06-06 07:49:52 +00:00
|
|
|
# note the import starts at repo root: this allows `./overlay/default.nix` to access the stuff at the root
|
2023-06-22 23:34:15 +00:00
|
|
|
# "nixpkgs-overlays=${../../..}/hosts/common/nix-path/overlay"
|
|
|
|
# as long as my system itself doesn't rely on NIXPKGS at runtime, we can point the overlays to git
|
|
|
|
# to avoid switching so much during development
|
2024-02-20 12:13:52 +00:00
|
|
|
"nixpkgs-overlays=/home/colin/dev/nixos/hosts/common/nix/overlay"
|
2023-06-06 07:49:52 +00:00
|
|
|
];
|
2023-11-08 23:56:31 +00:00
|
|
|
|
|
|
|
# ensure new deployments have a source of this repo with which they can bootstrap.
|
2024-03-02 22:13:04 +00:00
|
|
|
# this however changes on every commit and can be slow to copy for e.g. `moby`.
|
2024-04-09 20:20:36 +00:00
|
|
|
environment.etc."nixos" = lib.mkIf (config.sane.maxBuildCost >= 2) {
|
2024-03-02 22:13:04 +00:00
|
|
|
source = ../../..;
|
|
|
|
};
|
2024-04-09 20:20:36 +00:00
|
|
|
environment.etc."nix/registry.json" = lib.mkIf (config.sane.maxBuildCost < 2) {
|
2024-03-02 23:42:58 +00:00
|
|
|
enable = false;
|
|
|
|
};
|
2024-02-20 12:16:00 +00:00
|
|
|
|
|
|
|
systemd.services.nix-daemon.serviceConfig = {
|
|
|
|
# the nix-daemon manages nix builders
|
|
|
|
# kill nix-daemon subprocesses when systemd-oomd detects an out-of-memory condition
|
|
|
|
# see:
|
|
|
|
# - nixos PR that enabled systemd-oomd: <https://github.com/NixOS/nixpkgs/pull/169613>
|
|
|
|
# - systemd's docs on these properties: <https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#ManagedOOMSwap=auto%7Ckill>
|
|
|
|
#
|
|
|
|
# systemd's docs warn that without swap, systemd-oomd might not be able to react quick enough to save the system.
|
|
|
|
# see `man oomd.conf` for further tunables that may help.
|
|
|
|
#
|
|
|
|
# alternatively, apply this more broadly with `systemd.oomd.enableSystemSlice = true` or `enableRootSlice`
|
|
|
|
# TODO: also apply this to the guest user's slice (user-1100.slice)
|
|
|
|
# TODO: also apply this to distccd
|
|
|
|
ManagedOOMMemoryPressure = "kill";
|
|
|
|
ManagedOOMSwap = "kill";
|
|
|
|
};
|
2023-06-06 07:49:52 +00:00
|
|
|
}
|