Skip to content

Commit

Permalink
feat: Add mainIsAscii option to remove IFD from elisp packages
Browse files Browse the repository at this point in the history
By setting the option to true, this will allow adding of elisp packages directly
to the outputs of a flake, without IFD.
  • Loading branch information
akirak committed Nov 25, 2023
1 parent 9c3c6ba commit 3b118f6
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkgs/emacs/data/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ in

# builtins.readFile fails when the source file contains control characters.
# pydoc.el is an example. A workaround is to take only the first N bytes of
# the file using `head` command and read its output.
# the file using `head` command and read its output. This is IFD, which
# effectively prevents you from adding elisp packages directly to the flake
# outputs.
headers =
lib.parseElispHeaders
(lib.readFirstBytes
# magit.el has a relatively long header, so other libraries would be shorter.
1500
(self.src + "/${self.mainFile}"));
(
# Add support for an option to remove IFD.
if self.mainIsAscii or false
then builtins.readFile (self.src + "/${self.mainFile}")
else
(lib.readFirstBytes
# magit.el has a relatively long header, so other libraries would be shorter.
1500
(self.src + "/${self.mainFile}"))
);
in
lib.getAttrs
(filter (name: hasAttr name attrs) [
Expand Down

0 comments on commit 3b118f6

Please sign in to comment.