nixos-config/terranix/space-left/config.nix

53 lines
1.4 KiB
Nix
Raw Normal View History

2021-02-14 20:24:19 +01:00
{ config, lib, pkgs, ... }:
let
hcloud-modules = pkgs.fetchgit {
url = "https://github.com/mrVanDalo/terranix-hcloud.git";
rev = "5fa359a482892cd973dcc6ecfc607f4709f24495";
sha256 = "0smgmdiklj98y71fmcdjsqjq8l41i66hs8msc7k4m9dpkphqk86p";
};
2021-11-01 19:30:41 +01:00
in
{
2021-02-14 20:24:19 +01:00
imports = [ "${hcloud-modules}/default.nix" ];
# configure temporary admin ssh keys
users.admins.palo.publicKey = "${lib.fileContents ./sshkey.pub}";
# configure provisioning private Key to be used when running provisioning on the machines
provisioner.privateKeyFile = toString ./sshkey;
hcloud.nixserver = {
host = {
enable = true;
2021-08-30 20:37:28 +02:00
serverType = "cx31";
2021-02-14 20:24:19 +01:00
configurationFile = pkgs.writeText "configuration.nix" ''
{ pkgs, lib, config, ... }:
{
environment.systemPackages = [ pkgs.git ];
}
'';
};
};
2021-08-30 20:37:28 +02:00
# todo : put this in the hcloud module
resource.hcloud_server.nixserver-host.location = "hel1";
2021-02-14 20:24:19 +01:00
hcloud.export.nix = toString ./plops/generated/nixos-machines.nix;
resource.local_file.sshConfig = {
filename = "${toString ./plops/generated/ssh-configuration}";
content = with lib;
let
configPart = name: ''
Host ''${ hcloud_server.nixserver-${name}.ipv4_address }
IdentityFile ${toString ./sshkey}
ServerAliveInterval 60
ServerAliveCountMax 3
'';
2021-11-01 19:30:41 +01:00
in
concatStringsSep "\n"
(map configPart (attrNames config.hcloud.nixserver));
2021-02-14 20:24:19 +01:00
};
}