2024-08-12 22:02:31 +03:00
|
|
|
{
|
2024-10-01 14:36:41 +03:00
|
|
|
lib,
|
2024-08-12 22:02:31 +03:00
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
myData,
|
|
|
|
...
|
|
|
|
}:
|
2024-07-29 15:39:54 +03:00
|
|
|
let
|
2024-03-12 13:44:40 +02:00
|
|
|
nvme = "/dev/disk/by-id/nvme-WD_PC_SN810_SDCQNRY-1T00-1201_23234W800017";
|
2024-07-29 15:39:54 +03:00
|
|
|
in
|
|
|
|
{
|
2024-03-12 21:26:31 +02:00
|
|
|
imports = [
|
2024-03-13 10:01:09 +02:00
|
|
|
../../shared/work
|
2024-03-12 21:26:31 +02:00
|
|
|
../../modules
|
|
|
|
../../modules/profiles/desktop
|
2024-04-12 16:37:06 +03:00
|
|
|
../../modules/profiles/autorandr
|
2024-05-06 05:55:27 +03:00
|
|
|
../../modules/profiles/btrfs
|
2024-03-12 21:26:31 +02:00
|
|
|
];
|
|
|
|
|
2024-08-27 08:50:57 +03:00
|
|
|
age.secrets = {
|
2024-08-27 08:57:17 +03:00
|
|
|
motiejus-work-passwd-hash.file = ../../secrets/motiejus_work_passwd_hash.age;
|
|
|
|
root-work-passwd-hash.file = ../../secrets/root_work_passwd_hash.age;
|
|
|
|
sasl-passwd.file = ../../secrets/postfix_sasl_passwd.age;
|
2024-08-27 08:50:57 +03:00
|
|
|
|
2024-08-27 08:57:17 +03:00
|
|
|
syncthing-key.file = ../../secrets/mtworx/syncthing/key.pem.age;
|
|
|
|
syncthing-cert.file = ../../secrets/mtworx/syncthing/cert.pem.age;
|
2024-08-27 08:50:57 +03:00
|
|
|
|
|
|
|
ssh8022-client = {
|
|
|
|
file = ../../secrets/ssh8022.age;
|
|
|
|
mode = "444";
|
|
|
|
};
|
2024-08-25 11:07:35 +03:00
|
|
|
};
|
|
|
|
|
2024-03-12 21:26:31 +02:00
|
|
|
boot = {
|
2024-07-29 15:39:54 +03:00
|
|
|
kernelModules = [ "kvm-intel" ];
|
2024-03-12 21:26:31 +02:00
|
|
|
loader.systemd-boot.enable = true;
|
2024-08-16 12:23:32 +03:00
|
|
|
|
|
|
|
# 6.10+ to fix audio. Thanks https://github.com/ilian/cfg/blob/4588b90e674827304cd8e0b9d1aecd75416d1cde/hosts/carbon/configuration.nix#L19
|
|
|
|
kernelPackages = pkgs.linuxPackages_6_10;
|
|
|
|
|
2024-03-12 21:26:31 +02:00
|
|
|
initrd = {
|
2024-07-29 15:39:54 +03:00
|
|
|
availableKernelModules = [
|
|
|
|
"xhci_pci"
|
|
|
|
"thunderbolt"
|
|
|
|
"nvme"
|
|
|
|
"usbhid"
|
|
|
|
"tpm_tis"
|
|
|
|
];
|
2024-07-16 05:25:09 +03:00
|
|
|
systemd = {
|
|
|
|
enableTpm2 = true;
|
|
|
|
emergencyAccess = true;
|
|
|
|
};
|
2024-03-12 21:26:31 +02:00
|
|
|
luks.devices = {
|
|
|
|
luksroot = {
|
|
|
|
device = "${nvme}-part3";
|
|
|
|
allowDiscards = true;
|
2024-07-29 15:39:54 +03:00
|
|
|
crypttabExtraOpts = [ "tpm2-device=auto" ];
|
2024-03-12 21:26:31 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
swapDevices = [
|
|
|
|
{
|
|
|
|
device = "${nvme}-part2";
|
|
|
|
randomEncryption.enable = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
fileSystems = {
|
|
|
|
"/" = {
|
|
|
|
device = "/dev/mapper/luksroot";
|
2024-03-13 15:28:35 +02:00
|
|
|
fsType = "btrfs";
|
2024-07-29 15:39:54 +03:00
|
|
|
options = [ "compress=zstd" ];
|
2024-03-12 21:26:31 +02:00
|
|
|
};
|
|
|
|
"/boot" = {
|
|
|
|
device = "${nvme}-part1";
|
2024-03-12 21:36:08 +02:00
|
|
|
fsType = "vfat";
|
2024-03-12 21:26:31 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
hardware.cpu.intel.updateMicrocode = true;
|
|
|
|
nixpkgs.hostPlatform = "x86_64-linux";
|
|
|
|
|
|
|
|
mj = {
|
|
|
|
stateVersion = "23.11";
|
2024-05-20 05:40:43 +03:00
|
|
|
timeZone = "Europe/Vilnius";
|
2024-03-12 21:26:31 +02:00
|
|
|
username = "motiejus";
|
|
|
|
|
|
|
|
base.users = {
|
|
|
|
enable = true;
|
2024-03-12 16:03:50 +02:00
|
|
|
devTools = true;
|
2024-03-18 17:46:17 +02:00
|
|
|
root.hashedPasswordFile = config.age.secrets.root-work-passwd-hash.path;
|
|
|
|
user.hashedPasswordFile = config.age.secrets.motiejus-work-passwd-hash.path;
|
2024-03-12 21:26:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
2024-08-25 11:07:35 +03:00
|
|
|
ssh8022.client = {
|
|
|
|
enable = true;
|
|
|
|
keyfile = config.age.secrets.ssh8022-client.path;
|
|
|
|
};
|
2024-08-24 22:00:37 +03:00
|
|
|
|
2024-03-12 21:26:31 +02:00
|
|
|
tailscale = {
|
|
|
|
enable = true;
|
|
|
|
verboseLogs = true;
|
|
|
|
};
|
|
|
|
|
2024-07-29 16:11:01 +03:00
|
|
|
btrfssnapshot = {
|
|
|
|
enable = true;
|
2024-07-29 16:31:32 +03:00
|
|
|
subvolumes = [
|
|
|
|
{
|
|
|
|
subvolume = "/home";
|
2024-07-29 16:11:01 +03:00
|
|
|
label = "5minutely";
|
|
|
|
keep = 12;
|
|
|
|
refreshInterval = "*:0/5";
|
2024-07-29 16:31:32 +03:00
|
|
|
}
|
|
|
|
{
|
|
|
|
subvolume = "/home";
|
|
|
|
label = "hourly";
|
|
|
|
keep = 24;
|
|
|
|
refreshInterval = "*:00:00";
|
|
|
|
}
|
2024-08-12 21:21:07 +03:00
|
|
|
{
|
|
|
|
subvolume = "/home";
|
|
|
|
label = "daily";
|
|
|
|
keep = 7;
|
|
|
|
refreshInterval = "daily UTC";
|
|
|
|
}
|
2024-07-29 16:31:32 +03:00
|
|
|
];
|
2024-07-29 16:11:01 +03:00
|
|
|
};
|
|
|
|
|
2024-06-06 02:06:46 +03:00
|
|
|
wifibackup = {
|
|
|
|
enable = true;
|
2024-06-06 02:22:30 +03:00
|
|
|
toPath = "/home/${config.mj.username}/M-Active/.wifi";
|
2024-06-06 02:06:46 +03:00
|
|
|
toUser = config.mj.username;
|
|
|
|
};
|
|
|
|
|
2024-07-29 15:39:54 +03:00
|
|
|
remote-builder.client =
|
|
|
|
let
|
2024-07-31 00:23:44 +03:00
|
|
|
host = myData.hosts."fra1-b.servers.jakst";
|
2024-07-29 15:39:54 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
enable = true;
|
|
|
|
inherit (host) system supportedFeatures;
|
|
|
|
hostName = host.jakstIP;
|
|
|
|
sshKey = "/etc/ssh/ssh_host_ed25519_key";
|
2024-07-31 01:06:24 +03:00
|
|
|
maxJobs = 2;
|
2024-07-29 15:39:54 +03:00
|
|
|
};
|
2024-06-07 23:45:30 +03:00
|
|
|
|
2024-03-12 21:26:31 +02:00
|
|
|
node_exporter = {
|
|
|
|
enable = true;
|
2024-07-29 15:39:54 +03:00
|
|
|
extraSubnets = [ myData.subnets.vno1.cidr ];
|
2024-03-12 21:26:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
deployerbot = {
|
|
|
|
follower = {
|
2024-07-31 09:19:13 +03:00
|
|
|
publicKeys = [ myData.hosts."fwminex.servers.jakst".publicKey ];
|
2024-03-12 21:26:31 +02:00
|
|
|
|
|
|
|
enable = true;
|
|
|
|
uidgid = myData.uidgid.updaterbot-deployee;
|
2024-07-29 15:39:54 +03:00
|
|
|
sshAllowSubnets = with myData.subnets; [ tailscale.sshPattern ];
|
2024-03-12 21:26:31 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-05 16:41:24 +03:00
|
|
|
postfix = {
|
2024-08-05 19:04:46 +03:00
|
|
|
enable = false;
|
|
|
|
#saslPasswdPath = config.age.secrets.sasl-passwd.path;
|
2024-08-05 16:41:24 +03:00
|
|
|
};
|
2024-03-12 21:26:31 +02:00
|
|
|
|
|
|
|
syncthing = {
|
|
|
|
enable = true;
|
|
|
|
dataDir = "/home/motiejus/";
|
|
|
|
user = "motiejus";
|
|
|
|
group = "users";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-01 14:36:41 +03:00
|
|
|
users = {
|
|
|
|
users.mount-test = {
|
|
|
|
name = "mount-test";
|
|
|
|
group = "mount-test";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
groups.mount-test = { };
|
|
|
|
};
|
|
|
|
|
2024-10-01 15:52:20 +03:00
|
|
|
systemd.tmpfiles.rules = [ "d /data 0755 root root -" ];
|
|
|
|
|
2024-10-01 14:36:41 +03:00
|
|
|
systemd.services.mount-test = {
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
RuntimeDirectory = "mount-test";
|
2024-10-01 15:52:20 +03:00
|
|
|
TemporaryFileSystem = "/data";
|
|
|
|
BindPaths = [ "/home/motiejus/x:/var/run/mount-test/bind-paths/x" ];
|
2024-10-01 14:36:41 +03:00
|
|
|
PrivateDevices = false;
|
|
|
|
|
|
|
|
Type = "simple";
|
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = 10;
|
|
|
|
|
|
|
|
# Hardening
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
PrivateMounts = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
RestrictAddressFamilies = [
|
|
|
|
"AF_INET"
|
|
|
|
"AF_INET6"
|
|
|
|
"AF_UNIX"
|
|
|
|
];
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictSUIDSGID = true;
|
2024-10-01 15:52:20 +03:00
|
|
|
CapabilityBoundingSet = lib.mkForce "CAP_SYS_ADMIN | CAP_SETUID | CAP_SETGID";
|
2024-10-01 14:36:41 +03:00
|
|
|
|
|
|
|
User = "mount-test";
|
|
|
|
Group = "mount-test";
|
|
|
|
ExecStart =
|
|
|
|
"!"
|
|
|
|
+ (lib.getExe (
|
|
|
|
pkgs.writeShellApplication {
|
|
|
|
name = "mount-test";
|
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
bindfs
|
|
|
|
util-linux
|
|
|
|
];
|
|
|
|
text = ''
|
|
|
|
set -x
|
2024-10-01 15:52:20 +03:00
|
|
|
mkdir -p /data/x
|
|
|
|
bindfs -d -u motiejus -g users /var/run/mount-test/bind-paths/x /data/x &
|
|
|
|
sleep 1
|
|
|
|
#exec setpriv \
|
|
|
|
# --ruid mount-test \
|
|
|
|
# --inh-caps -sys_admin,-setuid,-setgid \
|
|
|
|
touch /data/x/foo
|
2024-10-01 14:36:41 +03:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-29 15:39:54 +03:00
|
|
|
users.extraGroups.vboxusers.members = [ "motiejus" ];
|
2024-03-12 21:26:31 +02:00
|
|
|
|
2024-09-20 14:36:09 +03:00
|
|
|
environment.systemPackages = with pkgs; [ dnsmasq ];
|
|
|
|
|
2024-07-15 20:59:26 +03:00
|
|
|
security.tpm2.enable = true;
|
|
|
|
|
2024-03-12 21:26:31 +02:00
|
|
|
networking = {
|
|
|
|
hostId = "b14a02aa";
|
|
|
|
hostName = "mtworx";
|
|
|
|
domain = "motiejus.jakst";
|
|
|
|
firewall.rejectPackets = true;
|
|
|
|
};
|
|
|
|
}
|