infrastructure/modules/nixos/dgn-console.nix
Tom Hubrecht 0455ca4175
All checks were successful
Check workflows / check_workflows (pull_request) Successful in 17s
Check meta / check_meta (pull_request) Successful in 18s
Check meta / check_dns (pull_request) Successful in 22s
Build all the nodes / Jaccess04 (pull_request) Successful in 25s
Build all the nodes / Jaccess01 (pull_request) Successful in 28s
Run pre-commit on all files / pre-commit (pull_request) Successful in 32s
Build all the nodes / ap01 (pull_request) Successful in 41s
Build all the nodes / bridge01 (pull_request) Successful in 50s
Build all the nodes / cof02 (pull_request) Successful in 57s
Build all the nodes / geo01 (pull_request) Successful in 55s
Build all the nodes / geo02 (pull_request) Successful in 54s
Build all the nodes / build01 (pull_request) Successful in 1m5s
Build all the nodes / hypervisor01 (pull_request) Successful in 50s
Build all the nodes / compute01 (pull_request) Successful in 1m19s
Build all the nodes / netcore01 (pull_request) Successful in 22s
Build all the nodes / hypervisor02 (pull_request) Successful in 50s
Build all the nodes / hypervisor03 (pull_request) Successful in 46s
Build all the nodes / netcore02 (pull_request) Successful in 24s
Build all the nodes / lab-router01 (pull_request) Successful in 52s
Build all the nodes / iso (pull_request) Successful in 1m1s
Build all the nodes / tower01 (pull_request) Successful in 50s
Build all the nodes / krz01 (pull_request) Successful in 1m41s
Build all the nodes / rescue01 (pull_request) Successful in 1m10s
Build all the nodes / vault01 (pull_request) Successful in 1m8s
Build all the nodes / web02 (pull_request) Successful in 53s
Build all the nodes / web01 (pull_request) Successful in 1m11s
Build the shell / build-shell (pull_request) Successful in 24s
Build all the nodes / web03 (pull_request) Successful in 54s
Build all the nodes / zulip01 (pull_request) Successful in 48s
Build all the nodes / storage01 (pull_request) Successful in 2m27s
Build all the nodes / Jaccess04 (push) Successful in 23s
Build all the nodes / Jaccess01 (push) Successful in 31s
Run pre-commit on all files / pre-commit (push) Successful in 32s
Build all the nodes / ap01 (push) Successful in 44s
Build all the nodes / bridge01 (push) Successful in 48s
Build all the nodes / hypervisor01 (push) Successful in 52s
Build all the nodes / geo01 (push) Successful in 53s
Build all the nodes / cof02 (push) Successful in 55s
Build all the nodes / hypervisor03 (push) Successful in 58s
Build all the nodes / hypervisor02 (push) Successful in 1m0s
Build all the nodes / geo02 (push) Successful in 1m2s
Build all the nodes / build01 (push) Successful in 1m2s
Build all the nodes / iso (push) Successful in 1m3s
Build all the nodes / netcore01 (push) Successful in 24s
Build all the nodes / netcore02 (push) Successful in 22s
Build all the nodes / compute01 (push) Successful in 1m20s
Build all the nodes / lab-router01 (push) Successful in 51s
Build the shell / build-shell (push) Successful in 24s
Build all the nodes / tower01 (push) Successful in 53s
Build all the nodes / web02 (push) Successful in 58s
Build all the nodes / vault01 (push) Successful in 1m2s
Build all the nodes / zulip01 (push) Successful in 58s
Build all the nodes / web03 (push) Successful in 1m7s
Build all the nodes / krz01 (push) Successful in 1m53s
Build all the nodes / rescue01 (push) Successful in 1m18s
Build all the nodes / web01 (push) Successful in 1m13s
Build all the nodes / storage01 (push) Successful in 2m2s
fix(dgn-console): Remove duplicate neovim
`programs.neovim` is already enabled
2025-06-13 10:41:25 +02:00

136 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; [
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 \
"$@"
''
);
};
}