Skip to content

Commit 28532c2

Browse files
authored
Merge pull request #519 from NixOS/build-cleanup
build: prune common configuration
2 parents 0d476c9 + 211023c commit 28532c2

24 files changed

Lines changed: 140 additions & 820 deletions

build/common.nix

Lines changed: 54 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
2-
config,
32
pkgs,
43
lib,
54
...
65
}:
76

8-
with lib;
9-
107
{
118
imports = [
129
./diffoscope.nix
@@ -17,61 +14,71 @@ with lib;
1714

1815
nixpkgs.config.allowUnfree = true;
1916

20-
services.openssh.authorizedKeysFiles = mkForce [ "/etc/ssh/authorized_keys.d/%u" ];
21-
22-
boot.kernelModules = [ "coretemp" ];
23-
24-
# Prevent "out of sync" errors on the KVM switch.
25-
boot.vesa = false;
26-
boot.blacklistedKernelModules = [
27-
"radeonfb"
28-
"radeon"
29-
"i915"
30-
];
31-
boot.kernelParams = [ "nomodeset" ];
32-
3317
hardware.enableAllFirmware = true;
3418
hardware.cpu.amd.updateMicrocode = true;
3519
hardware.cpu.intel.updateMicrocode = true;
3620

37-
environment.systemPackages = [
38-
pkgs.emacs
39-
pkgs.sysstat
40-
pkgs.hdparm
41-
pkgs.sdparm # pkgs.lsiutil
42-
pkgs.htop
43-
pkgs.sqlite
44-
pkgs.iotop
45-
pkgs.lm_sensors
46-
pkgs.hwloc
47-
pkgs.lsof
48-
pkgs.numactl
49-
pkgs.gcc
50-
pkgs.smartmontools
51-
pkgs.tcpdump
52-
pkgs.gdb
53-
pkgs.elfutils
54-
];
21+
boot.kernel.sysctl = {
22+
# reboot on kernel panic
23+
"kernel.panic" = 60;
24+
"kernel.panic_on_oops" = 1;
25+
};
5526

56-
services.openssh.enable = true;
27+
documentation.nixos.enable = false;
5728

58-
boot.kernel.sysctl."kernel.panic" = 60;
59-
boot.kernel.sysctl."kernel.panic_on_oops" = 1;
29+
environment = {
30+
enableDebugInfo = true;
31+
systemPackages = with pkgs; [
32+
# debugging
33+
gdb
34+
lsof
35+
sqlite-interactive
36+
37+
# editors
38+
emacs
39+
helix
40+
neovim
41+
42+
# utilities
43+
ripgrep
44+
fd
45+
46+
# system introspection
47+
hdparm
48+
htop
49+
iotop
50+
lm_sensors
51+
nvme-cli
52+
smartmontools
53+
sysstat
54+
tcpdump
55+
tmux
56+
];
57+
};
6058

61-
nix.nrBuildUsers = 100;
59+
services.openssh = {
60+
enable = true;
61+
authorizedKeysFiles = lib.mkForce [ "/etc/ssh/authorized_keys.d/%u" ];
62+
};
6263

6364
nix.extraOptions = ''
6465
allowed-impure-host-deps = /etc/protocols /etc/services /etc/nsswitch.conf
6566
allowed-uris = https://github.com/ https://git.savannah.gnu.org/ github:
6667
'';
6768

69+
# we use networkd
6870
networking.useDHCP = false;
6971

70-
networking.firewall.enable = true;
71-
networking.firewall.rejectPackets = true;
72-
networking.firewall.allowPing = true;
73-
networking.firewall.allowedTCPPorts = [ 10050 ];
74-
networking.firewall.logRefusedConnections = false;
72+
networking.firewall = {
73+
enable = true;
74+
75+
# be a good network citizen and allow some debugging interactions
76+
rejectPackets = true;
77+
allowPing = true;
78+
79+
# prevent firewall log spam from rotating the kernel rinbuffer
80+
logRefusedConnections = false;
81+
};
7582

7683
services.resolved = {
7784
enable = true;
@@ -84,37 +91,10 @@ with lib;
8491
];
8592
};
8693

87-
# Bump the open files limit so that non-root users can run NixOS VM
88-
# tests (Samba opens lot of files).
89-
security.pam.loginLimits = [
90-
{
91-
domain = "*";
92-
item = "nofile";
93-
type = "-";
94-
value = "16384";
95-
}
96-
];
97-
98-
# Enable Kernel Samepage Merging (reduces memory footprint of VMs).
99-
hardware.ksm.enable = true;
100-
101-
# Disable the systemd-journald watchdog. The default timeout (1min)
102-
# can easily be triggered on our slow, heavily-loaded disks. And
103-
# that may cause services writing to the journal to fail until
104-
# they're restarted.
105-
systemd.services.systemd-journald.serviceConfig.WatchdogSec = 0;
106-
107-
environment.enableDebugInfo = true;
108-
109-
systemd.tmpfiles.rules = [ "d /tmp 1777 root root 7d" ];
110-
111-
# Disable sending email from cron.
112-
services.cron.mailto = "";
113-
114-
documentation.nixos.enable = false;
115-
116-
security.acme.acceptTerms = true;
117-
security.acme.defaults.email = "infra@nixos.org";
94+
security.acme = {
95+
acceptTerms = true;
96+
defaults.email = "infra@nixos.org";
97+
};
11898

11999
services.zfs.autoScrub.enable = true;
120100
}

build/diffoscope.nix

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
{ pkgs, ... }:
2-
3-
with pkgs.lib;
1+
{
2+
pkgs,
3+
...
4+
}:
45

56
let
67

78
diffoscopeWrapper = pkgs.writeScript "diffoscope-wrapper" ''
8-
#! ${pkgs.stdenv.shell}
9-
exec >&2
10-
echo ""
11-
echo "non-determinism detected in $2; diff with previous round follows:"
12-
echo ""
13-
time ${pkgs.utillinux}/bin/runuser -u diffoscope -- ${pkgs.diffoscope}/bin/diffoscope "$1" "$2"
14-
exit 0
9+
#! ${pkgs.stdenv.shell}
10+
exec >&2
11+
echo ""
12+
echo "non-determinism detected in $2; diff with previous round follows:"
13+
echo ""
14+
time ${pkgs.utillinux}/bin/runuser -u diffoscope -- ${pkgs.diffoscope}/bin/diffoscope "$1" "$2"
15+
exit 0
1516
'';
1617

1718
in

build/flake.nix

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,6 @@
7979
];
8080
};
8181

82-
nixosConfigurations.rhea = nixpkgs.lib.nixosSystem {
83-
system = "x86_64-linux";
84-
85-
modules = [
86-
flakesModule
87-
./rhea/configuration.nix
88-
];
89-
};
90-
9182
nixosConfigurations.mimas = nixpkgs.lib.nixosSystem {
9283
system = "x86_64-linux";
9384

0 commit comments

Comments
 (0)