All checks were successful
Check meta / check_dns (pull_request) Successful in 19s
Check meta / check_meta (pull_request) Successful in 21s
Check workflows / check_workflows (pull_request) Successful in 26s
Build all the nodes / ap01 (pull_request) Successful in 1m29s
Build all the nodes / build01 (pull_request) Successful in 1m34s
Build all the nodes / bridge01 (pull_request) Successful in 1m40s
Build all the nodes / geo01 (pull_request) Successful in 1m33s
Build all the nodes / netaccess01 (pull_request) Successful in 19s
Build all the nodes / netcore02 (pull_request) Successful in 19s
Build all the nodes / netcore01 (pull_request) Successful in 19s
Build all the nodes / geo02 (pull_request) Successful in 2m21s
Build all the nodes / hypervisor02 (pull_request) Successful in 2m13s
Build all the nodes / hypervisor01 (pull_request) Successful in 2m21s
Build all the nodes / compute01 (pull_request) Successful in 3m7s
Build all the nodes / hypervisor03 (pull_request) Successful in 1m41s
Build all the nodes / rescue01 (pull_request) Successful in 1m35s
Build all the nodes / storage01 (pull_request) Successful in 1m30s
Build the shell / build-shell (pull_request) Successful in 23s
Run pre-commit on all files / pre-commit (pull_request) Successful in 23s
Build all the nodes / tower01 (pull_request) Successful in 2m8s
Build all the nodes / vault01 (pull_request) Successful in 2m23s
Build all the nodes / web02 (pull_request) Successful in 1m59s
Build all the nodes / web03 (pull_request) Successful in 2m9s
Build all the nodes / web01 (pull_request) Successful in 2m41s
Build all the nodes / ap01 (push) Successful in 31s
Build all the nodes / build01 (push) Successful in 1m22s
Build all the nodes / bridge01 (push) Successful in 1m24s
Build all the nodes / netaccess01 (push) Successful in 19s
Build all the nodes / netcore01 (push) Successful in 19s
Build all the nodes / hypervisor03 (push) Successful in 1m26s
Build all the nodes / netcore02 (push) Successful in 21s
Build all the nodes / hypervisor02 (push) Successful in 2m4s
Build all the nodes / geo02 (push) Successful in 2m5s
Build all the nodes / geo01 (push) Successful in 2m9s
Build all the nodes / hypervisor01 (push) Successful in 2m12s
Build all the nodes / rescue01 (push) Successful in 1m24s
Build all the nodes / compute01 (push) Successful in 3m10s
Build the shell / build-shell (push) Successful in 21s
Build all the nodes / storage01 (push) Successful in 1m33s
Build all the nodes / tower01 (push) Successful in 1m32s
Run pre-commit on all files / pre-commit (push) Successful in 40s
Build all the nodes / web02 (push) Successful in 2m0s
Build all the nodes / vault01 (push) Successful in 2m8s
Build all the nodes / web03 (push) Successful in 2m0s
Build all the nodes / web01 (push) Successful in 2m33s
137 lines
3.4 KiB
Nix
137 lines
3.4 KiB
Nix
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
|
|
#
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
{
|
|
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-from = mkOption {
|
|
type = lib.types.package;
|
|
default = config.services.postgresql.package;
|
|
description = ''
|
|
Old postgresql package.
|
|
'';
|
|
};
|
|
|
|
pg-upgrade-to = mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.postgresql_15;
|
|
description = ''
|
|
New postgresql package.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
time.timeZone = "Europe/Paris";
|
|
|
|
console = {
|
|
keyMap = "fr";
|
|
};
|
|
|
|
environment.variables.EDITOR = "nvim";
|
|
|
|
programs = {
|
|
neovim = {
|
|
enable = true;
|
|
vimAlias = true;
|
|
};
|
|
rust-motd = {
|
|
enable = true;
|
|
|
|
settings = {
|
|
uptime.prefix = "Up";
|
|
filesystems.root = "/";
|
|
memory.swap_pos = "below";
|
|
last_login.root = 5;
|
|
};
|
|
};
|
|
|
|
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
|
|
'';
|
|
};
|
|
|
|
system.activationScripts.diff = {
|
|
supportsDryActivation = true;
|
|
text = ''
|
|
${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff /run/current-system "$systemConfig"
|
|
'';
|
|
};
|
|
|
|
hardware.enableRedistributableFirmware = true;
|
|
|
|
environment.systemPackages =
|
|
(with pkgs; [
|
|
neovim
|
|
wget
|
|
kitty.terminfo
|
|
|
|
# Utilities
|
|
bcc
|
|
bottom
|
|
btop
|
|
cpuid
|
|
dig
|
|
git
|
|
htop
|
|
iftop
|
|
mtr
|
|
pciutils
|
|
pwru
|
|
tcpdump
|
|
])
|
|
++ [ config.boot.kernelPackages.perf ]
|
|
++ lib.optional (config.services.postgresql.enable && cfg.pg-upgrade-from != 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="${cfg.pg-upgrade-from}/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 \
|
|
"$@"
|
|
''
|
|
);
|
|
};
|
|
}
|