This repository has no description
9.0 kB
228 lines
1{ pkgs, ... }:
2
3let
4 mcExt = pkgs.writeText "mc.ext" ''
5 # Midnight Commander 4.0 extension file
6 #
7 # Warning: The structure of this file has been completely changed with the version 4.0!
8 #
9 # All lines starting with # or empty lines are ignored.
10 #
11 # IMPORTANT: mc scans this file only upon first use or after editing it using the
12 # mc "Edit extension file" command (F9-c-e). If you edit this file in any other way
13 # while mc is running, you will need to press F9-c-e and exit the editor for your
14 # changes to take effect, or exit mc and start it again.
15 #
16 # Section name can be anything with following exceptions:
17 # there are two reserved section names:
18 # mc.ext.ini
19 # Default
20 # special name pattern:
21 # Include/xxxxx
22 # See below for more details.
23 #
24 # Section [mc.ext.ini] is mandatory. It contains file metadata.
25 # "Version" parameter is mandatory. It contains the file format version.
26 #
27 # Section [Default] is optional. It is applied only if no other match was found.
28 #
29 # Sections like [Include/xxxx] can be referenced as "Include=xxxx" from other sections.
30 # Section [Include/xxxx] can be located as before as after sections that point to it.
31 #
32 # Sections are processed from top to bottom, thus the order is important.
33 # If there are more than one sections with the same name in this file, the first
34 # section will be used.
35 #
36 # [Default] should be a catch-all action and come last.
37 #
38 # A section describing a file can contain following keys:
39 #
40 # File descriptions:
41 #
42 # Directory
43 # Matches any directory matching regular expression.
44 # Always case sensitive.
45 # This key has the highest priority over other keys. If this key is in a section,
46 # other keys are ignored.
47 #
48 # Type
49 # Matches files if `file %f` matches regular expression
50 # (the "filename:" part is removed from `file %f` output).
51 # Ignored if the "file" utility isn't used (not found during the configure step
52 # or disabled in the ini-file).
53 #
54 # TypeIgnoreCase [true|false]
55 # Defines whether the Type value is case sensitive or not.
56 # If absent, Type is case sensitive.
57 #
58 # Regex
59 # An extended regular expression
60 # Please note that we are using the PCRE library and thus \| matches
61 # the literal | and | has a special meaning (or), and () have a special meaning
62 # and \( \) stand for literal ( ).
63 #
64 # Example:
65 # Regex=\.t(ar\.lzma|lz)$
66 # matches *.tar.lzma or *.tlz.
67 #
68 # RegexIgnoreCase [true|false]
69 # Defines whether the Regex value is case sensitive or not.
70 # If absent, Regex is case sensitive.
71 #
72 # Shell
73 # Describes an extension when starting with a dot (no wildcards).
74 #
75 # Example:
76 # Shell=.tar
77 # matches *.tar.
78 #
79 # If it doesn't start with a dot, it matches only a file of that name.
80 #
81 # If both keys Regex and Shell are in the same section, Regex is used
82 # and Shell is ignored.
83 #
84 # ShellIgnoreCase [true|false]
85 # Defines whether the Shell value is case sensitive or not.
86 # If absent, Shell is case sensitive.
87 #
88 # Include
89 # Reference to another section.
90 #
91 # Example:
92 # Include=video
93 # points to the [Include/video] section.
94 #
95 # Commands:
96 #
97 # Open
98 # Execute the command if the user presses Enter or doubleclicks it.
99 #
100 # View
101 # Execute the command if the user presses F3.
102 #
103 # Edit
104 # Execute the command if the user presses F4.
105 #
106 # All commands are ignored if the section contains the Include key.
107 #
108 # Command is any one-line shell command, with the following substitutions:
109 #
110 # %%
111 # The % character
112 #
113 # %p
114 # Name of the current file without the path.
115 # Also provided to the external application as MC_EXT_BASENAME environment variable.
116 #
117 # %f
118 # Name of the current file. Unlike %p, if the file is located on a non-local
119 # virtual filesystem, that is either tarfs or ftpfs, then the file will be
120 # temporarily copied into a local directory and %f will be the full path
121 # to this local temporary file.
122 # If you don't want to get a local copy and want to get the virtual fs path
123 # (like /ftp://ftp.cvut.cz/pub/hungry/xword), then use %d/%p instead of %f.
124 # Also provided to the external application as MC_EXT_FILENAME environment variable.
125 #
126 # %d
127 # Name of the current directory without the trailing slash (`pwd`).
128 # Also provided to the external application as MC_EXT_CURRENTDIR environment variable.
129 #
130 # %s
131 # "Selected files", that is space separated list of tagged files if any or the name
132 # of the current file.
133 # Also provided to the external application as MC_EXT_SELECTED environment variable.
134 #
135 # %t
136 # List of the tagged files.
137 # Also provided to the external application as MC_EXT_ONLYTAGGED environment variable.
138 #
139 # %u
140 # List of the tagged files (they will be untaged after the command is executed).
141 #
142 # (If the letter following the % is uppercase, then it refers to the opposite panel.
143 # But you shouldn't have to use it in this file.)
144 #
145 # %cd
146 # The rest is a path mc should change into (cd won't work, since it's a child process).
147 # %cd handles even vfs names.
148 #
149 # %view
150 # The command output will be piped into mc's internal file viewer. If you use
151 # only %view and no command, the viewer will load %f file instead (that is no piping,
152 # which is the difference to %view cat %f).
153 #
154 # %view may be directly followed by {} with one or more of the following
155 # separated by commas:
156 # ascii (ascii mode)
157 # hex (hex mode),
158 # nroff (color highlighting for text using escape sequences),
159 # unform (no highlighting for nroff sequences)
160 #
161 # %var{VAR:default}
162 # This macro will expand to the value of the VAR variable in the environment if it's
163 # set, otherwise the default value will be used. This is similar to the Bourne shell
164 # ''${VAR-default} construct.
165 #
166 # Section can contain both Type and Regex or Type and Shell keys. In this case
167 # they are handled as an AND condition.
168 #
169 # Example:
170 # Shell=.3gp
171 # Type=^ISO Media.*3GPP
172 #
173 # matches *.3gp files for which `file` output is a line starting with "ISO Media"
174 # and containing "3GPP".
175 #
176 # If there are more than one keys with the same name in a section, the last key will be used.
177 #
178 #
179 # Any new entries you want to add are always welcome if they are useful on more than one
180 # system. You can post your modifications as tickets at www.midnight-commander.org.
181
182
183 ### Changes ###
184 #
185 # Reorganization: 2012-03-07 Slava Zanko <slavazanko@gmail.com>
186 # 2021-03-28 Andrew Borodin <aborodin@vmail.ru>
187 # 2021-08-24 Tomas Szepe <szepe@pinerecords.com>
188 # 2022-09-11 Andrew Borodin <aborodin@vmail.ru>: port to INI format.
189
190 [mc.ext.ini]
191 Version=4.0
192
193 ## do all through xdg-open ##
194 [all]
195 Regex=\.*
196 Open=/run/current-system/sw/bin/xdg-open %f
197 View=/run/current-system/sw/bin/xdg-open %f
198 Edit=/run/current-system/sw/bin/xdg-open %f
199
200 ######### Default #########
201
202 # Default target for anything not described above
203 [Default]
204 Open=/run/current-system/sw/bin/xdg-open %f
205 View=/run/current-system/sw/bin/xdg-open %f
206 '';
207
208in
209{
210 environment.systemPackages = [
211 (pkgs.symlinkJoin {
212 name = "mc";
213 paths = [
214 (pkgs.writeDashBin "mc" ''
215 export MC_DATADIR=${
216 pkgs.write "mc-ext" {
217 "/mc.ext.ini".link = mcExt;
218 "/sfs.ini".text = "";
219 }
220 };
221 export TERM=xterm-256color
222 exec ${pkgs.mc}/bin/mc -S nicedark "$@"
223 '')
224 pkgs.mc
225 ];
226 })
227 ];
228}