From 0257acf93a7cfc91fa65b0d00dcf7f70caa9a33b Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 17:56:06 +0100 Subject: tv urlwatch: add vncdotool and noVNC --- tv/2configs/urlwatch.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tv/2configs') diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix index 8189f6345..0106cddf7 100644 --- a/tv/2configs/urlwatch.nix +++ b/tv/2configs/urlwatch.nix @@ -51,6 +51,9 @@ # # is derived from `configFile` in: https://raw.githubusercontent.com/NixOS/nixpkgs/master/nixos/modules/services/x11/xserver.nix + + https://pypi.python.org/pypi/vncdotool + https://api.github.com/repos/kanaka/noVNC/tags ]; }; } -- cgit v1.2.3 From de4260a6a2b77aeb8115167ee63c1b20facd5b6a Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 17:56:59 +0100 Subject: tv backup: add xu-test-* --- tv/2configs/backup.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tv/2configs') diff --git a/tv/2configs/backup.nix b/tv/2configs/backup.nix index 6c90709a8..57f299ebd 100644 --- a/tv/2configs/backup.nix +++ b/tv/2configs/backup.nix @@ -26,5 +26,28 @@ with lib; yearly = { format = "%Y"; }; }; }; + } // mapAttrs (_: recursiveUpdate { + snapshots = { + minutely = { format = "%Y-%m-%dT%H:%M"; retain = 3; }; + hourly = { format = "%Y-%m-%dT%H"; retain = 3; }; + daily = { format = "%Y-%m-%d"; retain = 3; }; + }; + startAt = null; + }) { + xu-test-push-xu = { + method = "push"; + src = { host = config.krebs.hosts.xu; path = "/tmp/xu-bku-test-data"; }; + dst = { host = config.krebs.hosts.xu; path = "/bku/xu-test-push"; }; + }; + xu-test-pull-xu = { + method = "pull"; + src = { host = config.krebs.hosts.xu; path = "/tmp/xu-bku-test-data"; }; + dst = { host = config.krebs.hosts.xu; path = "/bku/xu-test-pull"; }; + }; + xu-test-push-wu = { + method = "push"; + src = { host = config.krebs.hosts.xu; path = "/tmp/xu-bku-test-data"; }; + dst = { host = config.krebs.hosts.wu; path = "/bku/xu-test-push"; }; + }; }; } -- cgit v1.2.3 From 9fbd327b80caa3c79940631138963e2e4b069ff7 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 17:58:02 +0100 Subject: tv systemPackages: add get, krebszones, nix-prefetch-scripts, and push --- tv/2configs/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tv/2configs') diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index b5639af51..dee0b15b1 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -183,6 +183,15 @@ with lib; "sendmail" # for sudo ]; } + { + environment.systemPackages = [ + pkgs.get + pkgs.krebszones + pkgs.nix-prefetch-scripts + pkgs.push + ]; + } + { systemd.tmpfiles.rules = let forUsers = flip map users; -- cgit v1.2.3 From 115711d529500684da5b72f3e20c98279184b045 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 18:21:17 +0100 Subject: xu-qemu0: init --- tv/2configs/xu-qemu0.nix | 226 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 tv/2configs/xu-qemu0.nix (limited to 'tv/2configs') diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix new file mode 100644 index 000000000..836603663 --- /dev/null +++ b/tv/2configs/xu-qemu0.nix @@ -0,0 +1,226 @@ +{ config, lib, pkgs, ... }: + +let + # XXX cannot use config.build.host.name here because infinite recursion when + # defining krebs.hosts.${host-name}.nets.retiolum.aliases below. + host-name = "xu"; +in + +# usage: +# sudo -iu df xu-qemu0 +# set_password vnc correcthorze +# +# vncdo -s xu:1 type 'curl init.xu.r' key shift-\\ type sh key return +# +# http://vnc.xu/vnc_auto.html?port=5701&host=xu&password=correcthorze +# +# make [install] system=xu-qemu0 target_host=10.56.0.101 + + +with lib; + +{ + #networking.wireless.interfaces = [ "wlp3s0" ]; + + #networking.useNetworkd = true; + + #networking.dhcpcd.allowInterfaces = [ + # "qemubr0" + #]; + + #systemd.network.networks.wlp3s0 = { + # matchConfig.name = "wlp3s0"; + # networkConfig.Bridge = "qemubr0"; + #}; + + systemd.network.enable = true; + + systemd.network.netdevs.qemubr0 = { + netdevConfig = { + Name = "qemubr0"; + Kind = "bridge"; + }; + }; + + users.groups.qemu-users.gid = genid "qemu-users"; + users.users.df.extraGroups = [ "qemu-users" ]; + + environment.etc."qemu/bridge.conf".text = '' + allow qemubr0 + ''; + + krebs.per-user.tv.packages = [ + pkgs.vncdotool + ]; + + krebs.per-user.df.packages = [ + (pkgs.writeDashBin "xu-qemu0" '' + set -efux + img=$HOME/tmp/xu-qemu0.raw + if ! test -e "$img"; then + ${pkgs.coreutils}/bin/mkdir -p "$(${pkgs.coreutils}/bin/dirname "$img")" + ${pkgs.kvm}/bin/qemu-img create "$img" 10G + fi + exec ${pkgs.kvm}/bin/qemu-kvm \ + -monitor stdio \ + -boot order=cd \ + -cdrom ${pkgs.fetchurl { + url = https://nixos.org/releases/nixos/15.09/nixos-15.09.1012.9fe0c23/nixos-minimal-15.09.1012.9fe0c23-x86_64-linux.iso; + sha256 = "18bc9wrsrjnhj9rya75xliqkl99gxbsk4dmwqivhvwfzb5qb5yp9"; + }} \ + -m 1024 \ + -netdev bridge,br=qemubr0,id=hn0,helper=/var/setuid-wrappers/qemu-bridge-helper \ + -net nic,netdev=hn0,id=nic1,macaddr=52:54:00:12:34:56 \ + -drive file="$img",format=raw \ + -display vnc=:1,websocket=5701,password,lossy \ + -name xu-qemu0 \ + '') + ]; + + #TODO krebs.setuid.qemu-bridge-helper = { + # filename = "${pkgs.qemu}/libexec/qemu-bridge-helper"; + # owner = "root"; + # group = "qemu-users"; + # mode = "4710"; + #}; + system.activationScripts."krebs.setuid" = stringAfter [ "setuid" ] '' + src=${pkgs.execve "qemu-bridge-helper" { + filename = "${pkgs.qemu}/libexec/qemu-bridge-helper"; + }} + dst=${config.security.wrapperDir}/qemu-bridge-helper + cp "$src" "$dst" + chown root.qemu-users "$dst" + chmod 4710 "$dst" + ''; + + users.users.qemu-dnsmasq.uid = genid "qemu-dnsmasq"; + + # TODO need custom etc/dbus-1/system.d/dnsmasq.conf for different BusName + services.dbus.packages = [ pkgs.dnsmasq ]; + + systemd.services.qemu-dnsmasq = let + # bind-interfaces + conf = pkgs.writeText "qemu-dnsmasq.conf" '' + listen-address=10.56.0.1 + interface=qemubr0 + dhcp-range=10.56.0.200,10.56.0.250 + dhcp-no-override + dhcp-leasefile=/tmp/qemu-dnsmasq.leases + domain=${host-name}.local + dhcp-host=52:54:00:12:34:56,xu-qemu0,10.56.0.101,1440m + ''; + in { + after = [ "network.target" "systemd-resolved.service" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "dbus"; + BusName = "uk.org.thekelleys.dnsmasq"; + # -1 --enable-dbus[=uk.org.thekelleys.dnsmasq] + SyslogIdentifier = "qemu-dnsmasq"; + ExecStart = "${pkgs.dnsmasq}/bin/dnsmasq -1k -u qemu-dnsmasq -C ${conf}"; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + PrivateTmp = "true"; + }; + restartTriggers = [ config.environment.etc.hosts.source ]; + }; + + + krebs.nginx.servers.init = { + server-names = [ + "init.${host-name}" + "init.${host-name}.r" + "init.${host-name}.retiolum" + ]; + extraConfig = '' + index init.txt; + root ${pkgs.writeTextFile { + name = "init-pages"; + text = '' + #! /bin/sh + set -efu + + dev=/dev/sda + pttype=dos # gpt + + case $pttype in + dos) + if ! test "$(blkid -o value -s PTTYPE "$dev")" = dos; then + parted -s "$dev" mklabel msdos + fi + if ! test "$(blkid -o value -s PARTLABEL "$dev"1)" = primary; then + parted -s "$dev" mkpart primary ext4 1MiB 513MiB + parted -s "$dev" set 1 boot on + fi + ;; + gpt) + if ! test "$(blkid -o value -s PTTYPE "$dev")" = gpt; then + parted -s "$dev" mklabel gpt + fi + if ! test "$(blkid -o value -s PARTLABEL "$dev"1)" = ESP; then + parted -s "$dev" mkpart ESP fat32 1MiB 513MiB + parted -s "$dev" set 1 boot on + fi + ;; + *) + echo "Error: bad pttype: $pttype" >&2 + exit -1 + esac + + if ! test "$(blkid -o value -s PARTLABEL "$dev"2)" = primary; then + parted -s "$dev" mkpart primary btrfs 513MiB 100% + fi + if ! test "$(blkid -o value -s TYPE "$dev"1)" = vfat; then + mkfs.vfat "$dev"1 + fi + if ! test "$(blkid -o value -s TYPE "$dev"2)" = btrfs; then + mkfs.btrfs "$dev"2 + fi + + parted "$dev" print + + if ! test "$(lsblk -n -o MOUNTPOINT "$dev"2)" = /mnt; then + mount "$dev"2 /mnt + fi + if ! test "$(lsblk -n -o MOUNTPOINT "$dev"1)" = /mnt/boot; then + mkdir -m 0000 -p /mnt/boot + mount "$dev"1 /mnt/boot + fi + + lsblk "$dev" + + key=${shell.escape config.krebs.users.tv-xu.pubkey} + + if [ "$(cat /root/.ssh/authorized_keys 2>/dev/null)" != "$key" ]; then + mkdir -p /root/.ssh + echo "$key" > /root/.ssh/authorized_keys + fi + systemctl start sshd + ip route + echo READY. + ''; + destination = "/init.txt"; + }}; + ''; + }; + + + krebs.hosts.${host-name}.nets.retiolum.aliases = [ + "init.${host-name}.r" + "init.${host-name}.retiolum" + "vnc.${host-name}.r" + "vnc.${host-name}.retiolum" + ]; + + krebs.nginx.servers.noVNC = { + server-names = [ + "vnc.${host-name}" + "vnc.${host-name}.r" + "vnc.${host-name}.retiolum" + ]; + #rewrite ^([^.]*)$ /vnc_auto.html?host=localhost&port=5701; + locations = singleton (nameValuePair "/" '' + index vnc.html; + root ${pkgs.noVNC}; + ''); + }; +} -- cgit v1.2.3 From 3ca0df0447c30d83c14144ad6f9a95cd4514117c Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 19:57:45 +0100 Subject: tv: add systemd.services.xu-qemu0 + xu-qemu0-monitor --- tv/2configs/default.nix | 1 + tv/2configs/xu-qemu0.nix | 86 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 61 insertions(+), 26 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index dee0b15b1..2edaed76d 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -44,6 +44,7 @@ with lib; tv = { isNormalUser = true; uid = 1337; + extraGroups = [ "tv" ]; }; }; }; diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix index 836603663..4584dcd7c 100644 --- a/tv/2configs/xu-qemu0.nix +++ b/tv/2configs/xu-qemu0.nix @@ -7,8 +7,7 @@ let in # usage: -# sudo -iu df xu-qemu0 -# set_password vnc correcthorze +# echo set_password vnc correcthorze | xu-qemu0-monitor # # vncdo -s xu:1 type 'curl init.xu.r' key shift-\\ type sh key return # @@ -16,6 +15,13 @@ in # # make [install] system=xu-qemu0 target_host=10.56.0.101 +# TODO iptables -A INPUT -p udp -m udp --dport bootps -j ACCEPT +# TODO iptables -A FORWARD -i qemubr0 -s 10.56.0.1/24 -m conntrack --ctstate NEW -j ACCEPT +# TODO iptables -A POSTROUTING -t nat -j MASQUERADE +# TODO iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT +# TODO iptables -A INPUT -i qemubr0 -p udp -m udp --dport domain -j ACCEPT +# TODO echo 1 > /proc/sys/net/ipv4/ip_forward +# TODO ifconfig qemubr0 10.56.0.1/24 up with lib; @@ -43,7 +49,6 @@ with lib; }; users.groups.qemu-users.gid = genid "qemu-users"; - users.users.df.extraGroups = [ "qemu-users" ]; environment.etc."qemu/bridge.conf".text = '' allow qemubr0 @@ -53,29 +58,58 @@ with lib; pkgs.vncdotool ]; - krebs.per-user.df.packages = [ - (pkgs.writeDashBin "xu-qemu0" '' - set -efux - img=$HOME/tmp/xu-qemu0.raw - if ! test -e "$img"; then - ${pkgs.coreutils}/bin/mkdir -p "$(${pkgs.coreutils}/bin/dirname "$img")" - ${pkgs.kvm}/bin/qemu-img create "$img" 10G - fi - exec ${pkgs.kvm}/bin/qemu-kvm \ - -monitor stdio \ - -boot order=cd \ - -cdrom ${pkgs.fetchurl { - url = https://nixos.org/releases/nixos/15.09/nixos-15.09.1012.9fe0c23/nixos-minimal-15.09.1012.9fe0c23-x86_64-linux.iso; - sha256 = "18bc9wrsrjnhj9rya75xliqkl99gxbsk4dmwqivhvwfzb5qb5yp9"; - }} \ - -m 1024 \ - -netdev bridge,br=qemubr0,id=hn0,helper=/var/setuid-wrappers/qemu-bridge-helper \ - -net nic,netdev=hn0,id=nic1,macaddr=52:54:00:12:34:56 \ - -drive file="$img",format=raw \ - -display vnc=:1,websocket=5701,password,lossy \ - -name xu-qemu0 \ - '') - ]; + users.users.xu-qemu0 = { + createHome = true; + group = "qemu-users"; + home = "/home/xu-qemu0"; + uid = genid "xu-qemu0"; + }; + + systemd.services.xu-qemu0 = let + in { + after = [ "network.target" "systemd-resolved.service" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "xu-qemu0"; + SyslogIdentifier = "xu-qemu0"; + ExecStart = pkgs.writeDash "xu-qemu0" '' + set -efu + img=$HOME/tmp/xu-qemu0.raw + if ! test -e "$img"; then + ${pkgs.coreutils}/bin/mkdir -p "$(${pkgs.coreutils}/bin/dirname "$img")" + ${pkgs.kvm}/bin/qemu-img create "$img" 10G + fi + exec ${pkgs.kvm}/bin/qemu-kvm \ + -monitor unix:$HOME/xu-qemu0.sock,server,nowait \ + -boot order=cd \ + -cdrom ${pkgs.fetchurl { + url = https://nixos.org/releases/nixos/15.09/nixos-15.09.1012.9fe0c23/nixos-minimal-15.09.1012.9fe0c23-x86_64-linux.iso; + sha256 = "18bc9wrsrjnhj9rya75xliqkl99gxbsk4dmwqivhvwfzb5qb5yp9"; + }} \ + -m 1024 \ + -netdev bridge,br=qemubr0,id=hn0,helper=/var/setuid-wrappers/qemu-bridge-helper \ + -net nic,netdev=hn0,id=nic1,macaddr=52:54:00:12:34:56 \ + -drive file="$img",format=raw \ + -display vnc=:1,websocket=5701,password,lossy \ + -name xu-qemu0 \ + ''; + }; + }; + + system.activationScripts."krebs.setuid.xu-qemu0-monitor" = stringAfter [ "setuid" ] '' + src=${pkgs.execve "xu-qemu0-monitor" { + # TODO toC should handle derivation, then we don't have to "${...}" here + filename = "${pkgs.writeDash "xu-qemu0-monitor" '' + exec ${pkgs.socat}/bin/socat \ + stdio \ + UNIX-CONNECT:${config.users.users.xu-qemu0.home}/xu-qemu0.sock \ + ''}"; + }} + dst=${config.security.wrapperDir}/xu-qemu0-monitor + cp "$src" "$dst" + chown xu-qemu0.tv "$dst" + chmod 4710 "$dst" + ''; #TODO krebs.setuid.qemu-bridge-helper = { # filename = "${pkgs.qemu}/libexec/qemu-bridge-helper"; -- cgit v1.2.3 From 450ca1f0cce267e68b4950504140cdbebe1b4b8e Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 20:09:23 +0100 Subject: xu-qemu0: create socket in ~/tmp --- tv/2configs/xu-qemu0.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix index 4584dcd7c..470b16ea4 100644 --- a/tv/2configs/xu-qemu0.nix +++ b/tv/2configs/xu-qemu0.nix @@ -74,13 +74,13 @@ with lib; SyslogIdentifier = "xu-qemu0"; ExecStart = pkgs.writeDash "xu-qemu0" '' set -efu + ${pkgs.coreutils}/bin/mkdir -p "$HOME/tmp" img=$HOME/tmp/xu-qemu0.raw if ! test -e "$img"; then - ${pkgs.coreutils}/bin/mkdir -p "$(${pkgs.coreutils}/bin/dirname "$img")" ${pkgs.kvm}/bin/qemu-img create "$img" 10G fi exec ${pkgs.kvm}/bin/qemu-kvm \ - -monitor unix:$HOME/xu-qemu0.sock,server,nowait \ + -monitor unix:$HOME/tmp/xu-qemu0.sock,server,nowait \ -boot order=cd \ -cdrom ${pkgs.fetchurl { url = https://nixos.org/releases/nixos/15.09/nixos-15.09.1012.9fe0c23/nixos-minimal-15.09.1012.9fe0c23-x86_64-linux.iso; @@ -102,7 +102,7 @@ with lib; filename = "${pkgs.writeDash "xu-qemu0-monitor" '' exec ${pkgs.socat}/bin/socat \ stdio \ - UNIX-CONNECT:${config.users.users.xu-qemu0.home}/xu-qemu0.sock \ + UNIX-CONNECT:${config.users.users.xu-qemu0.home}/tmp/xu-qemu0.sock \ ''}"; }} dst=${config.security.wrapperDir}/xu-qemu0-monitor -- cgit v1.2.3 From edd8bc21d33a631e0c9fb12e44e55b68d8f4cdf6 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 20:11:26 +0100 Subject: xu-qemu0: not wanted by multi-user.target --- tv/2configs/xu-qemu0.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix index 470b16ea4..bc108b4a2 100644 --- a/tv/2configs/xu-qemu0.nix +++ b/tv/2configs/xu-qemu0.nix @@ -68,7 +68,6 @@ with lib; systemd.services.xu-qemu0 = let in { after = [ "network.target" "systemd-resolved.service" ]; - wantedBy = [ "multi-user.target" ]; serviceConfig = { User = "xu-qemu0"; SyslogIdentifier = "xu-qemu0"; -- cgit v1.2.3 From ca246b6994950cf45aeb69e6e2e4c8f40fda7aa2 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 20:16:50 +0100 Subject: xu-qemu0: disable services.resolved --- tv/2configs/xu-qemu0.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'tv/2configs') diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix index bc108b4a2..205b1c011 100644 --- a/tv/2configs/xu-qemu0.nix +++ b/tv/2configs/xu-qemu0.nix @@ -40,6 +40,7 @@ with lib; #}; systemd.network.enable = true; + services.resolved.enable = mkForce false; systemd.network.netdevs.qemubr0 = { netdevConfig = { -- cgit v1.2.3 From 230c8088c8e96a990400533c780b035c8a4102de Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 20:55:38 +0100 Subject: xu-qemu0: setup qemubr0 address and route --- tv/2configs/xu-qemu0.nix | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix index 205b1c011..4d39031db 100644 --- a/tv/2configs/xu-qemu0.nix +++ b/tv/2configs/xu-qemu0.nix @@ -15,33 +15,31 @@ in # # make [install] system=xu-qemu0 target_host=10.56.0.101 -# TODO iptables -A INPUT -p udp -m udp --dport bootps -j ACCEPT +# TODO iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # TODO iptables -A FORWARD -i qemubr0 -s 10.56.0.1/24 -m conntrack --ctstate NEW -j ACCEPT # TODO iptables -A POSTROUTING -t nat -j MASQUERADE -# TODO iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT +# TODO iptables -A INPUT -i qemubr0 -p udp -m udp --dport bootps -j ACCEPT # TODO iptables -A INPUT -i qemubr0 -p udp -m udp --dport domain -j ACCEPT # TODO echo 1 > /proc/sys/net/ipv4/ip_forward -# TODO ifconfig qemubr0 10.56.0.1/24 up with lib; { - #networking.wireless.interfaces = [ "wlp3s0" ]; - - #networking.useNetworkd = true; - - #networking.dhcpcd.allowInterfaces = [ - # "qemubr0" - #]; - - #systemd.network.networks.wlp3s0 = { - # matchConfig.name = "wlp3s0"; - # networkConfig.Bridge = "qemubr0"; - #}; + networking.dhcpcd.denyInterfaces = [ "qemubr0" ]; systemd.network.enable = true; services.resolved.enable = mkForce false; + systemd.network.networks.qemubr0 = { + matchConfig.Name = "qemubr0"; + address = ["10.56.0.1/24"]; + routes = [{ + routeConfig = { + Gateway = "*"; + Destination = "10.56.0.0"; + }; + }]; + }; systemd.network.netdevs.qemubr0 = { netdevConfig = { Name = "qemubr0"; -- cgit v1.2.3 From 9a7b7dc5091b0af43fe9d6620f236878f93b3225 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 13 Feb 2016 20:58:27 +0100 Subject: xu-qemu0: net.ipv4.ip_forward = 1 --- tv/2configs/xu-qemu0.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix index 4d39031db..9962ca56a 100644 --- a/tv/2configs/xu-qemu0.nix +++ b/tv/2configs/xu-qemu0.nix @@ -20,7 +20,6 @@ in # TODO iptables -A POSTROUTING -t nat -j MASQUERADE # TODO iptables -A INPUT -i qemubr0 -p udp -m udp --dport bootps -j ACCEPT # TODO iptables -A INPUT -i qemubr0 -p udp -m udp --dport domain -j ACCEPT -# TODO echo 1 > /proc/sys/net/ipv4/ip_forward with lib; @@ -30,6 +29,8 @@ with lib; systemd.network.enable = true; services.resolved.enable = mkForce false; + boot.kernel.sysctl."net.ipv4.ip_forward" = 1; + systemd.network.networks.qemubr0 = { matchConfig.Name = "qemubr0"; address = ["10.56.0.1/24"]; -- cgit v1.2.3 From e890eb244af82ba678e894a84983db5057fbb60a Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 14 Feb 2016 13:26:37 +0100 Subject: krebs.setuid: init --- tv/2configs/xu-qemu0.nix | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix index 9962ca56a..df35f5c3f 100644 --- a/tv/2configs/xu-qemu0.nix +++ b/tv/2configs/xu-qemu0.nix @@ -79,7 +79,7 @@ with lib; ${pkgs.kvm}/bin/qemu-img create "$img" 10G fi exec ${pkgs.kvm}/bin/qemu-kvm \ - -monitor unix:$HOME/tmp/xu-qemu0.sock,server,nowait \ + -monitor unix:$HOME/tmp/xu-qemu0-monitor.sock,server,nowait \ -boot order=cd \ -cdrom ${pkgs.fetchurl { url = https://nixos.org/releases/nixos/15.09/nixos-15.09.1012.9fe0c23/nixos-minimal-15.09.1012.9fe0c23-x86_64-linux.iso; @@ -95,36 +95,20 @@ with lib; }; }; - system.activationScripts."krebs.setuid.xu-qemu0-monitor" = stringAfter [ "setuid" ] '' - src=${pkgs.execve "xu-qemu0-monitor" { - # TODO toC should handle derivation, then we don't have to "${...}" here - filename = "${pkgs.writeDash "xu-qemu0-monitor" '' - exec ${pkgs.socat}/bin/socat \ - stdio \ - UNIX-CONNECT:${config.users.users.xu-qemu0.home}/tmp/xu-qemu0.sock \ - ''}"; - }} - dst=${config.security.wrapperDir}/xu-qemu0-monitor - cp "$src" "$dst" - chown xu-qemu0.tv "$dst" - chmod 4710 "$dst" - ''; + krebs.setuid.xu-qemu0-monitor = { + filename = pkgs.writeDash "xu-qemu0-monitor" '' + exec ${pkgs.socat}/bin/socat \ + stdio \ + UNIX-CONNECT:${config.users.users.xu-qemu0.home}/tmp/xu-qemu0-monitor.sock \ + ''; + owner = "xu-qemu0"; + group = "tv"; + }; - #TODO krebs.setuid.qemu-bridge-helper = { - # filename = "${pkgs.qemu}/libexec/qemu-bridge-helper"; - # owner = "root"; - # group = "qemu-users"; - # mode = "4710"; - #}; - system.activationScripts."krebs.setuid" = stringAfter [ "setuid" ] '' - src=${pkgs.execve "qemu-bridge-helper" { - filename = "${pkgs.qemu}/libexec/qemu-bridge-helper"; - }} - dst=${config.security.wrapperDir}/qemu-bridge-helper - cp "$src" "$dst" - chown root.qemu-users "$dst" - chmod 4710 "$dst" - ''; + krebs.setuid.qemu-bridge-helper = { + filename = "${pkgs.qemu}/libexec/qemu-bridge-helper"; + group = "qemu-users"; + }; users.users.qemu-dnsmasq.uid = genid "qemu-dnsmasq"; -- cgit v1.2.3 From 673853e092c211e26a08030f87f9c868c6442a71 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 14 Feb 2016 16:43:44 +0100 Subject: RIP specialArgs.lib --- tv/2configs/backup.nix | 2 +- tv/2configs/charybdis.nix | 5 ++--- tv/2configs/default.nix | 2 +- tv/2configs/exim-retiolum.nix | 4 ++-- tv/2configs/exim-smarthost.nix | 2 +- tv/2configs/git.nix | 2 +- tv/2configs/hw/AO753.nix | 2 +- tv/2configs/nginx-public_html.nix | 4 ++-- tv/2configs/pulse.nix | 2 +- tv/2configs/retiolum.nix | 2 +- tv/2configs/vim.nix | 4 ++-- tv/2configs/xserver/Xresources.nix | 2 +- tv/2configs/xserver/default.nix | 2 +- tv/2configs/xserver/xserver.conf.nix | 2 +- tv/2configs/xu-qemu0.nix | 2 +- 15 files changed, 19 insertions(+), 20 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/backup.nix b/tv/2configs/backup.nix index 57f299ebd..641e2d586 100644 --- a/tv/2configs/backup.nix +++ b/tv/2configs/backup.nix @@ -1,5 +1,5 @@ { config, lib, ... }: -with lib; +with config.krebs.lib; { krebs.backup.plans = { wu-home-xu = { diff --git a/tv/2configs/charybdis.nix b/tv/2configs/charybdis.nix index f9ab3da68..eefb2810b 100644 --- a/tv/2configs/charybdis.nix +++ b/tv/2configs/charybdis.nix @@ -1,13 +1,12 @@ { config, lib, pkgs, ... }: -with builtins; -with lib; +with config.krebs.lib; let cfg = config.tv.charybdis; out = { options.tv.charybdis = api; - config = mkIf cfg.enable (mkMerge [ + config = lib.mkIf cfg.enable (lib.mkMerge [ imp { tv.iptables.input-retiolum-accept-new-tcp = [ 6667 6697 ]; } ]); diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 2edaed76d..9694e7b5b 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; { krebs.enable = true; diff --git a/tv/2configs/exim-retiolum.nix b/tv/2configs/exim-retiolum.nix index aedf25823..9197a3c30 100644 --- a/tv/2configs/exim-retiolum.nix +++ b/tv/2configs/exim-retiolum.nix @@ -1,6 +1,6 @@ -{ lib, ... }: +{ config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; { krebs.exim-retiolum.enable = true; diff --git a/tv/2configs/exim-smarthost.nix b/tv/2configs/exim-smarthost.nix index bcfea7821..4b49e20b1 100644 --- a/tv/2configs/exim-smarthost.nix +++ b/tv/2configs/exim-smarthost.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; { krebs.exim-smarthost = { diff --git a/tv/2configs/git.nix b/tv/2configs/git.nix index f248a8cb5..7a42ca9fa 100644 --- a/tv/2configs/git.nix +++ b/tv/2configs/git.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; let diff --git a/tv/2configs/hw/AO753.nix b/tv/2configs/hw/AO753.nix index e7a2b9238..b81b773be 100644 --- a/tv/2configs/hw/AO753.nix +++ b/tv/2configs/hw/AO753.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; { imports = [ diff --git a/tv/2configs/nginx-public_html.nix b/tv/2configs/nginx-public_html.nix index dc74f7f8d..15a3b5482 100644 --- a/tv/2configs/nginx-public_html.nix +++ b/tv/2configs/nginx-public_html.nix @@ -1,6 +1,6 @@ -{ lib, ... }: +{ config, lib, ... }: -with lib; +with config.krebs.lib; { krebs.nginx = { diff --git a/tv/2configs/pulse.nix b/tv/2configs/pulse.nix index e1894ca64..8e611f21e 100644 --- a/tv/2configs/pulse.nix +++ b/tv/2configs/pulse.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; let pkg = pkgs.pulseaudioLight; runDir = "/run/pulse"; diff --git a/tv/2configs/retiolum.nix b/tv/2configs/retiolum.nix index d2bb9e6cf..e1598d792 100644 --- a/tv/2configs/retiolum.nix +++ b/tv/2configs/retiolum.nix @@ -1,6 +1,6 @@ { config, lib, ... }: -with lib; +with config.krebs.lib; { krebs.retiolum = { diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 69a880dab..b0c26e50e 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -1,6 +1,6 @@ -{ lib, pkgs, ... }: +{ config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; let out = { environment.systemPackages = [ diff --git a/tv/2configs/xserver/Xresources.nix b/tv/2configs/xserver/Xresources.nix index f287bf206..923572721 100644 --- a/tv/2configs/xserver/Xresources.nix +++ b/tv/2configs/xserver/Xresources.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; pkgs.writeText "Xresources" '' !URxvt*background: #050505 diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 5cd17aa1d..4b936f473 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }@args: -with lib; +with config.krebs.lib; let # TODO krebs.build.user diff --git a/tv/2configs/xserver/xserver.conf.nix b/tv/2configs/xserver/xserver.conf.nix index e8a997a99..c452b4226 100644 --- a/tv/2configs/xserver/xserver.conf.nix +++ b/tv/2configs/xserver/xserver.conf.nix @@ -1,6 +1,6 @@ { config, lib, pkgs, ... }: -with lib; +with config.krebs.lib; let cfg = config.services.xserver; diff --git a/tv/2configs/xu-qemu0.nix b/tv/2configs/xu-qemu0.nix index df35f5c3f..720a8acd8 100644 --- a/tv/2configs/xu-qemu0.nix +++ b/tv/2configs/xu-qemu0.nix @@ -21,7 +21,7 @@ in # TODO iptables -A INPUT -i qemubr0 -p udp -m udp --dport bootps -j ACCEPT # TODO iptables -A INPUT -i qemubr0 -p udp -m udp --dport domain -j ACCEPT -with lib; +with config.krebs.lib; { networking.dhcpcd.denyInterfaces = [ "qemubr0" ]; -- cgit v1.2.3 From 8f520b19b623919fa6319029a955d43fd051773c Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 15 Feb 2016 16:27:11 +0100 Subject: don't try to mimic nixpkgs --- tv/2configs/default.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tv/2configs') diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 9694e7b5b..c4a2d6baa 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -9,12 +9,10 @@ with config.krebs.lib; user = config.krebs.users.tv; source = mapAttrs (_: mkDefault) ({ nixos-config = "symlink:stockholm/tv/1systems/${config.krebs.build.host.name}.nix"; - nixpkgs = symlink:stockholm/nixpkgs; secrets = "/home/tv/secrets/${config.krebs.build.host.name}"; secrets-common = "/home/tv/secrets/common"; stockholm = "/home/tv/stockholm"; - stockholm-user = "symlink:stockholm/tv"; - upstream-nixpkgs = { + nixpkgs = { url = https://github.com/NixOS/nixpkgs; rev = "77f8f35d57618c1ba456d968524f2fb2c3448295"; dev = "/home/tv/nixpkgs"; -- cgit v1.2.3 [cgit] Unable to lock slot /tmp/cgit/43300000.lock: No such file or directory (2)