This repository has no description
0

Configure Feed

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

superconfig / 2configs / kannix.nix
3.4 kB 141 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.yubi1.public 74 self.keys.ssh.yubi2.public 75 self.keys.ssh.solo2.public 76 self.keys.ssh.xerxes.public 77 self.keys.ssh.massulus.public 78 ]; 79 packages = [ 80 pkgs.tmux 81 pkgs.git 82 self.packages.${pkgs.system}.s 83 ]; 84 }; 85 86 systemd.tmpfiles.rules = [ 87 "d ${stateDir}/repos 0755 kannix users -" 88 "d ${stateDir}/worktrees 0755 kannix users -" 89 "d ${stateDir}/checkout 0755 kannix users -" 90 ]; 91 92 systemd.services.kannix-checkout = { 93 description = "Create kannix worktree from bare repo"; 94 wantedBy = [ "multi-user.target" ]; 95 unitConfig.ConditionPathExists = "!${srcDir}/.git"; 96 serviceConfig = { 97 Type = "oneshot"; 98 User = "kannix"; 99 Group = "users"; 100 ExecStart = toString ( 101 pkgs.writeShellScript "kannix-checkout" '' 102 ${pkgs.git}/bin/git --git-dir=${bareRepo} worktree add ${srcDir} main 103 '' 104 ); 105 }; 106 }; 107 108 systemd.user.services.kannix = { 109 description = "Kannix kanban server"; 110 wantedBy = [ "default.target" ]; 111 after = [ "network.target" ]; 112 path = [ 113 pkgs.tmux 114 pkgs.git 115 pkgs.nix 116 ]; 117 serviceConfig = { 118 Type = "simple"; 119 ExecStart = toString kannixScript; 120 Restart = "on-failure"; 121 RestartSec = 5; 122 WorkingDirectory = srcDir; 123 }; 124 }; 125 126 services.nginx.virtualHosts."kannix.lassul.us" = { 127 enableACME = true; 128 forceSSL = true; 129 locations."/" = { 130 proxyPass = "http://127.0.0.1:${toString port}"; 131 proxyWebsockets = true; 132 extraConfig = '' 133 proxy_set_header Host $host; 134 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 135 proxy_set_header X-Forwarded-Proto $scheme; 136 proxy_read_timeout 3600s; 137 proxy_send_timeout 3600s; 138 ''; 139 }; 140 }; 141}