summaryrefslogtreecommitdiff
path: root/modules/system/defaults/finder.nix
blob: 51fff74f6b1753b9370e497d575b34e85881098b (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{ config, lib, ... }:

let
  inherit (lib) mkOption types;

  cfg = config.system.defaults.finder;
in
{
  options = {

    system.defaults.finder.AppleShowAllFiles = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Whether to always show hidden files. The default is false.
      '';
    };

    system.defaults.finder.ShowStatusBar = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Show status bar at bottom of finder windows with item/disk space stats. The default is false.
      '';
    };

    system.defaults.finder.ShowPathbar = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Show path breadcrumbs in finder windows. The default is false.
      '';
    };

    system.defaults.finder.FXDefaultSearchScope = mkOption {
      type = types.nullOr types.str;
      default = null;
      description = ''
        Change the default search scope. Use "SCcf" to default to current folder.
        The default is unset ("This Mac").
      '';
    };

    system.defaults.finder.FXPreferredViewStyle = mkOption {
      type = types.nullOr types.str;
      default = null;
      description = ''
        Change the default finder view.
        "icnv" = Icon view, "Nlsv" = List view, "clmv" = Column View, "Flwv" = Gallery View
        The default is icnv.
      '';
    };

    system.defaults.finder.AppleShowAllExtensions = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Whether to always show file extensions.  The default is false.
      '';
    };

    system.defaults.finder.CreateDesktop = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Whether to show icons on the desktop or not. The default is true.
      '';
    };

    system.defaults.finder.QuitMenuItem = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Whether to allow quitting of the Finder.  The default is false.
      '';
    };

    system.defaults.finder._FXShowPosixPathInTitle = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Whether to show the full POSIX filepath in the window title.  The default is false.
      '';
    };

    system.defaults.finder._FXSortFoldersFirst = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Keep folders on top when sorting by name. The default is false.
      '';
    };

    system.defaults.finder.FXEnableExtensionChangeWarning = mkOption {
      type = types.nullOr types.bool;
      default = null;
      description = ''
        Whether to show warnings when change the file extension of files.  The default is true.
      '';
    };

    system.defaults.finder.NewWindowTarget = mkOption {
      type = types.nullOr (types.enum [
        "Computer"
        "OS volume"
        "Home"
        "Desktop"
        "Documents"
        "Recents"
        "iCloud Drive"
        "Other"
      ]);
      apply = key: if key == null then null else {
        "Computer" = "PfCm";
        "OS volume" = "PfVo";
        "Home" = "PfHm";
        "Desktop" = "PfDe";
        "Documents" = "PfDo";
        "Recents" = "PfAF";
        "iCloud Drive" = "PfID";
        "Other" = "PfLo";
      }.${key};
      default = null;
      description = ''
        Change the default folder shown in Finder windows. "Other" corresponds to the value of
        NewWindowTargetPath. The default is unset ("Recents").
      '';
    };

    system.defaults.finder.NewWindowTargetPath = mkOption {
      type = types.nullOr types.str;
      default = null;
      description = ''
        Sets the URI to open when NewWindowTarget is "Other". Spaces and similar characters must be
        escaped. If the value is invalid, Finder will open your home directory.
        Example: "file:///Users/foo/long%20cat%20pics".
        The default is unset.
      '';
    };
  };

  config = {
    assertions = [{
      assertion = cfg.NewWindowTargetPath != null -> cfg.NewWindowTarget == "PfLo";
      message = "`system.defaults.finder.NewWindowTarget` should be set to `Other` when `NewWindowTargetPath` is non-null.";
    }
    {
      assertion = cfg.NewWindowTarget == "PfLo" -> cfg.NewWindowTargetPath != null;
      message = "`system.defaults.finder.NewWindowTargetPath` should be non-null when `NewWindowTarget` is set to `Other`.";
    }];
  };
}