nixos-config/fudo/profiles/server.nix

78 lines
1.5 KiB
Nix
Raw Normal View History

2020-02-03 17:07:46 -08:00
{ config, lib, pkgs, ... }:
with lib;
let
2020-12-02 08:44:56 -08:00
reboot-if-necessary = pkgs.writeShellScriptBin "reboot-if-necessary" ''
2020-02-03 17:07:46 -08:00
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
'';
2020-12-02 08:44:56 -08:00
test-config = pkgs.writeShellScriptBin "fudo-test-config" ''
2020-02-03 17:07:46 -08:00
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 {
config = mkIf (config.fudo.common.profile == "server") {
environment = {
systemPackages = with pkgs; [
2020-10-24 09:14:46 -07:00
emacs-nox
2020-06-25 20:38:50 -07:00
ldns
ldns.examples
jdk12_headless
2020-07-23 22:38:48 -07:00
racket-minimal
2020-02-03 17:07:46 -08:00
reboot-if-necessary
2020-07-23 22:38:48 -07:00
test-config
2020-02-03 17:07:46 -08:00
];
noXlibs = true;
};
security = {
hideProcessInformation = true;
};
networking = {
networkmanager.enable = mkForce false;
2020-10-24 09:14:46 -07:00
};
2020-02-03 17:07:46 -08:00
boot.tmpOnTmpfs = true;
services.xserver.enable = false;
programs = {
gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
};
};
}