summaryrefslogtreecommitdiff
path: root/modules/hjem.nix
blob: 019eada6bfc5b7a2cc1506a0af4921ed40e3d6eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{std, ...}: {
  pkgs,
  lib,
  config,
  ...
}: let
  cfg = config.tsunami;
in {
  imports = lib.filesystem.listFilesRecursive ./common;

  _module.args = {
    inherit std;
    tsunamiLib = {
      scriptPath = f: "~/.config/tmux/scripts/${f}.sh";
      filePath = f: "~/.config/tmux/files/${f}";
    };
  };

  files = lib.mkIf cfg.enable (lib.mkMerge [
    (
      cfg.scripts
      |> builtins.mapAttrs (name: value: {
        name = ".config/tmux/scripts/${name}.sh";
        value = {
          text = value;
          executable = true;
        };
      })
      |> lib.attrValues
      |> builtins.listToAttrs
    )
    (
      cfg.files
      |> builtins.mapAttrs (name: value: {
        name = ".config/tmux/files/${name}";
        value.text = value;
      })
      |> lib.attrValues
      |> builtins.listToAttrs
    )
    (
      cfg.confs
      |> builtins.mapAttrs (name: value: {
        name = ".config/tmux/conf.d/${name}.conf";
        value.text = value;
      })
      |> lib.attrValues
      |> builtins.listToAttrs
    )
    {
      ".config/tmux/tmux.conf".text = ''
        run-shell "find ~/.config/tmux/conf.d -print0 | xargs -0 -n1 tmux source-file"
      '';
    }
  ]);

  packages = lib.optional cfg.enable pkgs.tmux;
}