summaryrefslogtreecommitdiffstats
path: root/lass/2configs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-04-17 22:04:03 +0200
committertv <tv@krebsco.de>2019-04-17 22:04:03 +0200
commitffd36f5554256f74beb6ade469666b00f72b22a9 (patch)
tree51e77c75388d9f9e032bdb09427bcaace2b846c7 /lass/2configs
parente051fecf9c19d446d6588bd21070fd1a799b97a3 (diff)
parent1314eb9284697b46d8208c138cf2349816e15c5f (diff)
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'lass/2configs')
-rw-r--r--lass/2configs/baseX.nix1
-rw-r--r--lass/2configs/exim-smarthost.nix3
-rw-r--r--lass/2configs/green-host.nix83
-rw-r--r--lass/2configs/mail.nix4
-rw-r--r--lass/2configs/prism-share.nix2
-rw-r--r--lass/2configs/radio.nix9
-rw-r--r--lass/2configs/ssh-cryptsetup.nix17
-rw-r--r--lass/2configs/sync/decsync.nix8
-rw-r--r--lass/2configs/sync/weechat.nix8
-rw-r--r--lass/2configs/syncthing.nix2
-rw-r--r--lass/2configs/websites/domsen.nix2
-rw-r--r--lass/2configs/xdg-open.nix66
12 files changed, 198 insertions, 7 deletions
diff --git a/lass/2configs/baseX.nix b/lass/2configs/baseX.nix
index 26d6622ae..5003d2279 100644
--- a/lass/2configs/baseX.nix
+++ b/lass/2configs/baseX.nix
@@ -9,6 +9,7 @@ in {
./power-action.nix
./copyq.nix
./urxvt.nix
+ ./xdg-open.nix
{
hardware.pulseaudio = {
enable = true;
diff --git a/lass/2configs/exim-smarthost.nix b/lass/2configs/exim-smarthost.nix
index aec59261c..4216bd67a 100644
--- a/lass/2configs/exim-smarthost.nix
+++ b/lass/2configs/exim-smarthost.nix
@@ -100,6 +100,9 @@ with import <stockholm/lib>;
{ from = "box@lassul.us"; to = lass.mail; }
{ from = "paloalto@lassul.us"; to = lass.mail; }
{ from = "subtitles@lassul.us"; to = lass.mail; }
+ { from = "lobsters@lassul.us"; to = lass.mail; }
+ { from = "fysitech@lassul.us"; to = lass.mail; }
+ { from = "threema@lassul.us"; to = lass.mail; }
];
system-aliases = [
{ from = "mailer-daemon"; to = "postmaster"; }
diff --git a/lass/2configs/green-host.nix b/lass/2configs/green-host.nix
new file mode 100644
index 000000000..860d7c113
--- /dev/null
+++ b/lass/2configs/green-host.nix
@@ -0,0 +1,83 @@
+{ config, lib, pkgs, ... }:
+with import <stockholm/lib>;
+
+{
+ imports = [
+ <stockholm/lass/2configs/container-networking.nix>
+ <stockholm/lass/2configs/syncthing.nix>
+ { #hack for already defined
+ systemd.services."container@green".reloadIfChanged = mkForce false;
+ systemd.services."container@green".preStart = ''
+ ${pkgs.mount}/bin/mount | ${pkgs.gnugrep}/bin/grep -q ' on /var/lib/containers/green '
+ '';
+ systemd.services."container@green".postStop = ''
+ set -x
+ ${pkgs.umount}/bin/umount /var/lib/containers/green
+ ls -la /dev/mapper/control
+ ${pkgs.devicemapper}/bin/dmsetup ls
+ ${pkgs.cryptsetup}/bin/cryptsetup -v luksClose /var/lib/sync-containers/green.img
+ '';
+ }
+ ];
+
+ lass.ensure-permissions = [
+ { folder = "/var/lib/sync-containers"; owner = "root"; group = "syncthing"; }
+ ];
+
+ krebs.syncthing.folders = [
+ { path = "/var/lib/sync-containers"; peers = [ "icarus" "skynet" "littleT" "shodan" ]; }
+ ];
+
+ system.activationScripts.containerPermissions = ''
+ mkdir -p /var/lib/containers
+ chmod 711 /var/lib/containers
+ '';
+
+ containers.green = {
+ config = { ... }: {
+ environment.systemPackages = [
+ pkgs.git
+ pkgs.rxvt_unicode.terminfo
+ ];
+ services.openssh.enable = true;
+ users.users.root.openssh.authorizedKeys.keys = [
+ config.krebs.users.lass.pubkey
+ ];
+ };
+ autoStart = false;
+ enableTun = true;
+ privateNetwork = true;
+ hostAddress = "10.233.2.15";
+ localAddress = "10.233.2.16";
+ };
+
+ environment.systemPackages = [
+ (pkgs.writeDashBin "start-green" ''
+ set -fu
+ CONTAINER='green'
+ IMAGE='/var/lib/sync-containers/green.img'
+
+ ${pkgs.cryptsetup}/bin/cryptsetup status "$CONTAINER" >/dev/null
+ if [ "$?" -ne 0 ]; then
+ ${pkgs.cryptsetup}/bin/cryptsetup luksOpen "$IMAGE" "$CONTAINER"
+ fi
+
+ mkdir -p /var/lib/containers/"$CONTAINER"
+
+ ${pkgs.mount}/bin/mount | grep -q " on /var/lib/containers/"$CONTAINER" "
+ if [ "$?" -ne 0 ]; then
+ ${pkgs.mount}/bin/mount -o sync /dev/mapper/"$CONTAINER" /var/lib/containers/"$CONTAINER"
+ fi
+
+ STATE=$(${pkgs.nixos-container}/bin/nixos-container status "$CONTAINER")
+ if [ "$STATE" = 'down' ]; then
+ ${pkgs.nixos-container}/bin/nixos-container start "$CONTAINER"
+ fi
+ ping -c1 green.r
+ if [ "$?" -ne 0 ]; then
+ ${pkgs.nixos-container}/bin/nixos-container run green -- nixos-rebuild -I /var/src switch
+ fi
+
+ '')
+ ];
+}
diff --git a/lass/2configs/mail.nix b/lass/2configs/mail.nix
index 0803846aa..6de111ba8 100644
--- a/lass/2configs/mail.nix
+++ b/lass/2configs/mail.nix
@@ -233,8 +233,4 @@ in {
tag-new-mails
tag-old-mails
];
-
- nixpkgs.config.packageOverrides = opkgs: {
- notmuch = (opkgs.notmuch.overrideAttrs (o: { doCheck = false; }));
- };
}
diff --git a/lass/2configs/prism-share.nix b/lass/2configs/prism-share.nix
index 70e616ec6..aa3eb541d 100644
--- a/lass/2configs/prism-share.nix
+++ b/lass/2configs/prism-share.nix
@@ -21,7 +21,7 @@ with import <stockholm/lib>;
shares = {
incoming = {
path = "/mnt/prism";
- "read only" = "no";
+ "read only" = "yes";
browseable = "yes";
"guest ok" = "yes";
};
diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix
index f88b2627b..d67d970f8 100644
--- a/lass/2configs/radio.nix
+++ b/lass/2configs/radio.nix
@@ -59,6 +59,9 @@ in {
group = "radio";
musicDirectory = "/home/radio/the_playlist/music";
extraConfig = ''
+ log_level "default"
+ auto_update "yes"
+
audio_output {
type "shout"
encoding "lame"
@@ -245,4 +248,10 @@ in {
alias ${html};
'';
};
+ krebs.syncthing.folders = [
+ { id = "the_playlist"; path = "/home/radio/music/the_playlist"; peers = [ "mors" "phone" "prism" ]; }
+ ];
+ lass.ensure-permissions = [
+ { folder = "/home/radio/music/the_playlist"; owner = "radio"; group = "syncthing"; }
+ ];
}
diff --git a/lass/2configs/ssh-cryptsetup.nix b/lass/2configs/ssh-cryptsetup.nix
new file mode 100644
index 000000000..c5e1c5928
--- /dev/null
+++ b/lass/2configs/ssh-cryptsetup.nix
@@ -0,0 +1,17 @@
+{ config, ... }:
+{
+ boot.initrd = {
+ network = {
+ enable = true;
+ ssh = {
+ enable = true;
+ authorizedKeys = with config.krebs.users; [
+ config.krebs.users.lass-mors.pubkey
+ config.krebs.users.lass-blue.pubkey
+ config.krebs.users.lass-shodan.pubkey
+ config.krebs.users.lass-icarus.pubkey
+ ];
+ };
+ };
+ };
+}
diff --git a/lass/2configs/sync/decsync.nix b/lass/2configs/sync/decsync.nix
new file mode 100644
index 000000000..94569c94d
--- /dev/null
+++ b/lass/2configs/sync/decsync.nix
@@ -0,0 +1,8 @@
+{
+ krebs.syncthing.folders = [
+ { id = "decsync"; path = "/home/lass/decsync"; peers = [ "mors" "blue" "green" "phone" ]; }
+ ];
+ lass.ensure-permissions = [
+ { folder = "/home/lass/decsync"; owner = "lass"; group = "syncthing"; }
+ ];
+}
diff --git a/lass/2configs/sync/weechat.nix b/lass/2configs/sync/weechat.nix
new file mode 100644
index 000000000..d10177b1d
--- /dev/null
+++ b/lass/2configs/sync/weechat.nix
@@ -0,0 +1,8 @@
+{
+ krebs.syncthing.folders = [
+ { path = "/home/lass/.weechat"; peers = [ "blue" "green" "mors" ]; }
+ ];
+ lass.ensure-permissions = [
+ { folder = "/home/lass/.weechat"; owner = "lass"; group = "syncthing"; }
+ ];
+}
diff --git a/lass/2configs/syncthing.nix b/lass/2configs/syncthing.nix
index d8b3c9f90..fc10b2cb4 100644
--- a/lass/2configs/syncthing.nix
+++ b/lass/2configs/syncthing.nix
@@ -16,7 +16,7 @@ with import <stockholm/lib>;
key = toString <secrets/syncthing.key>;
peers = mapAttrs (n: v: { id = v.syncthing.id; }) (filterAttrs (n: v: v.syncthing.id != null) config.krebs.hosts);
folders = [
- { path = "/home/lass/sync"; peers = [ "icarus" "mors" "skynet" "blue" "green" "littleT" "prism"]; }
+ { path = "/home/lass/sync"; peers = [ "icarus" "mors" "skynet" "blue" "green" "littleT" "prism" "shodan" ]; }
];
};
diff --git a/lass/2configs/websites/domsen.nix b/lass/2configs/websites/domsen.nix
index 5bd5a7cac..2131c7c62 100644
--- a/lass/2configs/websites/domsen.nix
+++ b/lass/2configs/websites/domsen.nix
@@ -119,7 +119,7 @@ in {
authenticators.PLAIN = ''
driver = plaintext
public_name = PLAIN
- server_condition = ''${run{${config.lass.usershadow.path}/bin/verify_arg ${config.lass.usershadow.pattern} $auth2 $auth3}{yes}{no}}
+ server_condition = ''${run{/run/wrappers/bin/shadow_verify_arg ${config.lass.usershadow.pattern} $auth2 $auth3}{yes}{no}}
'';
authenticators.LOGIN = ''
driver = plaintext
diff --git a/lass/2configs/xdg-open.nix b/lass/2configs/xdg-open.nix
new file mode 100644
index 000000000..824c36dc7
--- /dev/null
+++ b/lass/2configs/xdg-open.nix
@@ -0,0 +1,66 @@
+{ config, pkgs, lib, ... }: with import <stockholm/lib>; let
+
+ xdg-open-wrapper = pkgs.writeDashBin "xdg-open" ''
+ /run/wrappers/bin/sudo -u lass ${xdg-open} "$@"
+ '';
+
+ xdg-open = pkgs.writeBash "xdg-open" ''
+ set -e
+ FILE="$1"
+ mime=
+
+ case "$FILE" in
+ http://*|https://*)
+ mime=text/html
+ ;;
+ mailto:*)
+ mime=special/mailaddress
+ ;;
+ magnet:*)
+ mime=application/x-bittorrent
+ ;;
+ irc:*)
+ mime=x-scheme-handler/irc
+ ;;
+ *)
+ # it’s a file
+
+ # strip possible protocol
+ FILE=''${FILE#file://}
+ mime=''$(file -E --brief --mime-type "$FILE") \
+ || (echo "$mime" 1>&2; exit 1)
+ # ^ echo the error message of file
+ ;;
+ esac
+
+ case "$mime" in
+ special/mailaddress)
+ urxvtc --execute vim "$FILE" ;;
+ ${optionalString (hasAttr "browser" config.lass) ''
+ text/html)
+ ${config.lass.browser.select}/bin/browser-select "$FILE" ;;
+ text/xml)
+ ${config.lass.browser.select}/bin/browser-select "$FILE" ;;
+ ''}
+ text/*)
+ urxvtc --execute vim "$FILE" ;;
+ image/*)
+ sxiv "$FILE" ;;
+ application/x-bittorrent)
+ env DISPLAY=:0 transgui "$FILE" ;;
+ application/pdf)
+ zathura "$FILE" ;;
+ inode/directory)
+ sudo -u lass -i urxvtc --execute mc "$FILE" ;;
+ *)
+ # open dmenu and ask for program to open with
+ $(dmenu_path | dmenu) "$FILE";;
+ esac
+ '';
+in {
+ environment.systemPackages = [ xdg-open-wrapper ];
+
+ security.sudo.extraConfig = ''
+ cr ALL=(lass) NOPASSWD: ${xdg-open} *
+ '';
+}