Tom Hubrecht
88d9b8c3e3
Some checks failed
Check meta / check_dns (pull_request) Successful in 19s
Check meta / check_meta (pull_request) Successful in 20s
Check workflows / check_workflows (pull_request) Successful in 24s
Build all the nodes / ap01 (pull_request) Successful in 1m15s
Build all the nodes / bridge01 (pull_request) Successful in 1m53s
Build all the nodes / geo01 (pull_request) Successful in 1m55s
Build all the nodes / geo02 (pull_request) Successful in 1m53s
Build all the nodes / compute01 (pull_request) Successful in 2m33s
Build all the nodes / rescue01 (pull_request) Successful in 2m13s
Build all the nodes / storage01 (pull_request) Successful in 1m57s
Run pre-commit on all files / check (pull_request) Successful in 30s
Build all the nodes / web02 (pull_request) Successful in 1m47s
Build all the nodes / vault01 (pull_request) Successful in 2m21s
Build all the nodes / web03 (pull_request) Successful in 1m40s
Build all the nodes / web01 (pull_request) Successful in 2m54s
Check meta / check_dns (push) Successful in 20s
Check meta / check_meta (push) Successful in 19s
Check workflows / check_workflows (push) Successful in 25s
Build all the nodes / ap01 (push) Successful in 1m16s
Build all the nodes / bridge01 (push) Successful in 1m41s
Build all the nodes / geo02 (push) Successful in 1m44s
Build all the nodes / geo01 (push) Successful in 1m53s
Build all the nodes / compute01 (push) Successful in 2m20s
Build all the nodes / rescue01 (push) Successful in 1m49s
Build all the nodes / storage01 (push) Successful in 1m46s
Build all the nodes / vault01 (push) Successful in 1m45s
Run pre-commit on all files / check (push) Successful in 30s
Build all the nodes / web02 (push) Has been cancelled
Build all the nodes / web01 (push) Has been cancelled
Build all the nodes / web03 (push) Has been cancelled
Signed-off-by: Tom Hubrecht <tom.hubrecht@dgnum.eu> Acked-by: Ryan Lahfa <ryan.lahfa@dgnum.eu> Acked-by: Maurice Debray <maurice.debray@dgnum.eu> Acked-by: Lubin Bailly <lubin.bailly@dgnum.eu> Acked-by: Jean-Marc Gailis <jean-marc.gailis@dgnum.eu> as the legal authority, at the time of writing, in DGNum. Acked-by: Elias Coppens <elias.coppens@dgnum.eu> as a member, at the time of writing, of the DGNum executive counsel.
153 lines
2.8 KiB
Bash
153 lines
2.8 KiB
Bash
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
|
|
#
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
bootDevice=
|
|
rootDevice=
|
|
|
|
domain="par01.infra.dgnum.eu"
|
|
hostname="dgn0x"
|
|
|
|
hasZFS=
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
i="$1"
|
|
shift 1
|
|
case "$i" in
|
|
--root)
|
|
rootDevice="$1"
|
|
shift 1
|
|
;;
|
|
--boot)
|
|
bootDevice="$1"
|
|
shift 1
|
|
;;
|
|
--swap)
|
|
swapDevice="$1"
|
|
shift 1
|
|
;;
|
|
--domain)
|
|
domain="$1"
|
|
shift 1
|
|
;;
|
|
--hostname)
|
|
hostname="$1"
|
|
shift 1
|
|
;;
|
|
--with-zfs)
|
|
hasZFS="1"
|
|
;;
|
|
*)
|
|
echo "$0: unknown option \`$i'"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ -z "$bootDevice" ]; then
|
|
echo "Missing boot partition"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$rootDevice" ]; then
|
|
echo "Missing root partition"
|
|
exit 1
|
|
fi
|
|
|
|
# Mount the partitions to where they should be
|
|
mount "$rootDevice" /mnt
|
|
mkdir /mnt/boot
|
|
|
|
mount "$bootDevice" /mnt/boot
|
|
|
|
if [ -n "$swapDevice" ]; then
|
|
swapon "$swapDevice"
|
|
fi
|
|
|
|
# Generate configration
|
|
nixos-generate-config --root /mnt
|
|
|
|
NIX="/mnt/etc/nixos/"
|
|
|
|
# Setup our own files
|
|
mv $NIX/configuration.nix $NIX/base-configuration.nix
|
|
|
|
cat <<EOF > $NIX/dgnum-server.nix
|
|
{ ... }: {
|
|
services.nscd.enableNsncd = false;
|
|
programs.bash.promptInit = ''
|
|
# 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@\$(hostname -f):\w]\\\$\[\033[0m\] "
|
|
else
|
|
PS1="\n\[\033[\$PROMPT_COLOR\][\[\e]0;\u@\H: \w\a\]\u@\$(hostname -f):\w]\\\$\[\033[0m\] "
|
|
fi
|
|
if test "\$TERM" = "xterm"; then
|
|
PS1="\[\033]2;\$(hostname -f):\u:\w\007\]\$PS1"
|
|
fi
|
|
fi
|
|
'';
|
|
}
|
|
EOF
|
|
|
|
cat <<EOF > $NIX/configuration.nix
|
|
{ pkgs, ... }: {
|
|
imports = [
|
|
./base-configuration.nix
|
|
./dgnum-server.nix
|
|
$(if [ -n "$hasZFS" ]; then echo './zfs.nix'; fi)
|
|
];
|
|
|
|
boot.tmp.cleanOnBoot = true;
|
|
|
|
console.keyMap = "fr";
|
|
|
|
time.timeZone = "Europe/Paris";
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
vim
|
|
wget
|
|
kitty.terminfo
|
|
];
|
|
|
|
networking = {
|
|
hostName = "$hostname";
|
|
domain = "$domain";
|
|
};
|
|
|
|
# Activate SSH and set the keys
|
|
services.openssh = {
|
|
enable = true;
|
|
|
|
settings.PasswordAuthentication = false;
|
|
};
|
|
|
|
users.users.root.openssh.authorizedKeys.keyFiles = [ ./rootKeys ];
|
|
}
|
|
EOF
|
|
|
|
if [ -n "$hasZFS" ]; then
|
|
cat <<EOF > $NIX/zfs.nix
|
|
{ ... }: {
|
|
boot = {
|
|
supportedFilesystems = [ "zfs" ];
|
|
zfs.forceImportRoot = false;
|
|
zfs.extraPools = [
|
|
$(zpool list -Ho name | sed 's/^/"/;s/$/"/')
|
|
];
|
|
};
|
|
|
|
networking.hostId = "$(head -c4 /dev/urandom | od -A none -t x4 | sed 's/ //')";
|
|
}
|
|
EOF
|
|
fi
|
|
|
|
# Copy the keys
|
|
cp /etc/ssh/authorized_keys.d/root $NIX/rootKeys
|
|
|
|
# Perform the installation
|
|
nixos-install
|