feat(deploy): first integration of krops

This commit is contained in:
mrflos 2024-09-18 11:29:27 +03:00
parent fc5c9a04ec
commit 255805947e
6 changed files with 61 additions and 59 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
.DS_Store
deploy/result
configuration.nix configuration.nix
darwin-configuration.nix darwin-configuration.nix

57
deploy/krops.nix Normal file
View file

@ -0,0 +1,57 @@
let
krops = builtins.fetchGit {
url = "https://cgit.krebsco.de/krops/";
};
lib = import "${krops}/lib";
pkgs = import "${krops}/pkgs" {};
source = name: lib.evalSource [
{
dotfiles.file = toString ../dotfiles;
machines.file = toString ../machines;
modules.file = toString ../modules;
nixos-config.symlink = "machines/${name}/configuration.nix";
nixpkgs.git = {
clean.exclude = ["/.version-suffix"];
ref = "086b448a5d54fd117f4dc2dee55c9f0ff461bdc1";
url = https://github.com/NixOS/nixpkgs;
shallow = true;
};
#secrets.pass = {
# dir = toString ./secrets";
# name = "${name}";
#};
}
];
zoro = pkgs.krops.writeDeploy "deploy-zoro" {
source = source "zoro";
target = lib.mkTarget "optisseur@10.42.0.3:4222" // {
extraOptions = [
#"-o"
#"ControlMaster=auto"
#"-o"
#"ControlPath=~/.ssh/master-%r@%h:%p"
#"-o"
#"ControlPersist=480m"
];
sudo = true;
};
};
sanji = pkgs.krops.writeDeploy "deploy-sanji" {
source = source "sanji";
target = "root@server02.mydomain.org";
};
in {
zoro = zoro;
sanji = sanji;
all = pkgs.writeScript "deploy-all-servers"
(lib.concatStringsSep "\n" [ zoro sanji ]);
}
# ssh-add -t 4h ~/.ssh/id_ed25519
# nix-build ./krops.nix -A zoro && ./result
# nix-build ./krops.nix -A sanji && ./result
# nix-build ./krops.nix -A all && ./result

View file

@ -1,59 +0,0 @@
{ config, lib, pkgs, ... }:
{
imports = [
./ThinkCentre-M710q-zoro-hardware-configuration.nix
../modules/minimal-server.nix
];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking = {
hostName = "zoro";
domain = "mrflos.pw";
nameservers = ["80.67.169.12" "2001:910:800::12" "80.67.169.40" "2001:910:800::40"];
wg-quick.interfaces = {
wg0 = {
address = [ "10.42.0.3/32"];
privateKeyFile = "/etc/wireguard_private_key";
peers = [
{
publicKey = "2MZzEGJzA3HrwkHf91TaKJEHwCNyVvsTLWoIYHrCxhY=";
presharedKeyFile = "/etc/wireguard_preshared_key";
allowedIPs = [ "10.42.0.0/24" ];
endpoint = "195.201.63.240:8098";
persistentKeepalive = 15;
}
];
};
};
};
time.timeZone = "Europe/Moscow";
i18n.defaultLocale = "en_US.UTF-8";
users.users.optisseur = {
isNormalUser = true;
extraGroups = [ "wheel" ];
initialPassword = "ACHANGER";
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBBM+2TwkopAQF7splTWjORQoxjcp67VhodwzvTMlL8g florian@florian-LinuxMint-MBP"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRG0CyeeMMrrjTTm/PHgRXD/I4lH/bBPBCGUiL+cBdq douzeb@tux-12"
];
};
services.openssh.enable = true;
services.openssh.ports = [ 4222 ];
services.openssh.settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
};
networking.firewall.allowedTCPPorts = [ 80 443 4222 ];
system.stateVersion = "24.05";
}

View file

@ -49,6 +49,7 @@ in
htop htop
lazygit lazygit
lsd lsd
magic-wormhole
mc mc
micro micro
mosh mosh

View file

@ -21,6 +21,7 @@
htop htop
lazygit lazygit
lsd lsd
magic-wormhole
mc mc
micro micro
mosh mosh