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.

84 lines
1.8 KiB

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