summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-02-15 17:07:48 +0100
committermakefu <github@syntax-fehler.de>2016-02-15 17:07:48 +0100
commit34471904f61dfe59fb36e2a686b07a9436b601bf (patch)
treece2f7a874350e94f060101519d063c779e6a3293
parent0f49d7fa7202d9854b382ada864c8e9506c71ba0 (diff)
parent6e6c783a148293acdbfbfeb36c4bd0ef69b9d8ee (diff)
Merge remote-tracking branch 'cd/master'
-rw-r--r--Makefile13
-rw-r--r--miefda/1systems/bobby.nix2
-rw-r--r--miefda/2configs/git.nix2
-rw-r--r--miefda/2configs/miefda.nix2
-rw-r--r--miefda/2configs/tinc-basic-retiolum.nix2
-rw-r--r--miefda/2configs/tlp.nix2
-rw-r--r--miefda/2configs/x220t.nix2
-rw-r--r--miefda/default.nix6
-rw-r--r--mv/1systems/stro.nix3
-rw-r--r--mv/2configs/default.nix2
-rw-r--r--mv/2configs/git.nix2
-rw-r--r--mv/2configs/vim.nix4
-rw-r--r--mv/2configs/xserver/Xresources.nix2
-rw-r--r--mv/2configs/xserver/default.nix2
-rw-r--r--mv/2configs/xserver/xserver.conf.nix2
-rw-r--r--mv/3modules/iptables.nix5
-rw-r--r--nixpkgs/default.nix5
-rw-r--r--nixpkgs/krebs0
l---------nixpkgs/lib1
-rw-r--r--nixpkgs/nixos/default.nix1
l---------nixpkgs/nixos/lib1
l---------nixpkgs/nixos/modules1
l---------root1
-rw-r--r--shared/1systems/test-all-krebs-modules.nix3
-rw-r--r--shared/1systems/test-arch.nix1
-rw-r--r--shared/1systems/test-centos6.nix1
-rw-r--r--shared/1systems/test-centos7.nix1
-rw-r--r--shared/1systems/test-failing.nix3
-rw-r--r--shared/1systems/test-minimal-deploy.nix3
-rw-r--r--shared/1systems/wolf.nix1
-rw-r--r--shared/2configs/base.nix6
-rw-r--r--shared/2configs/cgit-mirror.nix2
-rw-r--r--shared/2configs/collectd-base.nix2
-rw-r--r--shared/2configs/graphite.nix2
-rw-r--r--shared/2configs/shared-buildbot.nix2
-rw-r--r--shared/default.nix7
-rw-r--r--tv/1systems/cd.nix3
-rw-r--r--tv/1systems/mkdir.nix3
-rw-r--r--tv/1systems/nomic.nix3
-rw-r--r--tv/1systems/rmdir.nix3
-rw-r--r--tv/1systems/wu.nix6
-rw-r--r--tv/1systems/xu-qemu0.nix28
-rw-r--r--tv/1systems/xu.nix8
-rw-r--r--tv/2configs/backup.nix25
-rw-r--r--tv/2configs/charybdis.nix5
-rw-r--r--tv/2configs/default.nix16
-rw-r--r--tv/2configs/exim-retiolum.nix4
-rw-r--r--tv/2configs/exim-smarthost.nix2
-rw-r--r--tv/2configs/git.nix2
-rw-r--r--tv/2configs/hw/AO753.nix2
-rw-r--r--tv/2configs/nginx-public_html.nix4
-rw-r--r--tv/2configs/pulse.nix2
-rw-r--r--tv/2configs/retiolum.nix2
-rw-r--r--tv/2configs/urlwatch.nix3
-rw-r--r--tv/2configs/vim.nix4
-rw-r--r--tv/2configs/xserver/Xresources.nix2
-rw-r--r--tv/2configs/xserver/default.nix2
-rw-r--r--tv/2configs/xserver/xserver.conf.nix2
-rw-r--r--tv/2configs/xu-qemu0.nix243
-rw-r--r--tv/3modules/ejabberd.nix5
-rw-r--r--tv/3modules/iptables.nix5
-rw-r--r--tv/default.nix9
62 files changed, 410 insertions, 80 deletions
diff --git a/Makefile b/Makefile
index f39ed0c..384c872 100644
--- a/Makefile
+++ b/Makefile
@@ -4,14 +4,16 @@ endif
export target_host ?= $(system)
export target_user ?= root
+export target_port ?= 22
export target_path ?= /var/src
evaluate = \
nix-instantiate \
- --arg configuration ./$(LOGNAME)/1systems/$(system).nix \
--eval \
--readonly-mode \
--show-trace \
+ -I nixos-config=./$(LOGNAME)/1systems/$(system).nix \
+ -I stockholm=. \
$(1)
execute = \
@@ -22,19 +24,20 @@ execute = \
# usage: make deploy system=foo [target_host=bar]
deploy:
$(call execute,populate)
- ssh $(target_user)@$(target_host) nixos-rebuild switch -I $(target_path)
+ ssh $(target_user)@$(target_host) -p $(target_port) \
+ nixos-rebuild switch --show-trace -I $(target_path)
# usage: make LOGNAME=shared system=wolf eval.config.krebs.build.host.name
eval eval.:;@$(call evaluate)
eval.%:;@$(call evaluate,-A $*)
# usage: make install system=foo [target_host=bar]
-install: ssh = ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
+install: ssh ?= ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
install:
- $(ssh) $(target_user)@$(target_host) \
+ $(ssh) $(target_user)@$(target_host) -p $(target_port) \
env target_path=$(target_path) \
sh -s prepare < krebs/4lib/infest/prepare.sh
target_path=/mnt$(target_path) $(call execute,populate)
- $(ssh) $(target_user)@$(target_host) \
+ $(ssh) $(target_user)@$(target_host) -p $(target_port) \
env NIXOS_CONFIG=$(target_path)/nixos-config \
nixos-install
diff --git a/miefda/1systems/bobby.nix b/miefda/1systems/bobby.nix
index d245952..b85e686 100644
--- a/miefda/1systems/bobby.nix
+++ b/miefda/1systems/bobby.nix
@@ -7,7 +7,7 @@
{
imports =
[ # Include the results of the hardware scan.
-
+ ../.
../2configs/miefda.nix
../2configs/tlp.nix
../2configs/x220t.nix
diff --git a/miefda/2configs/git.nix b/miefda/2configs/git.nix
index fec828f..052cc4a 100644
--- a/miefda/2configs/git.nix
+++ b/miefda/2configs/git.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
let
diff --git a/miefda/2configs/miefda.nix b/miefda/2configs/miefda.nix
index 545987a..f17e8aa 100644
--- a/miefda/2configs/miefda.nix
+++ b/miefda/2configs/miefda.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
#networking.wicd.enable = true;
diff --git a/miefda/2configs/tinc-basic-retiolum.nix b/miefda/2configs/tinc-basic-retiolum.nix
index b31fe15..f82fd6b 100644
--- a/miefda/2configs/tinc-basic-retiolum.nix
+++ b/miefda/2configs/tinc-basic-retiolum.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
krebs.retiolum = {
enable = true;
diff --git a/miefda/2configs/tlp.nix b/miefda/2configs/tlp.nix
index 0e1bb0d..32f4f2e 100644
--- a/miefda/2configs/tlp.nix
+++ b/miefda/2configs/tlp.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
hardware.enableAllFirmware = true;
nixpkgs.config.allowUnfree = true;
diff --git a/miefda/2configs/x220t.nix b/miefda/2configs/x220t.nix
index bea84f7..2d128e5 100644
--- a/miefda/2configs/x220t.nix
+++ b/miefda/2configs/x220t.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
services.xserver = {
diff --git a/miefda/default.nix b/miefda/default.nix
new file mode 100644
index 0000000..7f275c2
--- /dev/null
+++ b/miefda/default.nix
@@ -0,0 +1,6 @@
+_:
+{
+ imports = [
+ ../krebs
+ ];
+}
diff --git a/mv/1systems/stro.nix b/mv/1systems/stro.nix
index 3915219..f251cb0 100644
--- a/mv/1systems/stro.nix
+++ b/mv/1systems/stro.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
krebs.build.host = config.krebs.hosts.stro;
@@ -9,6 +9,7 @@ with lib;
"7ae05edcdd14f6ace83ead9bf0d114e97c89a83a";
imports = [
+ ../.
../2configs/hw/x220.nix
../2configs/git.nix
../2configs/mail-client.nix
diff --git a/mv/2configs/default.nix b/mv/2configs/default.nix
index 9c41209..d93218a 100644
--- a/mv/2configs/default.nix
+++ b/mv/2configs/default.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
let
HOME = getEnv "HOME";
in
diff --git a/mv/2configs/git.nix b/mv/2configs/git.nix
index c182d0d..933649f 100644
--- a/mv/2configs/git.nix
+++ b/mv/2configs/git.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
let
diff --git a/mv/2configs/vim.nix b/mv/2configs/vim.nix
index a961b6b..adf1da9 100644
--- a/mv/2configs/vim.nix
+++ b/mv/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/mv/2configs/xserver/Xresources.nix b/mv/2configs/xserver/Xresources.nix
index f287bf2..9235727 100644
--- a/mv/2configs/xserver/Xresources.nix
+++ b/mv/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/mv/2configs/xserver/default.nix b/mv/2configs/xserver/default.nix
index 44539c5..3d4aa88 100644
--- a/mv/2configs/xserver/default.nix
+++ b/mv/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/mv/2configs/xserver/xserver.conf.nix b/mv/2configs/xserver/xserver.conf.nix
index e8a997a..c452b42 100644
--- a/mv/2configs/xserver/xserver.conf.nix
+++ b/mv/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/mv/3modules/iptables.nix b/mv/3modules/iptables.nix
index cbf49f5..b2b41bf 100644
--- a/mv/3modules/iptables.nix
+++ b/mv/3modules/iptables.nix
@@ -1,13 +1,12 @@
{ config, lib, pkgs, ... }:
-with builtins;
-with lib;
+with config.krebs.lib;
let
cfg = config.tv.iptables;
out = {
options.tv.iptables = api;
- config = mkIf cfg.enable imp;
+ config = lib.mkIf cfg.enable imp;
};
api = {
diff --git a/nixpkgs/default.nix b/nixpkgs/default.nix
deleted file mode 100644
index 1fe99b0..0000000
--- a/nixpkgs/default.nix
+++ /dev/null
@@ -1,5 +0,0 @@
-_:
-
-(import <stockholm> {
- configuration = {};
-}).pkgs
diff --git a/nixpkgs/krebs b/nixpkgs/krebs
deleted file mode 100644
index e69de29..0000000
--- a/nixpkgs/krebs
+++ /dev/null
diff --git a/nixpkgs/lib b/nixpkgs/lib
deleted file mode 120000
index 7b13c80..0000000
--- a/nixpkgs/lib
+++ /dev/null
@@ -1 +0,0 @@
-../../upstream-nixpkgs/lib \ No newline at end of file
diff --git a/nixpkgs/nixos/default.nix b/nixpkgs/nixos/default.nix
deleted file mode 100644
index 4fe08ef..0000000
--- a/nixpkgs/nixos/default.nix
+++ /dev/null
@@ -1 +0,0 @@
-import <stockholm>
diff --git a/nixpkgs/nixos/lib b/nixpkgs/nixos/lib
deleted file mode 120000
index 9e69d1a..0000000
--- a/nixpkgs/nixos/lib
+++ /dev/null
@@ -1 +0,0 @@
-../../../upstream-nixpkgs/nixos/lib \ No newline at end of file
diff --git a/nixpkgs/nixos/modules b/nixpkgs/nixos/modules
deleted file mode 120000
index 8aa2488..0000000
--- a/nixpkgs/nixos/modules
+++ /dev/null
@@ -1 +0,0 @@
-../../../upstream-nixpkgs/nixos/modules \ No newline at end of file
diff --git a/root b/root
deleted file mode 120000
index 1cd1825..0000000
--- a/root
+++ /dev/null
@@ -1 +0,0 @@
-../stockholm-user \ No newline at end of file
diff --git a/shared/1systems/test-all-krebs-modules.nix b/shared/1systems/test-all-krebs-modules.nix
index b98004d..e1021c7 100644
--- a/shared/1systems/test-all-krebs-modules.nix
+++ b/shared/1systems/test-all-krebs-modules.nix
@@ -2,6 +2,9 @@
let
en = { enable = true;};
in {
+ imports = [
+ ../.
+ ];
krebs = {
enable = true;
build.user = config.krebs.users.shared;
diff --git a/shared/1systems/test-arch.nix b/shared/1systems/test-arch.nix
index ece2094..14fc038 100644
--- a/shared/1systems/test-arch.nix
+++ b/shared/1systems/test-arch.nix
@@ -2,6 +2,7 @@
{
imports = [
+ ../.
../2configs/base.nix
{
boot.loader.grub = {
diff --git a/shared/1systems/test-centos6.nix b/shared/1systems/test-centos6.nix
index a8b5f9b..8add0b7 100644
--- a/shared/1systems/test-centos6.nix
+++ b/shared/1systems/test-centos6.nix
@@ -7,6 +7,7 @@ let
gw = "168.235.148.1";
in {
imports = [
+ ../.
../2configs/base.nix
../2configs/os-templates/CAC-CentOS-6.5-64bit.nix
{
diff --git a/shared/1systems/test-centos7.nix b/shared/1systems/test-centos7.nix
index 48cecc8..65daff5 100644
--- a/shared/1systems/test-centos7.nix
+++ b/shared/1systems/test-centos7.nix
@@ -5,6 +5,7 @@ let
in {
imports = [
+ ../.
../2configs/base.nix
../2configs/os-templates/CAC-CentOS-7-64bit.nix
../2configs/temp/networking.nix
diff --git a/shared/1systems/test-failing.nix b/shared/1systems/test-failing.nix
index 81a9e48..fe1c2cb 100644
--- a/shared/1systems/test-failing.nix
+++ b/shared/1systems/test-failing.nix
@@ -1,6 +1,9 @@
{ config, pkgs, ... }:
{
+ imports = [
+ ../.
+ ];
programs.ssh.startAgent = true;
programs.ssh.startAgent = false;
}
diff --git a/shared/1systems/test-minimal-deploy.nix b/shared/1systems/test-minimal-deploy.nix
index 309e289..bec2b38 100644
--- a/shared/1systems/test-minimal-deploy.nix
+++ b/shared/1systems/test-minimal-deploy.nix
@@ -1,5 +1,8 @@
{ config, pkgs, lib, ... }:
{
+ imports = [
+ ../.
+ ];
krebs = {
enable = true;
build.user = config.krebs.users.shared;
diff --git a/shared/1systems/wolf.nix b/shared/1systems/wolf.nix
index 588ec1b..96691ae 100644
--- a/shared/1systems/wolf.nix
+++ b/shared/1systems/wolf.nix
@@ -6,6 +6,7 @@ let
in
{
imports = [
+ ../.
../2configs/base.nix
<nixpkgs/nixos/modules/profiles/qemu-guest.nix>
../2configs/collectd-base.nix
diff --git a/shared/2configs/base.nix b/shared/2configs/base.nix
index 715397e..9f998b5 100644
--- a/shared/2configs/base.nix
+++ b/shared/2configs/base.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
krebs.enable = true;
krebs.retiolum = {
@@ -16,7 +16,7 @@ with lib;
# TODO rename shared user to "krebs"
krebs.build.user = mkDefault config.krebs.users.shared;
krebs.build.source = {
- upstream-nixpkgs = mkDefault {
+ nixpkgs = mkDefault {
url = https://github.com/NixOS/nixpkgs;
rev = "77f8f35d57618c1ba456d968524f2fb2c3448295"; # for urlwatch-minidb
};
@@ -24,8 +24,6 @@ with lib;
stockholm = mkDefault "${getEnv "HOME"}/stockholm";
nixos-config = "symlink:stockholm/${config.krebs.build.user.name}/1systems/${config.krebs.build.host.name}.nix";
- nixpkgs = symlink:stockholm/nixpkgs;
- stockholm-user = "symlink:stockholm/${config.krebs.build.user.name}";
};
networking.hostName = config.krebs.build.host.name;
diff --git a/shared/2configs/cgit-mirror.nix b/shared/2configs/cgit-mirror.nix
index 0794ee4..b984535 100644
--- a/shared/2configs/cgit-mirror.nix
+++ b/shared/2configs/cgit-mirror.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
let
rules = with git; singleton {
user = [ wolf-repo-sync ];
diff --git a/shared/2configs/collectd-base.nix b/shared/2configs/collectd-base.nix
index 3b792bf..9c63dcd 100644
--- a/shared/2configs/collectd-base.nix
+++ b/shared/2configs/collectd-base.nix
@@ -1,7 +1,7 @@
{ config, lib, pkgs, ... }:
# TODO: krebs.collectd.plugins
-with lib;
+with config.krebs.lib;
let
connect-time-cfg = with pkgs; writeText "collectd-connect-time.conf" ''
LoadPlugin python
diff --git a/shared/2configs/graphite.nix b/shared/2configs/graphite.nix
index 707ec6e..37c6b09 100644
--- a/shared/2configs/graphite.nix
+++ b/shared/2configs/graphite.nix
@@ -5,7 +5,7 @@
# TODO: krebs.graphite.minimal.enable
# TODO: configure firewall
-with lib;
+with config.krebs.lib;
{
imports = [ ];
diff --git a/shared/2configs/shared-buildbot.nix b/shared/2configs/shared-buildbot.nix
index 19724ac..ebf5f4a 100644
--- a/shared/2configs/shared-buildbot.nix
+++ b/shared/2configs/shared-buildbot.nix
@@ -64,7 +64,7 @@
# prepare nix-shell
# the dependencies which are used by the test script
deps = [ "gnumake", "jq","nix","rsync",
- "(import <stockholm> {}).pkgs.test.infest-cac-centos7" ]
+ "(import <stockholm>).pkgs.test.infest-cac-centos7" ]
# TODO: --pure , prepare ENV in nix-shell command:
# SSL_CERT_FILE,LOGNAME,NIX_REMOTE
nixshell = ["nix-shell",
diff --git a/shared/default.nix b/shared/default.nix
new file mode 100644
index 0000000..69b4aba
--- /dev/null
+++ b/shared/default.nix
@@ -0,0 +1,7 @@
+_:
+{
+ imports = [
+ ../krebs
+ ./3modules
+ ];
+}
diff --git a/tv/1systems/cd.nix b/tv/1systems/cd.nix
index b96548d..9b63826 100644
--- a/tv/1systems/cd.nix
+++ b/tv/1systems/cd.nix
@@ -1,11 +1,12 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
krebs.build.host = config.krebs.hosts.cd;
imports = [
+ ../.
../2configs/hw/CAC-Developer-2.nix
../2configs/fs/CAC-CentOS-7-64bit.nix
../2configs/exim-smarthost.nix
diff --git a/tv/1systems/mkdir.nix b/tv/1systems/mkdir.nix
index 2010dcd..58a8fdc 100644
--- a/tv/1systems/mkdir.nix
+++ b/tv/1systems/mkdir.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
let
# TODO merge with lass
@@ -19,6 +19,7 @@ in
krebs.build.host = config.krebs.hosts.mkdir;
imports = [
+ ../.
../2configs/hw/CAC-Developer-1.nix
../2configs/fs/CAC-CentOS-7-64bit.nix
../2configs/exim-smarthost.nix
diff --git a/tv/1systems/nomic.nix b/tv/1systems/nomic.nix
index 37ef204..2c9775d 100644
--- a/tv/1systems/nomic.nix
+++ b/tv/1systems/nomic.nix
@@ -1,11 +1,12 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
krebs.build.host = config.krebs.hosts.nomic;
imports = [
+ ../.
../2configs/hw/AO753.nix
../2configs/exim-retiolum.nix
../2configs/git.nix
diff --git a/tv/1systems/rmdir.nix b/tv/1systems/rmdir.nix
index 4005b5e..c54caa6 100644
--- a/tv/1systems/rmdir.nix
+++ b/tv/1systems/rmdir.nix
@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
let
# TODO merge with lass
@@ -19,6 +19,7 @@ in
krebs.build.host = config.krebs.hosts.rmdir;
imports = [
+ ../.
../2configs/hw/CAC-Developer-1.nix
../2configs/fs/CAC-CentOS-7-64bit.nix
../2configs/exim-smarthost.nix
diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix
index 4ed13a0..6154e4d 100644
--- a/tv/1systems/wu.nix
+++ b/tv/1systems/wu.nix
@@ -1,11 +1,12 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
krebs.build.host = config.krebs.hosts.wu;
imports = [
+ ../.
../2configs/hw/w110er.nix
../2configs/exim-retiolum.nix
../2configs/git.nix
@@ -191,8 +192,6 @@ with lib;
"d /tmp 1777 root root - -" # does this work with mounted /tmp?
];
- virtualisation.libvirtd.enable = true;
-
services.udev.extraRules = ''
SUBSYSTEM=="net", ATTR{address}=="00:90:f5:da:aa:c3", NAME="en0"
SUBSYSTEM=="net", ATTR{address}=="a0:88:b4:1b:ae:6c", NAME="wl0"
@@ -211,5 +210,4 @@ with lib;
services.tor.client.enable = true;
services.tor.enable = true;
services.virtualboxHost.enable = true;
-
}
diff --git a/tv/1systems/xu-qemu0.nix b/tv/1systems/xu-qemu0.nix
new file mode 100644
index 0000000..8945c19
--- /dev/null
+++ b/tv/1systems/xu-qemu0.nix
@@ -0,0 +1,28 @@
+{ config, lib, pkgs, ... }:
+
+{
+ krebs.hosts.xu-qemu0 = {
+ cores = 1;
+ ssh.privkey.path = <secrets/ssh.id_ed25519>;
+ # cannot define ssh.pubkey without at least one addr or alias
+ #ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFe51rD0ZqlMXNi/YpapnRzvdzCjI0icmxfCyBLSKG04";
+ };
+ krebs.build.host = config.krebs.hosts.xu-qemu0;
+
+ imports = [
+ ../.
+ <nixpkgs/nixos/modules/profiles/qemu-guest.nix>
+ ];
+
+ boot.loader.grub.device = "/dev/sda";
+
+ fileSystems = {
+ "/boot" = {
+ device = "/dev/sda1";
+ };
+ "/" = {
+ device = "/dev/sda2";
+ fsType = "btrfs";
+ };
+ };
+}
diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix
index 8c4af2b..5ec1fe5 100644
--- a/tv/1systems/xu.nix
+++ b/tv/1systems/xu.nix
@@ -1,11 +1,12 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
{
krebs.build.host = config.krebs.hosts.xu;
imports = [
+ ../.
../2configs/hw/x220.nix
../2configs/exim-retiolum.nix
../2configs/git.nix
@@ -14,6 +15,7 @@ with lib;
../2configs/pulse.nix
../2configs/retiolum.nix
../2configs/xserver
+ ../2configs/xu-qemu0.nix
{
environment.systemPackages = with pkgs; [
@@ -43,7 +45,7 @@ with lib;
# tv
bc
bind # dig
- #cac
+ cac-api
dic
file
gnupg21
@@ -189,8 +191,6 @@ with lib;
"d /tmp 1777 root root - -" # does this work with mounted /tmp?
];
- #virtualisation.libvirtd.enable = true;
-
#services.bitlbee.enable = true;
#services.tor.client.enable = true;
#services.tor.enable = true;
diff --git a/tv/2configs/backup.nix b/tv/2configs/backup.nix
index 6c90709..641e2d5 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 = {
@@ -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"; };
+ };
};
}
diff --git a/tv/2configs/charybdis.nix b/tv/2configs/charybdis.nix
index f9ab3da..eefb281 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 b5639af..c4a2d6b 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;
@@ -9,12 +9,10 @@ with 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";
@@ -44,6 +42,7 @@ with lib;
tv = {
isNormalUser = true;
uid = 1337;
+ extraGroups = [ "tv" ];
};
};
};
@@ -184,6 +183,15 @@ with lib;
];
}
{
+ environment.systemPackages = [
+ pkgs.get
+ pkgs.krebszones
+ pkgs.nix-prefetch-scripts
+ pkgs.push
+ ];
+ }
+
+ {
systemd.tmpfiles.rules = let
forUsers = flip map users;
isUser = { name, group, ... }:
diff --git a/tv/2configs/exim-retiolum.nix b/tv/2configs/exim-retiolum.nix
index aedf258..9197a3c 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 bcfea78..4b49e20 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 f248a8c..7a42ca9 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 e7a2b92..b81b773 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 dc74f7f..15a3b54 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 e1894ca..8e611f2 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 d2bb9e6..e1598d7 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/urlwatch.nix b/tv/2configs/urlwatch.nix
index 8189f63..0106cdd 100644
--- a/tv/2configs/urlwatch.nix
+++ b/tv/2configs/urlwatch.nix
@@ -51,6 +51,9 @@
# <stockholm/tv/2configs/xserver/xserver.conf.nix>
# 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
];
};
}
diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix
index 69a880d..b0c26e5 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 f287bf2..9235727 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 5cd17aa..4b936f4 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 e8a997a..c452b42 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
new file mode 100644
index 0000000..720a8ac
--- /dev/null
+++ b/tv/2configs/xu-qemu0.nix
@@ -0,0 +1,243 @@
+{ 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:
+# echo set_password vnc correcthorze | xu-qemu0-monitor
+#
+# 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
+
+# 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 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 config.krebs.lib;
+
+{
+ networking.dhcpcd.denyInterfaces = [ "qemubr0" ];
+
+ 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"];
+ routes = [{
+ routeConfig = {
+ Gateway = "*";
+ Destination = "10.56.0.0";
+ };
+ }];
+ };
+ systemd.network.netdevs.qemubr0 = {
+ netdevConfig = {
+ Name = "qemubr0";
+ Kind = "bridge";
+ };
+ };
+
+ users.groups.qemu-users.gid = genid "qemu-users";
+
+ environment.etc."qemu/bridge.conf".text = ''
+ allow qemubr0
+ '';
+
+ krebs.per-user.tv.packages = [
+ pkgs.vncdotool
+ ];
+
+ 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" ];
+ serviceConfig = {
+ User = "xu-qemu0";
+ 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.kvm}/bin/qemu-img create "$img" 10G
+ fi
+ exec ${pkgs.kvm}/bin/qemu-kvm \
+ -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;
+ 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 \
+ '';
+ };
+ };
+
+ 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";
+ };
+
+ krebs.setuid.qemu-bridge-helper = {
+ filename = "${pkgs.qemu}/libexec/qemu-bridge-helper";
+ group = "qemu-users";
+ };
+
+ 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};
+ '');
+ };
+}
diff --git a/tv/3modules/ejabberd.nix b/tv/3modules/ejabberd.nix
index 581e100..c9d9b48 100644
--- a/tv/3modules/ejabberd.nix
+++ b/tv/3modules/ejabberd.nix
@@ -1,13 +1,12 @@
{ config, lib, pkgs, ... }:
-with builtins;
-with lib;
+with config.krebs.lib;
let
cfg = config.tv.ejabberd;
out = {
options.tv.ejabberd = api;
- config = mkIf cfg.enable imp;
+ config = lib.mkIf cfg.enable imp;
};
api = {
diff --git a/tv/3modules/iptables.nix b/tv/3modules/iptables.nix
index 4924db4..c0fd7ec 100644
--- a/tv/3modules/iptables.nix
+++ b/tv/3modules/iptables.nix
@@ -1,13 +1,12 @@
{ config, lib, pkgs, ... }:
-with builtins;
-with lib;
+with config.krebs.lib;
let
cfg = config.tv.iptables;
out = {
options.tv.iptables = api;
- config = mkIf cfg.enable imp;
+ config = lib.mkIf cfg.enable imp;
};
api = {
diff --git a/tv/default.nix b/tv/default.nix
new file mode 100644
index 0000000..b1c7c1b
--- /dev/null
+++ b/tv/default.nix
@@ -0,0 +1,9 @@
+_:
+{
+ imports = [
+ ../krebs
+ ./2configs
+ ./3modules
+ ./5pkgs
+ ];
+}