Skip to content

Commit

Permalink
mistral: ms-sql-server
Browse files Browse the repository at this point in the history
  • Loading branch information
moni-dz committed Sep 8, 2024
1 parent 030848b commit c59e40f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 10 deletions.
10 changes: 10 additions & 0 deletions hosts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
server = true;

modules = [
inputs.agenix.nixosModules.default

{
age.secrets.ms-sql-server = {
file = ../secrets/ms-sql-server.age;
owner = "moni";
mode = "0444";
};
}

inputs.nix-minecraft.nixosModules.minecraft-servers
./mistral/configuration.nix
];
Expand Down
39 changes: 37 additions & 2 deletions hosts/mistral/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
inputs,
modulesPath,
config,
lib,
pkgs,
...
Expand Down Expand Up @@ -30,8 +31,12 @@
programs.fish.enable = true;

networking.firewall = {
allowedTCPPorts = [ 4747 ];
allowedUDPPorts = [ 4747 ];
allowedTCPPorts = [
1433
4747
];

interfaces.podman1.allowedUDPPorts = [ 53 ];
};

services = {
Expand Down Expand Up @@ -189,10 +194,40 @@
};
};

systemd.services.create-podman-network = with config.virtualisation.oci-containers; {
serviceConfig.Type = "oneshot";
wantedBy = [ "${backend}-ms-sql-server.service" ];

script = ''
${lib.getExe pkgs.podman} network exists db-net || ${lib.getExe pkgs.podman} network create db-net
'';
};

users.users.moni = {
isNormalUser = true;
home = "/home/moni";
shell = pkgs.fish;
extraGroups = [ "wheel" ];
};

virtualisation = {
podman.enable = true;

oci-containers = {
backend = "podman";

containers.ms-sql-server = {
image = "mcr.microsoft.com/mssql/server:2022-latest";
autoStart = true;
ports = [ "1433:1433" ];

environment = {
ACCEPT_EULA = "Y";
MSSQL_SA_PASSWORD = __readFile config.age.secrets.ms-sql-server.path; # yes, this is bad but I don't have much choice...
};

extraOptions = [ "--network=db-net" ];
};
};
};
}
8 changes: 4 additions & 4 deletions hosts/starcruiser/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@
# $ sudo smbpasswd -a yourusername

# This adds to the [global] section:
extraConfig = ''
browseable = yes
smb encrypt = required
'';
settings."global" = {
browseable = "yes";
"smb encrypt" = "required";
};

shares = {
homes = {
Expand Down
11 changes: 11 additions & 0 deletions secrets/ms-sql-server.age
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
age-encryption.org/v1
-> ssh-ed25519 KAuKJQ S+5Cj+apibo8urg+BwImZ7bMuiBTcCbU2vwvfiuTKRc
17qaL3XbwmwOEsLyLczHUbqfp+bUCCFXFdgtVHjnLAg
-> ssh-ed25519 OasC+A V0wHZeDlGzNTmY+iZGIFCV5K+X+mi8ZxKkRpMfXFjxM
k6J55lXiYpHcyHQ43T/KmRfvzY6zIRSTqO6nQ0hod7E
-> ssh-ed25519 KAuKJQ fgPfr0ybokgSxQeSdg7NHpyUeWWKAPd+6qgKbn5dBgM
o7Mgc3RFaZ+nZd5HOY/FbPvr6+dCEcZ00kYJsg5vZOY
-> ssh-ed25519 fKg5bA DGsDYH+PY/kIE1P83uM/OratFSgBKg2owSccnxFdpl8
SiGp65d0h1Hz9M5FshGSKiDcW9aEKbT0yuSv6LIBen8
--- R0a2WytYTgh3SKesag1I1FSa2vhdVgdP8pzusQG8f00
T���)Z�Agϟ�_����[���q���Q����<�+h�4K
10 changes: 6 additions & 4 deletions secrets/secrets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ let
zero = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOf7dkQDloUFN1Hxn/yWrcqMaJiH/jsXUGAAtL9l92xQ";
starcruiser = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKrPdqIiTrGqnN6eAhRuGl9ZV2sUz/IR85T3/TzUT4Ol";
riscake = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEeZg4xxANKadIm8hnhM/rQrl77Xwwp0tFRnnANtFgI3";
mistral = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFDRGyDQlHPogYIt0IIwI+/1D+U3qbOHOZOyPsAN2NWt";

users = [
moni.linux
moni.darwin
zero
];
hosts = [
in
{
"tokens.age".publicKeys = users ++ [
starcruiser
riscake
];
in
{
"tokens.age".publicKeys = users ++ hosts;

"ms-sql-server.age".publicKeys = users ++ [ mistral ];
}

0 comments on commit c59e40f

Please sign in to comment.