This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / configs / kannix.nix
3.6 kB 147 lines
1{ 2 self, 3 pkgs, 4 lib, 5 ... 6}: 7let 8 port = 4243; 9 stateDir = "/var/lib/kannix"; 10 bareRepo = "${stateDir}/repos/kannix.git"; 11 srcDir = "${stateDir}/checkout/kannix"; 12 13 configFile = pkgs.writeText "kannix.json" ( 14 builtins.toJSON { 15 columns = [ 16 "backlog" 17 "planning" 18 "doing" 19 "review" 20 "done" 21 ]; 22 server = { 23 host = "127.0.0.1"; 24 inherit port; 25 }; 26 repos_dir = "${stateDir}/repos"; 27 worktree_dir = "${stateDir}/worktrees"; 28 } 29 ); 30 31 kannixScript = pkgs.writeShellScript "kannix-run" '' 32 export KANNIX_CONFIG=${configFile} 33 export KANNIX_STATE_DIR=${stateDir} 34 export PATH=${ 35 lib.makeBinPath [ 36 pkgs.tmux 37 pkgs.git 38 pkgs.nix 39 pkgs.inotify-tools 40 pkgs.coreutils 41 ] 42 }:$PATH 43 cd ${srcDir} 44 45 while true; do 46 nix run .# -- \ 47 --host 127.0.0.1 \ 48 --port ${toString port} & 49 PID=$! 50 51 inotifywait -r -e modify,create,delete,move \ 52 --exclude '(__pycache__|\.pyc|\.git/|result)' \ 53 ${srcDir}/src ${srcDir}/flake.nix ${srcDir}/flake.lock ${srcDir}/package.nix ${srcDir}/pyproject.toml 54 55 echo "Change detected, restarting..." 56 kill $PID 2>/dev/null 57 wait $PID 2>/dev/null 58 sleep 1 59 done 60 ''; 61in 62{ 63 users.users.kannix = { 64 isNormalUser = true; 65 home = stateDir; 66 createHome = true; 67 group = "users"; 68 shell = pkgs.bashInteractive; 69 linger = true; 70 openssh.authorizedKeys.keys = [ 71 self.keys.ssh.barnacle.public 72 self.keys.ssh.yubi_pgp.public 73 self.keys.ssh.termux_massulus.public 74 self.keys.ssh.yubi1.public 75 self.keys.ssh.yubi2.public 76 self.keys.ssh.solo2.public 77 self.keys.ssh.xerxes.public 78 self.keys.ssh.ignavia.public 79 self.keys.ssh.phonetpm_massulus.public 80 self.keys.ssh.massulus.public 81 ]; 82 packages = [ 83 pkgs.tmux 84 pkgs.git 85 (pkgs.writeShellScriptBin "kannix-ctl" '' 86 cd ${srcDir} 87 exec "$(nix build .# --no-link --print-out-paths)/bin/kannix-ctl" "$@" 88 '') 89 ]; 90 }; 91 92 systemd.tmpfiles.rules = [ 93 "d ${stateDir}/repos 0755 kannix users -" 94 "d ${stateDir}/worktrees 0755 kannix users -" 95 "d ${stateDir}/checkout 0755 kannix users -" 96 ]; 97 98 systemd.services.kannix-checkout = { 99 description = "Create kannix worktree from bare repo"; 100 wantedBy = [ "multi-user.target" ]; 101 unitConfig.ConditionPathExists = "!${srcDir}/.git"; 102 serviceConfig = { 103 Type = "oneshot"; 104 User = "kannix"; 105 Group = "users"; 106 ExecStart = toString ( 107 pkgs.writeShellScript "kannix-checkout" '' 108 ${pkgs.git}/bin/git --git-dir=${bareRepo} worktree add ${srcDir} main 109 '' 110 ); 111 }; 112 }; 113 114 systemd.user.services.kannix = { 115 description = "Kannix kanban server"; 116 wantedBy = [ "default.target" ]; 117 after = [ "network.target" ]; 118 path = [ 119 pkgs.tmux 120 pkgs.git 121 pkgs.nix 122 ]; 123 serviceConfig = { 124 Type = "simple"; 125 ExecStart = toString kannixScript; 126 Restart = "on-failure"; 127 RestartSec = 5; 128 WorkingDirectory = srcDir; 129 }; 130 }; 131 132 services.nginx.virtualHosts."kannix.lassul.us" = { 133 enableACME = true; 134 forceSSL = true; 135 locations."/" = { 136 proxyPass = "http://127.0.0.1:${toString port}"; 137 proxyWebsockets = true; 138 extraConfig = '' 139 proxy_set_header Host $host; 140 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 141 proxy_set_header X-Forwarded-Proto $scheme; 142 proxy_read_timeout 3600s; 143 proxy_send_timeout 3600s; 144 ''; 145 }; 146 }; 147}