Tom Hubrecht
10a925021f
All checks were successful
build configuration / build_vault01 (push) Successful in 1m6s
build configuration / build_web02 (push) Successful in 1m11s
build configuration / build_storage01 (push) Successful in 1m14s
build configuration / build_compute01 (push) Successful in 1m17s
build configuration / build_rescue01 (push) Successful in 1m18s
lint / check (push) Successful in 24s
build configuration / build_web01 (push) Successful in 1m33s
build configuration / push_to_cache (push) Successful in 2m10s
105 lines
2.7 KiB
Nix
105 lines
2.7 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
inherit (lib) mkEnableOption mkOption mkIf;
|
|
|
|
cfg = config.dgn-console;
|
|
in
|
|
{
|
|
options.dgn-console = {
|
|
enable = mkEnableOption "DGNum console setup." // {
|
|
default = true;
|
|
};
|
|
|
|
pg-upgrade-to = mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.postgresql_15;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
time.timeZone = "Europe/Paris";
|
|
|
|
console = {
|
|
keyMap = "fr";
|
|
};
|
|
|
|
environment.variables.EDITOR = "nvim";
|
|
|
|
programs.neovim.vimAlias = true;
|
|
|
|
system.activationScripts.diff = {
|
|
supportsDryActivation = true;
|
|
text = ''
|
|
${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff /run/current-system "$systemConfig"
|
|
'';
|
|
};
|
|
|
|
programs.bash.promptInit = ''
|
|
FQDN="$(hostname).$(domainname)"
|
|
# 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;)
|
|
PS1="\n\[\033[$PROMPT_COLOR\][\u@$FQDN:\w]\\$\[\033[0m\] "
|
|
else
|
|
PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\H: \w\a\]\u@$FQDN:\w]\\$\[\033[0m\] "
|
|
fi
|
|
if test "$TERM" = "xterm"; then
|
|
PS1="\[\033]2;$FQDN:\u:\w\007\]$PS1"
|
|
fi
|
|
fi
|
|
'';
|
|
|
|
hardware.enableRedistributableFirmware = true;
|
|
|
|
environment.systemPackages =
|
|
(with pkgs; [
|
|
neovim
|
|
wget
|
|
kitty.terminfo
|
|
|
|
# Utilities
|
|
bcc
|
|
bottom
|
|
cpuid
|
|
dig
|
|
htop
|
|
iftop
|
|
mtr
|
|
tcpdump
|
|
])
|
|
++ 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 \
|
|
"$@"
|
|
''
|
|
);
|
|
};
|
|
}
|