Skip to content

Commit

Permalink
add gcp generator
Browse files Browse the repository at this point in the history
  • Loading branch information
zbioe committed Aug 9, 2022
1 parent 841d8cd commit 5b28bd6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 38 deletions.
6 changes: 5 additions & 1 deletion deploys/consul/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ in {
wantedBy = [ "consul.service" ];
path = "/etc/consul.d/encryption.hcl";
script = ''
if !systemctl is-active -q consul; then echo consul is down && exit 0; fi
NEW_KEY=$(cut -f2 -d\" </etc/consul.d/gossip.hcl | sed -e '/^$/d')
consul keyring -install "$NEW_KEY"
consul keyring -use "$NEW_KEY"
Expand All @@ -158,7 +159,10 @@ in {
'';
};
pki = rec {
script = "consul reload";
script = ''
if !systemctl is-active -q consul; then echo consul is down && exit 0; fi
consul reload
'';
wantedBy = [ "consul.service" ];
templates = let
mkTmpl = field: ''
Expand Down
1 change: 1 addition & 0 deletions env/local/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
38 changes: 38 additions & 0 deletions generators/minimal-default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{ modulesPath, ... }:
let
ssh-keys = import ./ssh-keys.nix;
username = "main";
password = "alface";
in {
# Enable the OpenSSH daemon
services.openssh.enable = true;
services.openssh.passwordAuthentication = false;
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};

boot.loader.grub.enable = true;
boot.loader.timeout = 0;
boot.loader.grub.devices = [ "/dev/sda" ];

users = {
mutableUsers = false;
users = {
root = {
openssh.authorizedKeys.keys = ssh-keys;
initialPassword = password;
};
${username} = {
isNormalUser = true;
home = "/home/${username}";
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = ssh-keys;
initialPassword = password;
};
};
};
security.sudo.wheelNeedsPassword = false;
nix.settings.trusted-users = [ "@wheel" ];
system.stateVersion = "22.11";
}
7 changes: 7 additions & 0 deletions generators/minimal-gcp.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ modulesPath, ... }:
{
imports = [
"${modulesPath}/profiles/minimal.nix"
"${modulesPath}/virtualisation/google-compute-config.nix"
];
} // (import ./minimal-default.nix { inherit modulesPath; })
39 changes: 2 additions & 37 deletions generators/minimal-libvirt.nix
Original file line number Diff line number Diff line change
@@ -1,42 +1,7 @@
{ modulesPath, ... }:
let
ssh-keys = import ./ssh-keys.nix;
username = "main";
password = "alface";
in {
{
imports = [
"${modulesPath}/profiles/minimal.nix"
"${modulesPath}/virtualisation/libvirtd.nix"
];
# Enable the OpenSSH daemon
services.openssh.enable = true;
services.openssh.passwordAuthentication = false;
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};

boot.loader.grub.enable = true;
boot.loader.timeout = 0;
boot.loader.grub.devices = [ "/dev/sda" ];

users = {
mutableUsers = false;
users = {
root = {
openssh.authorizedKeys.keys = ssh-keys;
initialPassword = password;
};
${username} = {
isNormalUser = true;
home = "/home/${username}";
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = ssh-keys;
initialPassword = password;
};
};
};
security.sudo.wheelNeedsPassword = false;
nix.settings.trusted-users = [ "@wheel" ];
system.stateVersion = "22.11";
}
} // (import ./minimal-default.nix { inherit modulesPath; })

0 comments on commit 5b28bd6

Please sign in to comment.