nixos-config/config/profiles/server.nix

81 lines
1.6 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
reboot-if-necessary = pkgs.writeShellScriptBin "reboot-if-necessary" ''
if [ $# -ne 1 ]; then
echo "FAILED: no sync file provided."
exit 1
fi
WALL=${pkgs.utillinux}/bin/wall
if [ -f $1 ]; then
$WALL "$1 exists, rebooting system"
${pkgs.systemd}/bin/reboot
else
$WALL "$1 does not exist, aborting reboot."
fi
exit 0
'';
test-config = pkgs.writeShellScriptBin "fudo-test-config" ''
if [ $# -gt 1 ]; then
echo "usage: $0 [timeout]"
exit 1
elif [ $# -eq 1 ]; then
TIMEOUT=$1
else
TIMEOUT=15m
fi
SYNCFILE=$TMP/sync-$(date +"%Y%m%d-%H%M%N")
touch $SYNCFILE
${pkgs.utillinux}/bin/wall "Launching config. System will restart in $TIMEOUT if $SYNCFILE still exists."
systemd-run --on-active=$TIMEOUT ${reboot-if-necessary} $SYNCFILE
nixos-rebuild test
exit 0
'';
in {
imports = [ ./common.nix ];
config = {
environment = {
systemPackages = with pkgs; [
emacs-nox
ldns
ldns.examples
jdk14_headless
racket-minimal
reboot-if-necessary
test-config
];
# noXlibs = lib.mkForce true;
};
security = { hideProcessInformation = true; };
networking.networkmanager.enable = mkForce false;
boot.tmpOnTmpfs = true;
services = {
xserver.enable = false;
emacs = {
enable = true;
install = true;
package = pkgs.emacs;
defaultEditor = true;
};
};
sound.enable = false;
hardware.pulseaudio.enable = false;
};
}