Compare commits
14 Commits
29a0a80594
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
634022d717
|
|||
|
b3b590dbf3
|
|||
|
7083d475db
|
|||
|
2cf9053ca9
|
|||
|
6d9a883361
|
|||
|
9b196037db
|
|||
|
94eecc7e20
|
|||
|
7af1063f1f
|
|||
|
63a9fb80a1
|
|||
|
0cef524a0c
|
|||
|
d90f9fb648
|
|||
|
080e83aa5a
|
|||
|
0e312ded51
|
|||
|
a082dda03b
|
14
README.org
14
README.org
@@ -1,3 +1,17 @@
|
||||
* Unit
|
||||
|
||||
Declarative configuration for the main server, using [[https://nixos.org][NixOS]]
|
||||
|
||||
** Modules
|
||||
|
||||
The configuration is sliced into different files, per category:
|
||||
|
||||
- ZFS pool configuration: hardware-configuration.nix
|
||||
- Network configuration: networking.nix
|
||||
- Synchronization and backup services: datasync.nix
|
||||
- Web services and reverse proxy: webstack.nix
|
||||
- Smartd: monitoring.nix
|
||||
- Systemd services and timers: periodic.nix
|
||||
- Virtual machines: virtualization.nix
|
||||
|
||||
All the modules are imported in *configuration.nix*
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
services.samba = {
|
||||
enable = true;
|
||||
nsswins = true;
|
||||
syncPasswordsByPam = true;
|
||||
extraConfig = ''
|
||||
workgroup = WORKGROUP
|
||||
server string = unit
|
||||
@@ -52,7 +51,7 @@
|
||||
enable = true;
|
||||
package = pkgs.nextcloud21;
|
||||
home = "/vault/nextcloud";
|
||||
hostName = "nextcloud.coace.duckdns.org";
|
||||
hostName = "coace.duckdns.org";
|
||||
https = true;
|
||||
autoUpdateApps = {
|
||||
enable = true;
|
||||
|
||||
@@ -4,95 +4,107 @@
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
imports =
|
||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules =
|
||||
[ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
|
||||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "system/stateful/root";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/" =
|
||||
{ device = "system/stateful/root";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/nix" = {
|
||||
device = "system/ephemeral/nix";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/nix" =
|
||||
{ device = "system/ephemeral/nix";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/tmp" = {
|
||||
device = "system/ephemeral/tmp";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/tmp" =
|
||||
{ device = "system/ephemeral/tmp";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/home" = {
|
||||
device = "system/stateful/home";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/home" =
|
||||
{ device = "system/stateful/home";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-uuid/B314-22E9";
|
||||
fsType = "vfat";
|
||||
};
|
||||
fileSystems."/boot" =
|
||||
{ device = "/dev/disk/by-uuid/B314-22E9";
|
||||
fsType = "vfat";
|
||||
};
|
||||
|
||||
fileSystems."/vault" = {
|
||||
device = "vault";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault" =
|
||||
{ device = "vault";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/backups" = {
|
||||
device = "vault/backups";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/VMs" =
|
||||
{ device = "vault/VMs";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/VMs" = {
|
||||
device = "vault/VMs";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/backups" =
|
||||
{ device = "vault/backups";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/config" = {
|
||||
device = "vault/config";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/nextcloud" =
|
||||
{ device = "vault/nextcloud";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/samba" = {
|
||||
device = "vault/samba";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/code" =
|
||||
{ device = "vault/code";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/code" = {
|
||||
device = "vault/code";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/backups/databases" =
|
||||
{ device = "vault/backups/databases";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/VMs/legacy" = {
|
||||
device = "vault/VMs/legacy";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/samba" =
|
||||
{ device = "vault/samba";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/backups/databases" = {
|
||||
device = "vault/backups/databases";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/backups/wordpress" =
|
||||
{ device = "vault/backups/wordpress";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/nextcloud" = {
|
||||
device = "vault/nextcloud";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/backups/frontend" =
|
||||
{ device = "vault/backups/frontend";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/backups/documents" = {
|
||||
device = "vault/backups/documents";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/backups/documents" =
|
||||
{ device = "vault/backups/documents";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/backups/frontend" = {
|
||||
device = "vault/backups/frontend";
|
||||
fsType = "zfs";
|
||||
};
|
||||
fileSystems."/vault/config" =
|
||||
{ device = "vault/config";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/VMs/legacy" =
|
||||
{ device = "vault/VMs/legacy";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
fileSystems."/vault/frontend" =
|
||||
{ device = "vault/frontend";
|
||||
fsType = "zfs";
|
||||
};
|
||||
|
||||
swapDevices =
|
||||
[{ device = "/dev/disk/by-uuid/8262a243-b6aa-49e8-bf72-d2b85864d1c0"; }];
|
||||
[ { device = "/dev/disk/by-uuid/8262a243-b6aa-49e8-bf72-d2b85864d1c0"; }
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -51,11 +51,13 @@ in {
|
||||
5000 # Sybase
|
||||
80 # HTTP
|
||||
443 # HTTPS
|
||||
53 # DNS
|
||||
];
|
||||
allowedUDPPorts = [
|
||||
137 # Samba
|
||||
138 # Samba
|
||||
1194 # Wireguard
|
||||
53 # DNS
|
||||
];
|
||||
allowPing = true;
|
||||
};
|
||||
@@ -101,6 +103,11 @@ in {
|
||||
publicKey = "5DU9ipxJcut2wKrUr3yQux9crzXMSW4ZeKWFLRpUc1I=";
|
||||
allowedIPs = [ "10.9.0.4/32" ];
|
||||
}
|
||||
# manuela
|
||||
{
|
||||
publicKey = "V+DaOya2hLuV6C9BeCkDyFqXpPAFq9jMAeg1dvQw/FI=";
|
||||
allowedIPs = [ "10.9.0.5/32" ];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
@@ -130,4 +137,25 @@ in {
|
||||
'';
|
||||
};
|
||||
|
||||
# DNS server with adblock
|
||||
services.dnsmasq = {
|
||||
enable = true;
|
||||
servers = [ "1.1.1.1" "8.8.8.8" ];
|
||||
extraConfig = ''
|
||||
domain-needed
|
||||
bogus-priv
|
||||
no-resolv
|
||||
|
||||
listen-address=127.0.0.1,10.0.1.3
|
||||
bind-interfaces
|
||||
|
||||
cache-size=10000
|
||||
local-ttl=300
|
||||
|
||||
conf-file=/var/lib/dnsmasq/dnsmasq.blacklist.txt
|
||||
|
||||
address=/coace.duckdns.org/10.0.1.3
|
||||
'';
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
let
|
||||
stateDir = "/var/lib/dnsmasq";
|
||||
blocklist = "${stateDir}/dnsmasq.blacklist.txt";
|
||||
|
||||
in {
|
||||
# Pull changes from git repos
|
||||
systemd.user.services.git-pull = {
|
||||
description = "Pull git repositories";
|
||||
@@ -11,16 +15,8 @@
|
||||
cd "$base_folder" || exit
|
||||
ls | xargs -P10 -I{} git -C {} pull --rebase
|
||||
'';
|
||||
serviceConfig = { Type = "oneshot"; };
|
||||
};
|
||||
|
||||
systemd.user.timers.doom-upgrade = {
|
||||
description = "Daily code update";
|
||||
wantedBy = [ "default.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "22:00:00";
|
||||
Unit = "git-pull.service";
|
||||
};
|
||||
serviceConfig.Type = "oneshot";
|
||||
startAt = "22:00:00";
|
||||
};
|
||||
|
||||
# PostgreSQL daily backups
|
||||
@@ -30,4 +26,20 @@
|
||||
location = "/vault/backups/databases/nextcloud";
|
||||
startAt = "*-*-* 05:15:00";
|
||||
};
|
||||
|
||||
# Fetch hosts-blocklists daily
|
||||
systemd.services.download-dns-blocklist = {
|
||||
description = "Download hosts-blocklists";
|
||||
wantedBy = [ "default.target" ];
|
||||
path = with pkgs; [ curl ];
|
||||
script =
|
||||
"curl -L https://github.com/notracking/hosts-blocklists/raw/master/dnsmasq/dnsmasq.blacklist.txt -o ${blocklist}";
|
||||
serviceConfig.Type = "oneshot";
|
||||
postStop = ''
|
||||
chown -R dnsmasq ${stateDir}
|
||||
systemctl restart dnsmasq
|
||||
'';
|
||||
startAt = "02:00:00";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
|
||||
'';
|
||||
virtualHosts = {
|
||||
"nextcloud.coace.duckdns.org" = {
|
||||
"coace.duckdns.org" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
};
|
||||
@@ -48,8 +48,7 @@
|
||||
security.acme = {
|
||||
acceptTerms = true;
|
||||
email = "secretario@arquitectosdeceuta.com";
|
||||
certs."nextcloud.coace.duckdns.org".webroot =
|
||||
"/var/lib/acme/acme-challenge";
|
||||
certs."coace.duckdns.org".webroot = "/var/lib/acme/acme-challenge";
|
||||
};
|
||||
|
||||
# Generate dhparams
|
||||
@@ -69,7 +68,4 @@
|
||||
host all all ::1/128 trust
|
||||
'';
|
||||
};
|
||||
|
||||
# Restart reverse proxy after services startup
|
||||
systemd.services.nginx.after = [ "nextcloud.service" ];
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ sybase_service() {
|
||||
|
||||
perform_backup() {
|
||||
zip -r BBDD_"$(date +"%d%m%Y")".zip /opt/sybase
|
||||
scp BBDD_"$(date +"%d%m%Y")".zip unit:/vault/backups/databases/sica
|
||||
scp -i /root/.ssh/unit BBDD_"$(date +"%d%m%Y")".zip coace@192.168.122.1:/vault/backups/databases/sica
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
|
||||
Reference in New Issue
Block a user