diff --git a/flake.nix b/flake.nix index d53405d..11cb171 100644 --- a/flake.nix +++ b/flake.nix @@ -113,6 +113,7 @@ ./nixos/beefcake ] (with outputs.homeManagerModules; [ linux + weechat-in-tmux-service ]); rascal = mkNixosSystem "x86_64-linux" [./nixos/rascal] (with outputs.homeManagerModules; [ linux diff --git a/lib/internal.md b/lib/internal.md new file mode 100644 index 0000000..cd16505 --- /dev/null +++ b/lib/internal.md @@ -0,0 +1,9 @@ +# Internal Usage + +## Update Server + +```shell +g a; set host beefcake; nix run nixpkgs#nixos-rebuild -- --flake ".#$host" \ + --target-host "root@$host" --build-host "root@$host" \ + switch --show-trace +``` diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 251f3d9..c0358d4 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -27,6 +27,9 @@ sway-laptop = import ./sway-laptop.nix; tmux = import ./tmux.nix; + tmux-master-service = import ./tmux-master-service.nix; + weechat-in-tmux-service = import ./weechat-in-tmux-service.nix; + dragon = import ./dragon.nix; thinker = import ./thinker.nix; foxtrot = import ./foxtrot.nix; diff --git a/modules/home-manager/tmux-master-service.nix b/modules/home-manager/tmux-master-service.nix new file mode 100644 index 0000000..d859c49 --- /dev/null +++ b/modules/home-manager/tmux-master-service.nix @@ -0,0 +1,35 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; let + cfg = config.services.tmux-master-service; +in { + options.services.tmux-master-service = { + enable = mkEnableOption "tmux master service"; + + socket = mkOption { + type = types.path; + default = "/run/user/%U/tmux-%U/default"; + }; + }; + config = { + # https://superuser.com/a/1582196 + systemd.user.services.tmux-master = { + Unit = { + Description = "tmux master service"; + }; + Service = { + Type = "forking"; + RemainAfterExit = "yes"; + ExecStart = "${pkgs.tmux}/bin/tmux -S ${cfg.socket} new-session -d -s default"; + ExecStop = "${pkgs.tmux}/bin/tmux -S ${cfg.socket} kill-session -t weechat"; + }; + Install = { + WantedBy = ["default.target"]; + }; + }; + }; +} diff --git a/modules/home-manager/tmux.nix b/modules/home-manager/tmux.nix index ebfec35..120fac1 100644 --- a/modules/home-manager/tmux.nix +++ b/modules/home-manager/tmux.nix @@ -118,4 +118,7 @@ # set -g @continuum-save-interval '120' ''; }; + home.shellAliases = { + t = "tmux"; + }; } diff --git a/modules/home-manager/weechat-in-tmux-service.nix b/modules/home-manager/weechat-in-tmux-service.nix new file mode 100644 index 0000000..55067e4 --- /dev/null +++ b/modules/home-manager/weechat-in-tmux-service.nix @@ -0,0 +1,28 @@ +{ + pkgs, + outputs, + config, + ... +}: let + socket = config.services.tmux-master-service.socket; +in { + imports = with outputs.homeManagerModules; [ + tmux-master-service + ]; + systemd.user.services.weechat-in-tmux = { + Unit = { + Description = "weechat in tmux"; + PartOf = "tmux-master.service"; + After = ["tmux-master.service"]; + }; + Service = { + Type = "oneshot"; + RemainAfterExit = "yes"; + ExecStart = "${pkgs.tmux}/bin/tmux -S ${socket} new-session -d -s weechat ${pkgs.weechat}/bin/weechat"; + ExecStop = "${pkgs.tmux}/bin/tmux -S ${socket} kill-session -t weechat"; + }; + Install = { + WantedBy = ["default.target"]; + }; + }; +} diff --git a/nixos/beefcake/default.nix b/nixos/beefcake/default.nix index 45a941d..b0a1864 100644 --- a/nixos/beefcake/default.nix +++ b/nixos/beefcake/default.nix @@ -255,15 +255,6 @@ sudo nix run nixpkgs#ipmitool -- raw 0x30 0x30 0x02 0xff 0x00 environment.systemPackages = [pkgs.linuxquota]; - systemd.services.weechat-in-tmux = { - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - ExecStart = "${pkgs.tmux}/bin/tmux -2 new-session -d -s weechat ${pkgs.weechat}/bin/weechat"; - ExecStop = "${pkgs.tmux}/bin/tmux kill-session -t weechat"; - }; - }; - # TODO: make the client declarative? right now I think it's manually git # clone'd to /root systemd.services.deno-netlify-ddns-client = { diff --git a/readme.md b/readme.md index be6933e..a66d453 100644 --- a/readme.md +++ b/readme.md @@ -121,6 +121,10 @@ nix-shell --packages git \ --option trusted-public-keys 'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= h.lyte.dev:HeVWtne31ZG8iMf+c15VY3/Mky/4ufXlfTpT8+4Xbs0='" ``` +# Internal Usage + +Just for me, see [[lib/internal.md]] + # To Do ## Short Term