My Nix Configuration

[modules.default-config] Update nix configuration

Changed files
+85 -17
modules
nixos
default-config
+85 -17
modules/nixos/default-config/nixConfig.nix
···
+
{
+
pkgs,
+
lib,
+
inputs,
+
...
+
}:
+
let
+
userList = [
+
"root"
+
"thehedgehog"
+
"pyrox"
+
];
+
flakeInputs = lib.filterAttrs (name: value: (value ? outputs) && (name != "self")) inputs;
+
in
{
nix = {
enable = true;
# We use `nh.clean` instead, so this is disabled
gc.automatic = false;
-
extraOptions = ''
-
extra-experimental-features = nix-command flakes
-
allowed-uris = http:// https://
-
'';
+
registry = lib.mapAttrs (_: v: { flake = v; }) flakeInputs;
settings = {
+
# Don't auto-accept flake-defined nix settings, they're a CVE waiting to happen.
+
accept-flake-config = false;
+
# Allow these users to access the daemon
+
allowed-users = userList;
+
# No pre-defined nixbld users
+
auto-allocate-uids = true;
+
# Always optimize the store
+
auto-optimise-store = true;
+
# Compress build logs to save space
+
compress-build-log = true;
+
# Use all available cores to build
cores = 0;
-
auto-optimise-store = true;
-
trusted-users = [
-
"root"
-
"thehedgehog"
-
"pyrox"
+
experimental-features = [
+
# Nix3 CLI
+
"nix-command"
+
# Duh
+
"flakes"
+
# Use auto-generated uids instead of users in the nixbld group
+
"auto-allocate-uids"
+
# Can allow saving space in the store by content-addressing instead of input-addressing derivations
+
"ca-derivations"
+
# Build inside cgroups
+
"cgroups"
+
# Disallow URL Literals as they are deprecated
+
"no-url-literals"
+
# Allow Nix to call itself
+
"recursive-nix"
+
# Allow installables to be passed to `nix repl`
+
"repl-flake"
];
-
trusted-substituters = [
-
"https://cache.nixos.org"
-
"https://crane.cachix.org"
-
"https://isabelroses.cachix.org"
-
"https://nix-community.cachix.org"
-
"https://nixpkgs-wayland.cachix.org"
-
"https://viperml.cachix.org"
-
"https://cache.lix.systems"
+
# Build from source if substitution fails
+
fallback = true;
+
# Write an empty flake registry
+
flake-registry = pkgs.writers.writeJSON "registry-empty.json" {
+
flakes = [ ];
+
version = 2;
+
};
+
# allow keeping direnv gc roots
+
keep-derivations = true;
+
# Keep going even if a build fails, so that all possible succeeding builds do
+
keep-going = true;
+
# More direnv gc root stuff
+
keep-outputs = true;
+
# Show fewer log lines from failed builds since I get them from nh
+
log-lines = 10;
+
# Extra system features
+
system-features = [
+
"big-parallel"
+
"kvm"
+
"nixos-test"
+
"recursive-nix"
];
+
# The pubkeys of the below substituters
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk="
···
"viperml.cachix.org-1:qZhKBMTfmcLL+OG6fj/hzsMEedgKvZVFRRAhq7j8Vh8="
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
];
+
# Extra substituters
+
trusted-substituters = [
+
"https://cache.nixos.org"
+
"https://crane.cachix.org"
+
"https://isabelroses.cachix.org"
+
"https://nix-community.cachix.org"
+
"https://nixpkgs-wayland.cachix.org"
+
"https://viperml.cachix.org"
+
"https://cache.lix.systems"
+
];
+
# These users have additional daemon rights
+
trusted-users = userList;
+
# Use cgroups for building
+
use-cgroups = true;
+
# Allow use of the registry
+
use-registries = true;
+
# XDG base dirs to avoid cluttering $HOME
+
use-xdg-base-directories = true;
+
# I almost always work in a dirty tree, I know it's dirty
+
warn-dirty = false;
};
};
}