2024-02-02 10:51:31 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2023-07-18 17:00:31 +02:00
|
|
|
|
|
|
|
let
|
2023-11-29 14:58:05 +01:00
|
|
|
inherit (lib) mkEnableOption mkOption mkIf;
|
2023-07-18 17:00:31 +02:00
|
|
|
|
|
|
|
cfg = config.dgn-console;
|
2024-02-02 10:51:31 +01:00
|
|
|
in
|
|
|
|
{
|
2023-07-18 17:00:31 +02:00
|
|
|
options.dgn-console = {
|
2024-02-02 10:51:31 +01:00
|
|
|
enable = mkEnableOption "DGNum console setup." // {
|
|
|
|
default = true;
|
|
|
|
};
|
2023-11-29 14:58:05 +01:00
|
|
|
|
|
|
|
pg-upgrade-to = mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
default = pkgs.postgresql_15;
|
|
|
|
};
|
2023-07-18 17:00:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
time.timeZone = "Europe/Paris";
|
|
|
|
|
2024-02-02 10:51:31 +01:00
|
|
|
console = {
|
|
|
|
keyMap = "fr";
|
|
|
|
};
|
2023-07-18 17:00:31 +02:00
|
|
|
|
|
|
|
environment.variables.EDITOR = "nvim";
|
|
|
|
|
|
|
|
programs.neovim.vimAlias = true;
|
|
|
|
|
2024-01-07 18:17:14 +01:00
|
|
|
system.activationScripts.diff = {
|
|
|
|
supportsDryActivation = true;
|
|
|
|
text = ''
|
|
|
|
${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff /run/current-system "$systemConfig"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-07-18 17:00:31 +02:00
|
|
|
programs.bash.promptInit = ''
|
2023-07-20 15:48:24 +02:00
|
|
|
FQDN="$(hostname).$(domainname)"
|
2023-07-18 17:00:31 +02:00
|
|
|
# Provide a nice prompt if the terminal supports it.
|
|
|
|
if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then
|
|
|
|
PROMPT_COLOR="1;31m"
|
|
|
|
((UID)) && PROMPT_COLOR="1;32m"
|
|
|
|
if [ -n "$INSIDE_EMACS" ] || [ "$TERM" = "eterm" ] || [ "$TERM" = "eterm-color" ]; then
|
|
|
|
# Emacs term mode doesn't support xterm title escape sequence (\e]0;)
|
2023-07-20 15:48:24 +02:00
|
|
|
PS1="\n\[\033[$PROMPT_COLOR\][\u@$FQDN:\w]\\$\[\033[0m\] "
|
2023-07-18 17:00:31 +02:00
|
|
|
else
|
2023-07-20 15:48:24 +02:00
|
|
|
PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\H: \w\a\]\u@$FQDN:\w]\\$\[\033[0m\] "
|
2023-07-18 17:00:31 +02:00
|
|
|
fi
|
|
|
|
if test "$TERM" = "xterm"; then
|
2023-07-20 15:48:24 +02:00
|
|
|
PS1="\[\033]2;$FQDN:\u:\w\007\]$PS1"
|
2023-07-18 17:00:31 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
hardware.enableRedistributableFirmware = true;
|
2023-11-29 14:58:05 +01:00
|
|
|
|
2024-02-02 10:51:31 +01:00
|
|
|
environment.systemPackages =
|
|
|
|
(with pkgs; [
|
|
|
|
neovim
|
|
|
|
wget
|
|
|
|
kitty.terminfo
|
2024-03-24 18:11:26 +01:00
|
|
|
|
|
|
|
# Utilities
|
|
|
|
bcc
|
|
|
|
bottom
|
|
|
|
cpuid
|
2024-03-27 15:15:44 +01:00
|
|
|
dig
|
2024-03-24 18:11:26 +01:00
|
|
|
htop
|
|
|
|
iftop
|
2024-03-27 15:15:44 +01:00
|
|
|
mtr
|
2024-03-24 18:11:26 +01:00
|
|
|
tcpdump
|
2024-02-02 10:51:31 +01:00
|
|
|
])
|
|
|
|
++ lib.optional
|
|
|
|
(config.services.postgresql.enable && config.services.postgresql.package != cfg.pg-upgrade-to)
|
|
|
|
(
|
|
|
|
pkgs.writeScriptBin "upgrade-pg-cluster" ''
|
|
|
|
set -eux
|
|
|
|
# XXX it's perhaps advisable to stop all services that depend on postgresql
|
|
|
|
systemctl stop postgresql
|
|
|
|
|
|
|
|
export NEWDATA="/var/lib/postgresql/${cfg.pg-upgrade-to.psqlSchema}"
|
|
|
|
|
|
|
|
export NEWBIN="${cfg.pg-upgrade-to}/bin"
|
|
|
|
|
|
|
|
export OLDDATA="${config.services.postgresql.dataDir}"
|
|
|
|
export OLDBIN="${config.services.postgresql.package}/bin"
|
|
|
|
|
|
|
|
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
|
|
|
|
cd "$NEWDATA"
|
|
|
|
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA"
|
|
|
|
|
|
|
|
sudo -u postgres $NEWBIN/pg_upgrade \
|
|
|
|
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
|
|
|
|
--old-bindir $OLDBIN --new-bindir $NEWBIN \
|
|
|
|
"$@"
|
|
|
|
''
|
|
|
|
);
|
2023-07-18 17:00:31 +02:00
|
|
|
};
|
|
|
|
}
|