diff options
-rw-r--r-- | ci.nix | 21 | ||||
-rw-r--r-- | krebs/2configs/reaktor-krebs.nix | 1 | ||||
-rw-r--r-- | krebs/2configs/reaktor-retiolum.nix | 1 | ||||
-rw-r--r-- | krebs/2configs/repo-sync.nix | 1 | ||||
-rw-r--r-- | krebs/3modules/ci.nix | 162 | ||||
-rw-r--r-- | krebs/3modules/default.nix | 1 | ||||
-rw-r--r-- | krebs/5pkgs/simple/Reaktor/plugins.nix | 9 | ||||
-rw-r--r-- | krebs/5pkgs/simple/krebspage/default.nix | 6 | ||||
-rw-r--r-- | lass/1systems/mors/config.nix | 2 | ||||
-rw-r--r-- | lass/1systems/prism/config.nix | 1 | ||||
-rw-r--r-- | lass/2configs/exim-smarthost.nix | 2 | ||||
-rw-r--r-- | lass/2configs/git.nix | 64 | ||||
-rw-r--r-- | lass/2configs/mail.nix | 11 | ||||
-rw-r--r-- | lass/2configs/repo-sync.nix | 144 | ||||
-rw-r--r-- | lass/2configs/websites/lassulus.nix | 4 | ||||
-rw-r--r-- | makefu/krops.nix | 2 |
16 files changed, 256 insertions, 176 deletions
@@ -0,0 +1,21 @@ +# usage: nix-instantiate --eval --strict --json ./ci.nix +with import ./lib; +let + pkgs = import <nixpkgs> { overlays = [ (import ./submodules/nix-writers/pkgs) ]; }; + system = + import <nixpkgs/nixos/lib/eval-config.nix> { + modules = [{ + imports = [ + ./krebs + ./krebs/2configs + ]; + }]; + } + ; + + ci-systems = filterAttrs (_: v: v.ci) system.config.krebs.hosts; + + build = host: owner: + ((import (toString ./. + "/${owner}/krops.nix") { name = host; }).test {target = "${getEnv "HOME"}/stockholm-build";}); + +in mapAttrs (n: h: build n h.owner.name) ci-systems diff --git a/krebs/2configs/reaktor-krebs.nix b/krebs/2configs/reaktor-krebs.nix index 2e63f1385..ba3715161 100644 --- a/krebs/2configs/reaktor-krebs.nix +++ b/krebs/2configs/reaktor-krebs.nix @@ -15,6 +15,7 @@ with import <stockholm/lib>; sed-plugin task-add task-delete + task-done task-list ] ++ (attrValues (todo "agenda")) diff --git a/krebs/2configs/reaktor-retiolum.nix b/krebs/2configs/reaktor-retiolum.nix index d5f1851e3..90573ca1c 100644 --- a/krebs/2configs/reaktor-retiolum.nix +++ b/krebs/2configs/reaktor-retiolum.nix @@ -12,6 +12,7 @@ with import <stockholm/lib>; sed-plugin task-add task-delete + task-done task-list ] ++ (attrValues (todo "agenda")) diff --git a/krebs/2configs/repo-sync.nix b/krebs/2configs/repo-sync.nix index 3ca94fc1b..392e6bed3 100644 --- a/krebs/2configs/repo-sync.nix +++ b/krebs/2configs/repo-sync.nix @@ -143,6 +143,7 @@ in { (sync-retiolum { name = "cholerab"; desc = "krebs thesauron & enterprise-patterns"; section = "documentation"; }) + (sync-retiolum { name = "buildbot-classic"; desc = "fork of buildbot"; section = "software"; }) (sync-retiolum { name = "disko"; desc = "take a description of your disk layout and produce a format script"; section = "software"; }) (sync-retiolum { name = "news"; desc = "take a rss feed and a timeout and print it to stdout"; section = "software"; }) (sync-retiolum { name = "krops"; desc = "krebs ops"; section = "software"; }) diff --git a/krebs/3modules/ci.nix b/krebs/3modules/ci.nix new file mode 100644 index 000000000..cf82401d3 --- /dev/null +++ b/krebs/3modules/ci.nix @@ -0,0 +1,162 @@ +{ config, lib, pkgs, ... }: + +with import <stockholm/lib>; + +let + cfg = config.krebs.ci; + + out = { + options.krebs.ci = api; + config = lib.mkIf cfg.enable imp; + }; + + api = { + enable = mkEnableOption "Enable krebs ci service"; + repos = mkOption { + type = types.attrsOf (types.submodule ({ config, ...}: { + options = { + urls = mkOption { + type = types.listOf types.str; + default = [ "git@localhost:${config._module.args.name}" ]; + }; + }; + })); + }; + }; + + hostname = config.networking.hostName; + getJobs = pkgs.writeDash "get_jobs" '' + nix-build --no-out-link ./ci.nix 2>&1 > /dev/null + nix-instantiate --eval --strict --json ./ci.nix + ''; + + imp = { + krebs.buildbot.master = { + slaves = { + testslave = "lasspass"; + }; + + change_source = mapAttrs' (name: repo: + nameValuePair name (concatMapStrings (url: '' + cs.append( + changes.GitPoller( + "${url}", + workdir='${name}-${elemAt(splitString "." url) 1}', branches=True, + project='${name}', + pollinterval=10 + ) + ) + '') repo.urls) + ) cfg.repos; + + scheduler = mapAttrs' (name: repo: + nameValuePair name '' + sched.append( + schedulers.SingleBranchScheduler( + change_filter=util.ChangeFilter(branch_re=".*"), + treeStableTimer=60, + name="build-all-branches", + builderNames=[ + "${name}", + ] + ) + ) + sched.append( + schedulers.ForceScheduler( + name="${name}", + builderNames=[ + "${name}", + ] + ) + ) + '' + ) cfg.repos; + builder_pre = '' + from buildbot import interfaces + from buildbot.steps.shell import ShellCommand + + class StepToStartMoreSteps(ShellCommand): + def __init__(self, **kwargs): + ShellCommand.__init__(self, **kwargs) + + def addBuildSteps(self, steps_factories): + for sf in steps_factories: + step = interfaces.IBuildStepFactory(sf).buildStep() + step.setBuild(self.build) + step.setBuildSlave(self.build.slavebuilder.slave) + step_status = self.build.build_status.addStepWithName(step.name) + step.setStepStatus(step_status) + self.build.steps.append(step) + + def start(self): + props = self.build.getProperties() + new_steps = json.loads(props.getProperty('steps_json')) + for new_step in new_steps: + self.addBuildSteps([steps.ShellCommand( + name=str(new_step), + command=[ + new_steps[new_step] + ], + timeout=90001, + workdir='build', # TODO figure out why we need this? + )]) + + ShellCommand.start(self) + + ''; + + builder = mapAttrs' (name: repo: + nameValuePair name '' + f_${name} = util.BuildFactory() + f_${name}.addStep(steps.Git( + repourl=util.Property('repository', '${head repo.urls}'), + mode='full', + submodules=True, + )) + + f_${name}.addStep(steps.SetPropertyFromCommand( + env={ + "NIX_REMOTE": "daemon", + "NIX_PATH": "secrets=/var/src/stockholm/null:/var/src", + }, + name="get_steps", + command=["${getJobs}"], + property="steps_json" + )) + f_${name}.addStep(StepToStartMoreSteps(command=["echo"])) # TODO remove dummy command from here + + bu.append( + util.BuilderConfig( + name="${name}", + slavenames=slavenames, + factory=f_${name} + ) + ) + '' + ) cfg.repos; + + enable = true; + web.enable = true; + irc = { + enable = true; + nick = "build|${hostname}"; + server = "irc.r"; + channels = [ "noise" ]; + allowForce = true; + }; + extraConfig = '' + c['buildbotURL'] = "http://build.${hostname}.r/" + ''; + }; + + krebs.buildbot.slave = { + enable = true; + masterhost = "localhost"; + username = "testslave"; + password = "lasspass"; + packages = with pkgs; [ gnumake jq nix populate gnutar lzma gzip ]; + }; + }; + +in out + diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 6328fe8f1..82ae3b02e 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -13,6 +13,7 @@ let ./buildbot/master.nix ./buildbot/slave.nix ./build.nix + ./ci.nix ./current.nix ./exim.nix ./exim-retiolum.nix diff --git a/krebs/5pkgs/simple/Reaktor/plugins.nix b/krebs/5pkgs/simple/Reaktor/plugins.nix index c6e601475..92a270ef3 100644 --- a/krebs/5pkgs/simple/Reaktor/plugins.nix +++ b/krebs/5pkgs/simple/Reaktor/plugins.nix @@ -160,7 +160,7 @@ rec { task-list = buildSimpleReaktorPlugin "task-list" { pattern = "^task-list"; script = pkgs.writeDash "task-list" '' - ${pkgs.taskwarrior}/bin/task rc:${taskrcFile} list + ${pkgs.taskwarrior}/bin/task rc:${taskrcFile} export | ${pkgs.jq}/bin/jq -r '.[] | select(.id != 0) | "\(.id) \(.description)"' ''; }; @@ -171,6 +171,13 @@ rec { ''; }; + task-done = buildSimpleReaktorPlugin "task-done" { + pattern = "^task-done: (?P<args>.*)$$"; + script = pkgs.writeDash "task-done" '' + ${pkgs.taskwarrior}/bin/task rc:${taskrcFile} done "$*" + ''; + }; + todo = name: { add = buildSimpleReaktorPlugin "${name}-add" { pattern = "^${name}-add: (?P<args>.*)$$"; diff --git a/krebs/5pkgs/simple/krebspage/default.nix b/krebs/5pkgs/simple/krebspage/default.nix new file mode 100644 index 000000000..f9a446f43 --- /dev/null +++ b/krebs/5pkgs/simple/krebspage/default.nix @@ -0,0 +1,6 @@ +{ fetchgit }: +fetchgit { + url = "https://cgit.lassul.us/krebspage"; + rev = "8711780cef004e19a273a5149677869751cd06dc"; + sha256 = "0131vqrkcw140d7j94bvajkhlwi99kpikb8sy2bi1hgh8ziqplsm"; +} diff --git a/lass/1systems/mors/config.nix b/lass/1systems/mors/config.nix index 5a9c26b9d..69954a3e9 100644 --- a/lass/1systems/mors/config.nix +++ b/lass/1systems/mors/config.nix @@ -21,7 +21,6 @@ with import <stockholm/lib>; <stockholm/lass/2configs/virtualbox.nix> <stockholm/lass/2configs/fetchWallpaper.nix> <stockholm/lass/2configs/mail.nix> - <stockholm/lass/2configs/repo-sync.nix> <stockholm/krebs/2configs/ircd.nix> <stockholm/lass/2configs/logf.nix> <stockholm/lass/2configs/syncthing.nix> @@ -77,6 +76,7 @@ with import <stockholm/lib>; { environment.systemPackages = [ pkgs.ovh-zone + pkgs.bank ]; } { diff --git a/lass/1systems/prism/config.nix b/lass/1systems/prism/config.nix index 0f20d1c4e..f83721070 100644 --- a/lass/1systems/prism/config.nix +++ b/lass/1systems/prism/config.nix @@ -133,7 +133,6 @@ with import <stockholm/lib>; <stockholm/lass/2configs/ts3.nix> <stockholm/lass/2configs/privoxy-retiolum.nix> <stockholm/lass/2configs/radio.nix> - <stockholm/lass/2configs/repo-sync.nix> <stockholm/lass/2configs/binary-cache/server.nix> <stockholm/lass/2configs/iodined.nix> <stockholm/lass/2configs/paste.nix> diff --git a/lass/2configs/exim-smarthost.nix b/lass/2configs/exim-smarthost.nix index 191e25831..846000a3a 100644 --- a/lass/2configs/exim-smarthost.nix +++ b/lass/2configs/exim-smarthost.nix @@ -87,6 +87,8 @@ with import <stockholm/lib>; { from = "hackbeach@lassul.us"; to = lass.mail; } { from = "transferwise@lassul.us"; to = lass.mail; } { from = "cis@lassul.us"; to = lass.mail; } + { from = "afra@lassul.us"; to = lass.mail; } + { from = "ksp@lassul.us"; to = lass.mail; } ]; system-aliases = [ { from = "mailer-daemon"; to = "postmaster"; } diff --git a/lass/2configs/git.nix b/lass/2configs/git.nix index caa7c3065..300637ff8 100644 --- a/lass/2configs/git.nix +++ b/lass/2configs/git.nix @@ -23,6 +23,10 @@ let ]; }; + cgit-clear-cache = pkgs.cgit-clear-cache.override { + inherit (config.krebs.git.cgit.settings) cache-root; + }; + repos = public-repos // optionalAttrs config.krebs.build.host.secure restricted-repos; @@ -30,6 +34,10 @@ let rules = concatMap make-rules (attrValues repos); public-repos = mapAttrs make-public-repo { + buildbot-classic = { + cgit.desc = "fork of buildbot"; + cgit.section = "software"; + }; cholerab = { cgit.desc = "krebs thesauron & enterprise-patterns"; cgit.section = "documentation"; @@ -100,17 +108,20 @@ let inherit cgit collaborators name; public = true; hooks = { - post-receive = pkgs.git-hooks.irc-announce { - # TODO make nick = config.krebs.build.host.name the default - nick = config.krebs.build.host.name; - channel = "#xxx"; - # TODO define refs in some kind of option per repo - refs = [ - "refs/heads/master" - ]; - server = "irc.r"; - verbose = config.krebs.build.host.name == "prism"; - }; + post-receive = '' + ${pkgs.git-hooks.irc-announce { + # TODO make nick = config.krebs.build.host.name the default + nick = config.krebs.build.host.name; + channel = "#xxx"; + # TODO define refs in some kind of option per repo + refs = [ + "refs/heads/master" + ]; + server = "irc.r"; + verbose = config.krebs.build.host.name == "prism"; + }} + ${cgit-clear-cache}/bin/cgit-clear-cache + ''; }; }; @@ -122,19 +133,22 @@ let make-restricted-repo = name: { admins ? [], collaborators ? [], announce ? false, hooks ? {}, ... }: { inherit admins collaborators name; public = false; - hooks = optionalAttrs announce { - post-receive = pkgs.git-hooks.irc-announce { - # TODO make nick = config.krebs.build.host.name the default - nick = config.krebs.build.host.name; - channel = "#xxx"; - # TODO define refs in some kind of option per repo - refs = [ - "refs/heads/master" - "refs/heads/staging*" - ]; - server = "irc.r"; - verbose = false; - }; + hooks = { + post-receive = '' + ${optionalString announce (pkgs.git-hooks.irc-announce { + # TODO make nick = config.krebs.build.host.name the default + nick = config.krebs.build.host.name; + channel = "#xxx"; + # TODO define refs in some kind of option per repo + refs = [ + "refs/heads/master" + "refs/heads/staging*" + ]; + server = "irc.r"; + verbose = false; + })} + ${cgit-clear-cache}/bin/cgit-clear-cache + ''; } // hooks; }; @@ -142,7 +156,7 @@ let with git // config.krebs.users; repo: singleton { - user = [ lass-mors lass-shodan lass-icarus lass-blue ]; + user = [ lass lass-mors lass-shodan lass-icarus lass-blue ]; repo = [ repo ]; perm = push "refs/*" [ non-fast-forward create delete merge ]; } ++ diff --git a/lass/2configs/mail.nix b/lass/2configs/mail.nix index 2bb51b50a..9246abfed 100644 --- a/lass/2configs/mail.nix +++ b/lass/2configs/mail.nix @@ -176,6 +176,11 @@ let # top index bar in email view set pager_index_lines=7 + # top_index_bar toggle + macro pager ,@1 "<enter-command> set pager_index_lines=0; macro pager ] ,@2 'Toggle indexbar<Enter>" + macro pager ,@2 "<enter-command> set pager_index_lines=3; macro pager ] ,@3 'Toggle indexbar<Enter>" + macro pager ,@3 "<enter-command> set pager_index_lines=7; macro pager ] ,@1 'Toggle indexbar<Enter>" + macro pager ] ,@1 'Toggle indexbar # sidebar set sidebar_width = 20 @@ -186,9 +191,9 @@ let bind index <right> sidebar-next # got to next folder in sidebar bind index <space> sidebar-open # open selected folder from sidebar # sidebar toggle - macro index ,@) "<enter-command> set sidebar_visible=no; macro index ~ ,@( 'Toggle sidebar'<Enter>" - macro index ,@( "<enter-command> set sidebar_visible=yes; macro index ~ ,@) 'Toggle sidebar'<Enter>" - macro index ~ ,@( 'Toggle sidebar' # toggle the sidebar + macro index,pager ,@) "<enter-command> set sidebar_visible=no; macro index,pager [ ,@( 'Toggle sidebar'<Enter>" + macro index,pager ,@( "<enter-command> set sidebar_visible=yes; macro index,pager [ ,@) 'Toggle sidebar'<Enter>" + macro index,pager [ ,@( 'Toggle sidebar' # toggle the sidebar ''; mutt = pkgs.symlinkJoin { diff --git a/lass/2configs/repo-sync.nix b/lass/2configs/repo-sync.nix deleted file mode 100644 index 8b7d0db71..000000000 --- a/lass/2configs/repo-sync.nix +++ /dev/null @@ -1,144 +0,0 @@ -{ config, lib, pkgs, ... }: - -with import <stockholm/lib>; - -let - mirror = "git@${config.networking.hostName}:"; - - defineRepo = name: announce: let - repo = { - public = true; - name = mkDefault "${name}"; - cgit.desc = mkDefault "mirror for ${name}"; - cgit.section = mkDefault "mirror"; - hooks = mkIf announce (mkDefault { - post-receive = pkgs.git-hooks.irc-announce { - nick = config.networking.hostName; - channel = "#xxx"; - refs = [ - "refs/heads/newest" - ]; - server = "irc.r"; - verbose = false; - }; - }); - }; - in { - rules = with git; [ - { - user = with config.krebs.users; [ - config.krebs.users."${config.networking.hostName}-repo-sync" - lass - lass-mors - lass-shodan - ]; - repo = [ repo ]; - perm = push ''refs/*'' [ non-fast-forward create delete merge ]; - } - { - user = attrValues config.krebs.users; - repo = [ repo ]; - perm = fetch; - } - ]; - repos."${name}" = repo; - }; - - sync-retiolum = name: - { - krebs.repo-sync.repos.${name} = { - branches = { - makefu = { - origin.url = "http://cgit.gum/${name}"; - mirror.url = "${mirror}${name}"; - }; - tv = { - origin.url = "http://cgit.ni.r/${name}"; - mirror.url = "${mirror}${name}"; - }; - nin = { - origin.url = "http://cgit.onondaga.r/${name}"; - mirror.url = "${mirror}${name}"; - }; - lassulus = { - origin.url = "http://cgit.lassul.us/${name}"; - mirror.url = "${mirror}${name}"; - }; - makefu-staging = { - origin.url = "http://cgit.gum/${name}"; - origin.ref = "heads/staging"; - mirror.url = "${mirror}${name}"; - }; - tv-staging = { - origin.url = "http://cgit.ni.r/${name}"; - origin.ref = "heads/staging"; - mirror.url = "${mirror}${name}"; - }; - nin-staging = { - origin.url = "http://cgit.onondaga.r/${name}"; - origin.ref = "heads/staging"; - mirror.url = "${mirror}${name}"; - }; - }; - latest = { - url = "${mirror}${name}"; - ref = "heads/newest"; - }; - }; - krebs.git = defineRepo name (config.networking.hostName == "prism"); - }; - - sync-remote = name: url: - { - krebs.repo-sync.repos.${name} = { - branches = { - remote = { - origin.url = url; - mirror.url = "${mirror}${name}"; - }; - }; - }; - krebs.git = defineRepo name (config.networking.hostName == "prism"); - }; - - sync-remote-silent = name: url: - { - krebs.repo-sync.repos.${name} = { - branches = { - remote = { - origin.url = url; - mirror.url = "${mirror}${name}"; - }; - }; - }; - krebs.git = defineRepo name false; - }; - -in { - krebs.repo-sync = { - enable = true; - unitConfig.ConditionPathExists = "!/var/run/ppp0.pid"; - }; - imports = [ - (sync-remote "array" "https://github.com/makefu/array") - (sync-remote "email-header" "https://github.com/4z3/email-header") - (sync-remote "mycube-flask" "https://github.com/makefu/mycube-flask") - (sync-remote "reaktor-titlebot" "https://github.com/makefu/reaktor-titlebot") - (sync-remote "repo-sync" "https://github.com/makefu/repo-sync") - (sync-remote "skytraq-datalogger" "https://github.com/makefu/skytraq-datalogger") - (sync-remote "xintmap" "https://github.com/4z3/xintmap") - (sync-remote "realwallpaper" "https://github.com/lassulus/realwallpaper") - (sync-remote "lassulus-blog" "https://github.com/lassulus/lassulus-blog") - (sync-remote "painload" "https://github.com/krebs/painload") - (sync-remote "Reaktor" "https://github.com/krebs/Reaktor") - (sync-remote "nixos-wiki" "https://github.com/Mic92/nixos-wiki.wiki.git") - (sync-retiolum "go") - (sync-retiolum "much") - (sync-retiolum "newsbot-js") - (sync-retiolum "populate") - (sync-retiolum "stockholm") - (sync-retiolum "wai-middleware-time") - (sync-retiolum "xmonad-stockholm") - (sync-retiolum "nix-writers") - ]; -} diff --git a/lass/2configs/websites/lassulus.nix b/lass/2configs/websites/lassulus.nix index f60a66952..8f24fb212 100644 --- a/lass/2configs/websites/lassulus.nix +++ b/lass/2configs/websites/lassulus.nix @@ -82,6 +82,10 @@ in { c-base:$apr1$aQ6mYNR3$ho.aJ7icqSO.y.xKo3GQf0 ''}; ''; + locations."/krebspage".extraConfig = '' + default_type "text/html"; + alias ${pkgs.krebspage}/index.html; + ''; # TODO make this work! locations."= /ddate".extraConfig = let script = pkgs.writeBash "test" '' diff --git a/makefu/krops.nix b/makefu/krops.nix index 30385c10e..3838db635 100644 --- a/makefu/krops.nix +++ b/makefu/krops.nix @@ -76,7 +76,7 @@ in { }; # usage: $(nix-build --no-out-link --argstr name HOSTNAME --argstr target PATH -A test) - test = pkgs.krops.writeTest "${name}-test" { + test = { target ? target }: pkgs.krops.writeTest "${name}-test" { inherit target; source = source { test = true; }; }; |