Skip to content

Commit

Permalink
Reformat with nixfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
purcell committed Jul 26, 2024
1 parent a8c95b7 commit 82f8ebb
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 185 deletions.
4 changes: 3 additions & 1 deletion .dir-locals.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
;;; For more information see (info "(emacs) Directory Variables")

((nix-mode
(mode . nixpkgs-fmt-on-save)))
(mode . nixfmt-on-save))
(nix-ts-mode
(mode . nixfmt-on-save)))
115 changes: 44 additions & 71 deletions emacs.nix
Original file line number Diff line number Diff line change
@@ -1,90 +1,63 @@
{ name
, src
, version
, stdenv
, lib
, fetchurl
, glibc
, ncurses
, autoreconfHook
, pkg-config
, libxml2
, gettext
, gnutls
, jansson
, sqlite
, tree-sitter
{ name, src, version, stdenv, lib, fetchurl, glibc, ncurses, autoreconfHook
, pkg-config, libxml2, gettext, gnutls, jansson, sqlite, tree-sitter
, withTreeSitter ? lib.versionAtLeast version "29"
, withSQLite3 ? lib.versionAtLeast version "29"
, gmp
, sigtool ? null
, autoconf ? null
, automake ? null
, texinfo ? null
, srcRepo ? false
, latestPackageKeyring
, darwin
}:
, withSQLite3 ? lib.versionAtLeast version "29", gmp, sigtool ? null
, autoconf ? null, automake ? null, texinfo ? null, srcRepo ? false
, latestPackageKeyring, darwin }:

# A very minimal version of https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/emacs/default.nix
stdenv.mkDerivation rec {
inherit name version src;

enableParallelBuilding = true;

nativeBuildInputs =
[ pkg-config ]
nativeBuildInputs = [ pkg-config ]
++ lib.optionals stdenv.isDarwin [ sigtool ]
++ lib.optionals (lib.versionAtLeast version "25.1") [ autoreconfHook texinfo ];
++ lib.optionals (lib.versionAtLeast version "25.1") [
autoreconfHook
texinfo
];

buildInputs =
[ ncurses libxml2 gnutls gettext jansson gmp ]
buildInputs = [ ncurses libxml2 gnutls gettext jansson gmp ]
++ lib.optional withSQLite3 sqlite
++ lib.optional withTreeSitter tree-sitter;

hardeningDisable = [ "format" ];

# llvm-strip leaves executables that segfault immediately in some specific cases
preFixup = lib.optionalString (stdenv.hostPlatform.isDarwin && lib.versionOlder version "27.1") ''
export STRIP=${lib.getBin darwin.cctools-port}/bin/${stdenv.cc.targetPrefix}strip
'';

patches =
lib.optionals ("23.4" == version) [
./patches/all-dso-handle.patch
./patches/fpending-23.4.patch
] ++
lib.optionals ("24.1" == version) [
./patches/gnutls-e_again-old-emacsen.patch
./patches/all-dso-handle.patch
./patches/remove-old-gets-warning.patch
./patches/fpending-24.1.patch
] ++
lib.optionals ("24.2" == version) [
./patches/gnutls-e_again-old-emacsen.patch
./patches/all-dso-handle.patch
./patches/fpending-24.1.patch
] ++
lib.optionals ("24.3" == version) [
./patches/all-dso-handle.patch
./patches/fpending-24.3.patch
] ++
lib.optionals (lib.versionAtLeast version "24.3" && lib.versionOlder version "26.3") [
./patches/gnutls-e_again.patch
] ++
lib.optionals (lib.versionAtLeast version "25.1" && lib.versionOlder version "28.1") [
./patches/sigsegv-stack.patch
] ++
lib.optionals (stdenv.isDarwin && lib.versionAtLeast version "25.1" && lib.versionOlder version "26.1") [
./patches/gnutls-use-osx-cert-bundle.patch
] ++
lib.optionals (stdenv.isDarwin && lib.versionOlder version "27.1") [
./patches/macos-unexec.patch
];
preFixup = lib.optionalString
(stdenv.hostPlatform.isDarwin && lib.versionOlder version "27.1") ''
export STRIP=${
lib.getBin darwin.cctools-port
}/bin/${stdenv.cc.targetPrefix}strip
'';

passthru = {
inherit withTreeSitter;
};
patches = lib.optionals ("23.4" == version) [
./patches/all-dso-handle.patch
./patches/fpending-23.4.patch
] ++ lib.optionals ("24.1" == version) [
./patches/gnutls-e_again-old-emacsen.patch
./patches/all-dso-handle.patch
./patches/remove-old-gets-warning.patch
./patches/fpending-24.1.patch
] ++ lib.optionals ("24.2" == version) [
./patches/gnutls-e_again-old-emacsen.patch
./patches/all-dso-handle.patch
./patches/fpending-24.1.patch
] ++ lib.optionals ("24.3" == version) [
./patches/all-dso-handle.patch
./patches/fpending-24.3.patch
] ++ lib.optionals
(lib.versionAtLeast version "24.3" && lib.versionOlder version "26.3")
[ ./patches/gnutls-e_again.patch ] ++ lib.optionals
(lib.versionAtLeast version "25.1" && lib.versionOlder version "28.1")
[ ./patches/sigsegv-stack.patch ] ++ lib.optionals (stdenv.isDarwin
&& lib.versionAtLeast version "25.1" && lib.versionOlder version "26.1")
[ ./patches/gnutls-use-osx-cert-bundle.patch ]
++ lib.optionals (stdenv.isDarwin && lib.versionOlder version "27.1")
[ ./patches/macos-unexec.patch ];

passthru = { inherit withTreeSitter; };

configureFlags = [
"--disable-build-details" # for a (more) reproducible build
Expand Down Expand Up @@ -136,7 +109,7 @@ stdenv.mkDerivation rec {

meta = with lib; {
description = "The extensible, customizable GNU text editor";
homepage = https://www.gnu.org/software/emacs/;
homepage = "https://www.gnu.org/software/emacs/";
license = licenses.gpl3Plus;
platforms = platforms.all;
mainProgram = "emacs";
Expand Down
Loading

0 comments on commit 82f8ebb

Please sign in to comment.