Skip to content

Commit 5fc0c69

Browse files
committed
feat: Add defaultMainIsAscii option to avoid IFD
1 parent 4f2d5bc commit 5fc0c69

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

pkgs/emacs/data/default.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ in
2727
archiveLockFile,
2828
inputOverrides,
2929
elispPackagePins,
30+
defaultMainIsAscii,
3031
}: mode: let
3132
toLockData = {
3233
nodes,
@@ -92,7 +93,7 @@ in
9293
);
9394

9495
getPackageData = revDep: ename:
95-
lib.makeExtensible (import ./package.nix {inherit lib linkFarm;}
96+
lib.makeExtensible (import ./package.nix {inherit lib linkFarm defaultMainIsAscii;}
9697
ename
9798
# It would be nice if it were possible to set the pin from inside
9899
# overrideInputs, but it causes infinite recursion unfortunately :(

pkgs/emacs/data/package.nix

+13-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ let
2222
isFunction
2323
;
2424
in
25-
{lib, linkFarm}: ename: mkAttrs: self: let
25+
{
26+
lib,
27+
linkFarm,
28+
defaultMainIsAscii,
29+
}: ename: mkAttrs: self: let
2630
attrs =
2731
if isAttrs mkAttrs
2832
then mkAttrs
@@ -63,7 +67,7 @@ in
6367
lib.parseElispHeaders
6468
(
6569
# Add support for an option to remove IFD.
66-
if self.mainIsAscii or false
70+
if self.mainIsAscii or defaultMainIsAscii
6771
then builtins.readFile (self.src + "/${self.mainFile}")
6872
else
6973
(lib.readFirstBytes
@@ -88,12 +92,13 @@ in
8892
# If the source if a single-file archive from ELPA or MELPA, src will be
8993
# a file, and not a directory, so the file should be put in a directory.
9094
if attrs.inventory.type == "archive" && attrs.archive.type == "file"
91-
then linkFarm (ename + ".el") [
92-
{
93-
name = ename + ".el";
94-
path = attrs.src;
95-
}
96-
]
95+
then
96+
linkFarm (ename + ".el") [
97+
{
98+
name = ename + ".el";
99+
path = attrs.src;
100+
}
101+
]
97102
else attrs.src;
98103

99104
files = attrs.files or (lib.expandMelpaRecipeFiles self.src null);

pkgs/emacs/default.nix

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
if wantExtraOutputs
3737
then ["info"]
3838
else [],
39+
# Assume the main files of all packages contain only ASCII characters. This is
40+
# a requirement for avoiding IFD, but some libraries actually contain
41+
# non-ASCII characters, which cannot be parsed with `builtins.readFile`
42+
# function of Nix.
43+
defaultMainIsAscii ? false,
3944
# Export a manifest file of of the package set from the wrapper
4045
# (experimental). Needed if you use the hot-reloading feature of twist.el.
4146
exportManifest ? false,
@@ -101,6 +106,7 @@ in
101106
archiveLockFile
102107
builtinLibraries
103108
inputOverrides
109+
defaultMainIsAscii
104110
;
105111
# Just remap the name
106112
inventories = registries;

0 commit comments

Comments
 (0)