Skip to content

Commit 7700799

Browse files
committed
setup secrets with sops-nix
primarily for use with tailscale and for the matrix server. i've also refactored the host to a "server" module.
1 parent 94bed03 commit 7700799

File tree

9 files changed

+272
-11
lines changed

9 files changed

+272
-11
lines changed

.sops.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
keys:
2+
- &user_rmu age1jekavujwuvcqd76tl06nq4um3gd0sgdek2y3xquh3xuqxkyucyxqyjturt
3+
- &server_uaq age19g4qp9033celgp5m8ffv35rlua2eved5pshqvnsw3kl3ya22k9vsmaungh
4+
creation_rules:
5+
- path_regex: secrets/[^/]+\.(yaml|json|env|ini)$
6+
key_groups:
7+
- age:
8+
- *user_rmu
9+
- *server_uaq

flake.lock

+181
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
flake.nixosConfigurations.uaq = nixpkgs.lib.nixosSystem {
1212
system = "x86_64-linux";
1313
specialArgs = {inherit inputs self;};
14-
modules = [./hosts/uaq ./users/rmu.nix];
14+
modules = [./hosts/uaq];
1515
};
1616

1717
flake.nixosModules = {
18+
server = ./modules/server;
19+
1820
roles-matrix-bridge = ./modules/roles/matrix-bridge.nix;
1921
roles-matrix-homeserver = ./modules/roles/matrix-homeserver.nix;
2022
};
@@ -28,5 +30,7 @@
2830

2931
disko.url = "github:nix-community/disko";
3032
srvos.url = "github:nix-community/srvos/63ea710b10c88f2158251d49eec7cc286cefbd68";
33+
34+
sops-nix.url = "github:Mic92/sops-nix";
3135
};
3236
}

hosts/uaq/default.nix

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@
22
lib,
33
self,
44
config,
5-
inputs,
65
...
76
}: {
8-
time.timeZone = "Asia/Dubai";
9-
networking.hostName = "uaq";
10-
117
imports = [
12-
inputs.srvos.nixosModules.server
13-
14-
inputs.srvos.nixosModules.mixins-terminfo
15-
inputs.srvos.nixosModules.mixins-systemd-boot
8+
self.nixosModules.server
169

1710
# self.nixosModules.roles-matrix-bridge
1811
# self.nixosModules.roles-matrix-homeserver
1912
];
2013

14+
time.timeZone = "Asia/Dubai";
15+
16+
networking.hostName = "uaq";
2117
networking.useNetworkd = true;
2218
networking.useDHCP = false;
2319

modules/secrets.nix

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{inputs, ...}: {
2+
imports = [inputs.sops-nix.nixosModules.sops];
3+
4+
sops = {
5+
defaultSopsFile = ../secrets/server.yaml;
6+
age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"];
7+
secrets."tailscale/authKey" = {};
8+
};
9+
10+
services.tailscale.authKeyFile = "/run/secrets/tailscale/authKey";
11+
}

modules/server/default.nix

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
inputs,
3+
lib,
4+
...
5+
}: {
6+
imports = [
7+
../secrets.nix
8+
9+
../../users/rmu.nix
10+
../../users/shaher.nix
11+
../../users/gaurav.nix
12+
13+
inputs.srvos.nixosModules.server
14+
15+
inputs.srvos.nixosModules.mixins-terminfo
16+
inputs.srvos.nixosModules.mixins-systemd-boot
17+
];
18+
19+
programs.fish.enable = true;
20+
21+
services.openssh.settings = {
22+
MaxSessions = lib.mkDefault 4;
23+
PasswordAuthentication = false;
24+
};
25+
26+
services.tailscale.enable = true;
27+
services.tailscale.extraUpFlags = ["--ssh"];
28+
}

secrets/server.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
tailscale:
2+
authKey: ENC[AES256_GCM,data:UqYlhwxGqPqHWespWKEV+JVrP+tn0pAJ2Klj/3hemtEqZ0ANIJE/t6WsSFLKfthbyTQjurI48/vXExx+BBQ=,iv:MAR7Mk5XjFlswRfFWs+2USo7g2WcOWsLxPUVdpUzyag=,tag:gJjS8R5SB4jIGe6ygcv2Vw==,type:str]
3+
sops:
4+
kms: []
5+
gcp_kms: []
6+
azure_kv: []
7+
hc_vault: []
8+
age:
9+
- recipient: age1jekavujwuvcqd76tl06nq4um3gd0sgdek2y3xquh3xuqxkyucyxqyjturt
10+
enc: |
11+
-----BEGIN AGE ENCRYPTED FILE-----
12+
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBiVzQzdzh3aWVWYXBqazJI
13+
LzgxTTYzbjdkWWxvYTBKTXY3a21FYk04SlQ4CjkvOXI2QmtWSTN1aWwyRXNkbGpt
14+
VjdyYnM2K0d3SU9XalpwdG5aNGl4VDgKLS0tIEt5bGllM3ArbzlmSzVxaW5IZ2dm
15+
emZWNHlPZ3BDMElMekVoajV1MTBFdE0KkXAa2Yfy4rFvvlrM92H9OVwOCjw2FfQH
16+
Ku2tIUokxRgFKMu+CC2ICP9izxN+cffXLRqWECpCyv3Z6monDY2ZGg==
17+
-----END AGE ENCRYPTED FILE-----
18+
- recipient: age19g4qp9033celgp5m8ffv35rlua2eved5pshqvnsw3kl3ya22k9vsmaungh
19+
enc: |
20+
-----BEGIN AGE ENCRYPTED FILE-----
21+
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBxTmhMRFd4LzdsY2RPazBx
22+
QU5XU0ZQalArQllLSFI2czZCeTFJTkxHTFFZCmxRdmJla3cvZVdEVm0wOGd2eHVR
23+
YzlJd3c5VVJ4OUZLaFhaeEJQWm9TOVUKLS0tIHdVUXJQcThKai9ncDBsKzZFdHFZ
24+
d0hBMEVrWExwdFB3dUZjSm5YUDJzU1kKVGKKYyG3h2FQuU7K74+O7q0WlzIl1vAF
25+
pir2NWOKR8C1FG1czAR2nytPH/bgndp1aL+7vGNg6Z+QEIlsY2WYEQ==
26+
-----END AGE ENCRYPTED FILE-----
27+
lastmodified: "2024-09-25T09:59:04Z"
28+
mac: ENC[AES256_GCM,data:/uejUEt4so86IWJuC2JHF3cVE9shFRgTMUzvg8+/DYGHPloOa43x3DOvnyafZ081hOYnBN0sXz5fPu+vn6F3em1ptMIF+K1TsazmTfO1DSaNtsfCr72HFBIEBPrMsybYvOPk4vTbn+SGLCfJLvzpYqt5KhIRwsSxdiZiK9hB/0Q=,iv:k2MJSiX45to3H51ZClJYfEV/Ms9pr3Tgll0gAMkw5z0=,tag:lCJKchBIrjlo/xCArUjiwQ==,type:str]
29+
pgp: []
30+
unencrypted_suffix: _unencrypted
31+
version: 3.9.0

users/default.nix

-1
This file was deleted.

users/rmu.nix

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
{
1+
{pkgs, ...}: {
22
users.users.rmu = {
33
isNormalUser = true;
44
description = "Rashid Almheiri";
55
extraGroups = ["wheel"];
66

7+
shell = pkgs.fish;
8+
79
openssh.authorizedKeys.keys = [
810
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEIniejxbTn4cW/0iTk2eLin7ZTQfpCIP3hiNP318kS8 uaq"
911
];

0 commit comments

Comments
 (0)