NixOS configuration for HPC cluster https://docs.hpc.informatik.hs-fulda.de/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.8 KiB

  1. { pkgs, lib, config, modulesPath, nodes, ... }:
  2. with lib;
  3. let
  4. manager = nodes."manager".config;
  5. auto-install = pkgs.writers.writeBash "auto-install" ''
  6. set -o errexit
  7. set -o nounset
  8. set -o pipefail
  9. set -x
  10. if [[ "$(cat /proc/cmdline)" =~ nixos\.install=([^ ]+) ]]; then
  11. INSTALL="''${BASH_REMATCH[1]}"
  12. else
  13. echo "No install derivation found" >&2
  14. exit 1
  15. fi
  16. ${pkgs.retry}/bin/retry \
  17. --times 10 \
  18. --delay 15 \
  19. -- ${pkgs.nix}/bin/nix-store \
  20. --realize \
  21. --add-root /tmp/install \
  22. "$INSTALL"
  23. exec /tmp/install
  24. '';
  25. in
  26. {
  27. imports = [
  28. "${modulesPath}/installer/netboot/netboot-minimal.nix"
  29. ../../../modules
  30. ];
  31. config = {
  32. services.getty.autologinUser = lib.mkForce "root";
  33. networking.hostName = "installer";
  34. users.users."root" = {
  35. openssh.authorizedKeys.keys = manager.users.users."root".openssh.authorizedKeys.keys;
  36. };
  37. systemd.services."auto-install" = {
  38. description = "Automated NixOS installer";
  39. wants = [ "network-online.target" ];
  40. after = [ "network-online.target" ];
  41. conflicts = [ "getty@tty1.service" ];
  42. wantedBy = [ "multi-user.target" ];
  43. path = [ pkgs.bash pkgs.nix ];
  44. unitConfig = {
  45. AssertKernelCommandLine = "nixos.install";
  46. FailureAction = "reboot-force";
  47. };
  48. serviceConfig = {
  49. Type = "oneshot";
  50. ExecStart = auto-install;
  51. StandardInput = "none";
  52. StandardOutput = "journal+console";
  53. StandardError = "journal+console";
  54. };
  55. };
  56. nix.settings = {
  57. substituters = [
  58. "http://cache.${manager.networking.domain}"
  59. ];
  60. trusted-public-keys = [
  61. (fileContents manager.gather.parts."cache/key".path)
  62. ];
  63. };
  64. system.stateVersion = config.system.nixos.release;
  65. };
  66. }