feat(nixos): improve nix configuration and tmp handling

- Reformatted function parameters to enhance readability.
- Added `build-dir = "/var/tmp"` to nix settings for better build management.
- Removed redundant `TMPDIR` environment variable for nix-daemon in systemd services.
This commit is contained in:
Harald Hoyer 2025-09-28 08:09:41 +02:00
parent 3b0809697d
commit 92a9c0756c
2 changed files with 30 additions and 27 deletions

View file

@ -59,35 +59,38 @@ in
users = [ users = [
"root" "root"
config.metacfg.user.name config.metacfg.user.name
] ++ optional config.services.hydra.enable "hydra"; ]
++ optional config.services.hydra.enable "hydra";
extra-substituters = cfg.extra-substituters; extra-substituters = cfg.extra-substituters;
in in
{ {
package = cfg.package; package = cfg.package;
settings = settings = {
{ experimental-features = "nix-command flakes";
experimental-features = "nix-command flakes"; build-dir = "/var/tmp";
http-connections = 50; http-connections = 50;
warn-dirty = false; warn-dirty = false;
log-lines = 50; log-lines = 50;
sandbox = true; sandbox = true;
auto-optimise-store = true; auto-optimise-store = true;
trusted-users = users; trusted-users = users;
allowed-users = users; allowed-users = users;
substituters = [ substituters = [
cfg.default-substituter.url cfg.default-substituter.url
] ++ (mapAttrsToList (name: value: name) extra-substituters); ]
trusted-public-keys = [ ++ (mapAttrsToList (name: value: name) extra-substituters);
cfg.default-substituter.key trusted-public-keys = [
] ++ (mapAttrsToList (name: value: value.key) extra-substituters); cfg.default-substituter.key
]
++ (mapAttrsToList (name: value: value.key) extra-substituters);
} }
// (lib.optionalAttrs config.metacfg.tools.direnv.enable { // (lib.optionalAttrs config.metacfg.tools.direnv.enable {
keep-outputs = true; keep-outputs = true;
keep-derivations = true; keep-derivations = true;
}); });
gc = { gc = {
automatic = true; automatic = true;

View file

@ -1,7 +1,8 @@
{ config {
, lib config,
, pkgs lib,
, ... pkgs,
...
}: }:
with lib; with lib;
with lib.metacfg; with lib.metacfg;
@ -188,7 +189,6 @@ in
virtualisation.libvirtd.enable = lib.mkDefault true; virtualisation.libvirtd.enable = lib.mkDefault true;
boot.tmp.useTmpfs = true; boot.tmp.useTmpfs = true;
systemd.services.nix-daemon.environment.TMPDIR = "/var/tmp";
services.fstrim.enable = true; services.fstrim.enable = true;
}; };