flake/modules/core/nix.nix
2024-05-24 22:56:19 +00:00

94 lines
2.7 KiB
Nix

{
config,
pkgs,
lib,
inputs,
...
}: {
environment = {
# set channels (backwards compatibility)
etc = {
"nix/flake-channels/nixpkgs".source = inputs.nixpkgs;
"nix/flake-channels/home-manager".source = inputs.home-manager;
};
systemPackages = with pkgs; [git deadnix alejandra statix];
defaultPackages = [];
};
nixpkgs = {
config = {
allowUnfree = false;
allowBroken = true;
};
};
# faster rebuilding
documentation = {
enable = true;
doc.enable = false;
man.enable = true;
dev.enable = false;
};
nix = {
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
};
package = pkgs.nixVersions.git;
# Make builds run with low priority so my system stays responsive
daemonCPUSchedPolicy = "idle";
daemonIOSchedClass = "idle";
# pin the registry to avoid downloading and evaling a new nixpkgs version every time
registry = lib.mapAttrs (_: v: {flake = v;}) inputs;
# This will additionally add your inputs to the system's legacy channels
# Making legacy nix commands consistent as well, awesome!
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
# Free up to 1GiB whenever there is less than 100MiB left.
extraOptions = ''
experimental-features = nix-command flakes
keep-outputs = true
warn-dirty = false
keep-derivations = true
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)}
use-xdg-base-directories = true
'';
settings = {
auto-optimise-store = true;
# use binary cache, its not gentoo
builders-use-substitutes = true;
# allow sudo users to mark the following values as trusted
allowed-users = ["@wheel"];
# only allow sudo users to manage the nix store
trusted-users = ["@wheel"];
sandbox = true;
max-jobs = "auto";
# continue building derivations if one fails
keep-going = true;
log-lines = 20;
extra-experimental-features = ["flakes" "nix-command" "recursive-nix" "ca-derivations"];
# use binary cache, its not gentoo
substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
"https://nixpkgs-unfree.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nixpkgs-unfree.cachix.org-1:hqvoInulhbV4nJ9yJOEr+4wxhDV4xq2d1DK7S6Nj6rs="
];
};
};
system.autoUpgrade.enable = false;
system.stateVersion = "23.05"; # DONT TOUCH THIS
}