nixconfig/nixos/common.nix

81 lines
2.2 KiB
Nix

# INFO: this module is also sourced by Darwin hosts
{ inputs, lib, ... }:
let
registryInputs =
lib.mapAttrs (_: val: { flake = val; })
(lib.filterAttrs (name: value: name != "self" && (builtins.hasAttr "_type" value) && value._type == "flake") inputs);
in
{
# I don't use GNU's info
documentation.info.enable = false;
# Just expose everything possible so shell completion works
environment.pathsToLink = [
"/share/fish"
"/share/zsh"
"/share/bash-completion"
];
fonts.fontDir.enable = true;
nix.nixPath = [
"nixpkgs=${inputs.nixpkgs}"
"/nix/var/nix/profiles/per-user/root/channels"
];
nix.registry = registryInputs // { dotfiles.flake = inputs.self; };
nix.settings = {
auto-allocate-uids = true;
auto-optimise-store = true;
sandbox = true;
keep-outputs = true;
use-xdg-base-directories = true;
http-connections = 0;
max-jobs = "auto";
trusted-users = [ "root" ];
# Fallback quickly if substituters are not available.
connect-timeout = 5;
# Avoid copying unnecessary stuff over SSH
builders-use-substitutes = true;
# Avoid disk full issues
max-free = 3000 * 1024 * 1024;
min-free = 512 * 1024 * 1024;
# The default at 10 is rarely enough.
log-lines = 25;
# Flakes are set explicitly via nix.registry, so don't imply any URLs here
flake-registry = builtins.toFile "empty-registry.json" (builtins.toJSON {
flakes = [ ];
version = 2;
});
experimental-features = [
"auto-allocate-uids"
"ca-derivations"
"flakes"
"nix-command"
];
substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
"https://nixpkgs-unfree.cachix.org"
"https://numtide.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nixpkgs-unfree.cachix.org-1:hqvoInulhbV4nJ9yJOEr+4wxhDV4xq2d1DK7S6Nj6rs="
"numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE="
];
};
nixpkgs.config.allowUnfree = true;
nixpkgs.overlays = [ inputs.vscode-extensions.overlays.default ];
}