added backup module and backups for box and curve
also put a reverse proxy infront of radicale
This commit is contained in:
		
							parent
							
								
									ef507ca7aa
								
							
						
					
					
						commit
						5637febfd5
					
				|  | @ -12,4 +12,23 @@ | ||||||
|   services."grasp".enable = true; |   services."grasp".enable = true; | ||||||
|   services."grasp".path = "/home/anish/kitaab/grasp"; |   services."grasp".path = "/home/anish/kitaab/grasp"; | ||||||
|   services."grasp".user = "anish"; |   services."grasp".user = "anish"; | ||||||
|  | 
 | ||||||
|  |   services.postgresqlBackup = { | ||||||
|  |     enable = true; | ||||||
|  |     databases = [ "wallabag" ]; | ||||||
|  |     location = "/var/backup/postgresql"; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   mossnet.backup = { | ||||||
|  |     enable = true; | ||||||
|  |     name = "mossnet"; | ||||||
|  |     paths = [ | ||||||
|  |       "/var/lib/taskserver" # taskwarrior | ||||||
|  |       "/var/www/shaarli-config" # sharli | ||||||
|  |       "/var/backup/postgresql" # wallabag | ||||||
|  |       "/var/lib/radicale" # radicale | ||||||
|  |     ]; | ||||||
|  |     # seafile? | ||||||
|  |     # syncthing | ||||||
|  |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -28,22 +28,28 @@ | ||||||
| 
 | 
 | ||||||
|   boot.supportedFilesystems = [ "ntfs" ]; |   boot.supportedFilesystems = [ "ntfs" ]; | ||||||
| 
 | 
 | ||||||
|  |   mossnet.backup = { | ||||||
|  |     enable = true; | ||||||
|  |     name = "curve"; | ||||||
|  |     paths = [ "/home/anish" ]; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|   # enable adb  |   # enable adb  | ||||||
|   # TODO move this (it's for KaiOS WebIDE devShell?) |   # TODO move this (it's for KaiOS WebIDE devShell?) | ||||||
|   programs.adb.enable = true; |   programs.adb.enable = true; | ||||||
|   #virtualisation.docker.enable = true; |   #virtualisation.docker.enable = true; | ||||||
|   services.udev.extraRules = '' |   services.udev.extraRules = '' | ||||||
|         # Monitor plugged in |     # Monitor plugged in | ||||||
|         # Doesn't work, becuase /home/anish/bin/hotplug-monitor isn't part of the nix build |     # Doesn't work, becuase /home/anish/bin/hotplug-monitor isn't part of the nix build | ||||||
|         # KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/anish/.Xauthority", RUN+="/home/anish/bin/hotplug-monitor.sh" # TODO: add this file to nix home-manager |     # KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/anish/.Xauthority", RUN+="/home/anish/bin/hotplug-monitor.sh" # TODO: add this file to nix home-manager | ||||||
| 
 | 
 | ||||||
|         # Qualcomm EDL |     # Qualcomm EDL | ||||||
|         SUBSYSTEMS=="usb", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9008", MODE="0666", GROUP="plugdev" |     SUBSYSTEMS=="usb", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9008", MODE="0666", GROUP="plugdev" | ||||||
| 
 | 
 | ||||||
|         # Qualcomm Memory Debug |     # Qualcomm Memory Debug | ||||||
|         SUBSYSTEMS=="usb", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9006", MODE="0666", GROUP="plugdev" |     SUBSYSTEMS=="usb", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9006", MODE="0666", GROUP="plugdev" | ||||||
| 
 | 
 | ||||||
|         # Atmel DFU |     # Atmel DFU | ||||||
|     ### ATmega16U2 |     ### ATmega16U2 | ||||||
|     SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2fef", TAG+="uaccess" |     SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2fef", TAG+="uaccess" | ||||||
|     ### ATmega32U2 |     ### ATmega32U2 | ||||||
|  |  | ||||||
							
								
								
									
										54
									
								
								modules/backup.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								modules/backup.nix
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,54 @@ | ||||||
|  | # Assumes the remote borg backup server has already been initialized | ||||||
|  | # TODO:  | ||||||
|  | # This currently works on a per host basis, and the host file has to define all the locations it wants to back up. | ||||||
|  | # Ideally, this would create a job for each profile instead, so the backup strategy is included in the profile regardless of host | ||||||
|  | { config, lib, pkgs, ... }: | ||||||
|  | with lib; | ||||||
|  | let | ||||||
|  |   cfg = config.mossnet.backup; | ||||||
|  | in | ||||||
|  | { | ||||||
|  |   options = { | ||||||
|  |     mossnet.backup = { | ||||||
|  |       enable = mkEnableOption "Backup module using borg for Anish's computer nursery"; | ||||||
|  |       name = lib.mkOption { | ||||||
|  |         type = types.str; | ||||||
|  |         default = { }; | ||||||
|  |         example = literalExample '' | ||||||
|  |           shaarli | ||||||
|  |         ''; | ||||||
|  |         description = '' | ||||||
|  |           name for the backup operator | ||||||
|  |         ''; | ||||||
|  |       }; | ||||||
|  |       paths = lib.mkOption { | ||||||
|  |         type = with types; attrsOf (listOf str); | ||||||
|  |         default = { }; | ||||||
|  |         example = literalExample '' | ||||||
|  |           [ "/home/anish/usr" ]; | ||||||
|  |         ''; | ||||||
|  |         description = '' | ||||||
|  |           A list of folders to backup | ||||||
|  |         ''; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   config = mkIf cfg.enable { | ||||||
|  |     services.borgbackup.jobs = { | ||||||
|  |       "${cfg.name}" = { | ||||||
|  |         paths = cfg.paths; | ||||||
|  |         doInit = true; | ||||||
|  |         repo = "20779@hk-s020.rsync.net:${cfg.name}"; | ||||||
|  |         encryption = { | ||||||
|  |           mode = "repokey-blake2"; | ||||||
|  |           passCommand = "cat /run/keys/borg-password"; | ||||||
|  |         }; | ||||||
|  |         environment = { BORG_RSH = "ssh -i /root/borg/borg-key"; }; # YOU NEED TO PUT THIS HERE MANUALLY | ||||||
|  |         compression = "auto,lzma"; | ||||||
|  |         startAt = "weekly"; | ||||||
|  |         extraArgs = "--remote-path=borg1"; | ||||||
|  |       }; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | } | ||||||
|  | @ -7,5 +7,18 @@ | ||||||
|       server.hosts = [ "0.0.0.0:5252" ]; |       server.hosts = [ "0.0.0.0:5252" ]; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
|  | 
 | ||||||
|   networking.firewall.allowedTCPPorts = [ 5252 ]; |   networking.firewall.allowedTCPPorts = [ 5252 ]; | ||||||
|  | 
 | ||||||
|  |   services.nginx.virtualHosts."cal.mossnet.lan" = { | ||||||
|  |     enableACME = false; | ||||||
|  |     forceSSL = false; | ||||||
|  | 
 | ||||||
|  |     locations."/" = { | ||||||
|  |       extraConfig = '' | ||||||
|  |         proxy_pass http://localhost:5252/; | ||||||
|  |         proxy_set_header X-Forwarded-Host $host; | ||||||
|  |       ''; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue