emacs: refactor

- Remove the excessive repetition of inherited packages
- Factor the excessive repetition of metadata in sources.nix
This commit is contained in:
Anderson Torres 2023-08-25 19:18:25 -03:00
parent e05a78c881
commit f6a6dc801f
2 changed files with 69 additions and 96 deletions

View file

@ -4,6 +4,14 @@ lib.makeScope pkgs.newScope (self:
let let
gconf = pkgs.gnome2.GConf; gconf = pkgs.gnome2.GConf;
inherit (self) callPackage; inherit (self) callPackage;
inheritedArgs = {
inherit gconf;
inherit (pkgs.darwin) sigtool;
inherit (pkgs.darwin.apple_sdk.frameworks)
AppKit Carbon Cocoa GSS ImageCaptureCore ImageIO IOKit OSAKit Quartz
QuartzCore WebKit;
};
in { in {
sources = import ./sources.nix { sources = import ./sources.nix {
inherit lib; inherit lib;
@ -12,14 +20,7 @@ lib.makeScope pkgs.newScope (self:
fetchFromSavannah; fetchFromSavannah;
}; };
emacs28 = callPackage (self.sources.emacs28) { emacs28 = callPackage (self.sources.emacs28) inheritedArgs;
inherit gconf;
inherit (pkgs.darwin) sigtool;
inherit (pkgs.darwin.apple_sdk.frameworks)
AppKit Carbon Cocoa GSS ImageCaptureCore ImageIO IOKit OSAKit Quartz
QuartzCore WebKit;
};
emacs28-gtk2 = self.emacs28.override { emacs28-gtk2 = self.emacs28.override {
withGTK2 = true; withGTK2 = true;
@ -33,14 +34,7 @@ lib.makeScope pkgs.newScope (self:
noGui = true; noGui = true;
}); });
emacs29 = callPackage (self.sources.emacs29) { emacs29 = callPackage (self.sources.emacs29) inheritedArgs;
inherit gconf;
inherit (pkgs.darwin) sigtool;
inherit (pkgs.darwin.apple_sdk.frameworks)
AppKit Carbon Cocoa GSS ImageCaptureCore ImageIO IOKit OSAKit Quartz
QuartzCore WebKit;
};
emacs29-gtk3 = self.emacs29.override { emacs29-gtk3 = self.emacs29.override {
withGTK3 = true; withGTK3 = true;
@ -54,21 +48,7 @@ lib.makeScope pkgs.newScope (self:
withPgtk = true; withPgtk = true;
}; };
emacs28-macport = callPackage (self.sources.emacs28-macport) { emacs28-macport = callPackage (self.sources.emacs28-macport) inheritedArgs;
inherit gconf;
inherit (pkgs.darwin) sigtool; emacs29-macport = callPackage (self.sources.emacs29-macport) inheritedArgs;
inherit (pkgs.darwin.apple_sdk.frameworks)
AppKit Carbon Cocoa GSS ImageCaptureCore ImageIO IOKit OSAKit Quartz
QuartzCore WebKit;
};
emacs29-macport = callPackage (self.sources.emacs29-macport) {
inherit gconf;
inherit (pkgs.darwin) sigtool;
inherit (pkgs.darwin.apple_sdk.frameworks)
AppKit Carbon Cocoa GSS ImageCaptureCore ImageIO IOKit OSAKit Quartz
QuartzCore WebKit;
};
}) })

View file

@ -4,14 +4,29 @@
}: }:
let let
metaFor = variant: version: rev: { mkArgs = { pname, version, variant, rev, hash }: {
homepage = { inherit pname version variant;
"mainline" = "https://www.gnu.org/software/emacs/";
"macport" = "https://bitbucket.org/mituharu/emacs-mac/"; src = {
"mainline" = (fetchFromSavannah {
repo = "emacs";
inherit rev hash;
});
"macport" = (fetchFromBitbucket {
owner = "mituharu";
repo = "emacs-mac";
inherit rev hash;
});
}.${variant}; }.${variant};
description = "The extensible, customizable GNU text editor"
+ lib.optionalString (variant == "macport") " - macport variant"; meta = {
longDescription = '' homepage = {
"mainline" = "https://www.gnu.org/software/emacs/";
"macport" = "https://bitbucket.org/mituharu/emacs-mac/";
}.${variant};
description = "The extensible, customizable GNU text editor"
+ lib.optionalString (variant == "macport") " - macport variant";
longDescription = ''
GNU Emacs is an extensible, customizable text editorand more. At its core GNU Emacs is an extensible, customizable text editorand more. At its core
is an interpreter for Emacs Lisp, a dialect of the Lisp programming is an interpreter for Emacs Lisp, a dialect of the Lisp programming
language with extensions to support text editing. language with extensions to support text editing.
@ -30,79 +45,57 @@ let
This release is built from Mitsuharu Yamamoto's patched source code This release is built from Mitsuharu Yamamoto's patched source code
tailored for macOS. tailored for macOS.
''; '';
changelog = { changelog = {
"mainline" = "https://www.gnu.org/savannah-checkouts/gnu/emacs/news/NEWS.${version}"; "mainline" = "https://www.gnu.org/savannah-checkouts/gnu/emacs/news/NEWS.${version}";
"macport" = "https://bitbucket.org/mituharu/emacs-mac/raw/${rev}/NEWS-mac"; "macport" = "https://bitbucket.org/mituharu/emacs-mac/raw/${rev}/NEWS-mac";
}.${variant}; }.${variant};
license = lib.licenses.gpl3Plus; license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ maintainers = with lib.maintainers; [
AndersonTorres AndersonTorres
adisbladis adisbladis
atemu atemu
jwiegley jwiegley
lovek323 lovek323
matthewbauer matthewbauer
]; ];
platforms = { platforms = {
"mainline" = lib.platforms.all; "mainline" = lib.platforms.all;
"macport" = lib.platforms.darwin; "macport" = lib.platforms.darwin;
}.${variant}; }.${variant};
mainProgram = "emacs"; mainProgram = "emacs";
};
}; };
in in
{ {
emacs28 = import ./generic.nix { emacs28 = import ./generic.nix (mkArgs {
pname = "emacs"; pname = "emacs";
version = "28.2"; version = "28.2";
variant = "mainline"; variant = "mainline";
src = fetchFromSavannah { rev = "28.2";
repo = "emacs"; hash = "sha256-4oSLcUDR0MOEt53QOiZSVU8kPJ67GwugmBxdX3F15Ag=";
rev = "28.2"; });
hash = "sha256-4oSLcUDR0MOEt53QOiZSVU8kPJ67GwugmBxdX3F15Ag=";
};
meta = metaFor "mainline" "28.2" "28.2"; emacs29 = import ./generic.nix (mkArgs {
};
emacs29 = import ./generic.nix {
pname = "emacs"; pname = "emacs";
version = "29.1"; version = "29.1";
variant = "mainline"; variant = "mainline";
src = fetchFromSavannah { rev = "29.1";
repo = "emacs"; hash = "sha256-3HDCwtOKvkXwSULf3W7YgTz4GV8zvYnh2RrL28qzGKg=";
rev = "29.1"; });
hash = "sha256-3HDCwtOKvkXwSULf3W7YgTz4GV8zvYnh2RrL28qzGKg=";
};
meta = metaFor "mainline" "29.1" "29.1"; emacs28-macport = import ./generic.nix (mkArgs {
};
emacs28-macport = import ./generic.nix {
pname = "emacs-mac"; pname = "emacs-mac";
version = "28.2"; version = "28.2";
variant = "macport"; variant = "macport";
src = fetchFromBitbucket { rev = "emacs-28.2-mac-9.1";
owner = "mituharu"; hash = "sha256-Ne2jQ2nVLNiQmnkkOXVc5AkLVkTpm8pFC7VNY2gQjPE=";
repo = "emacs-mac"; });
rev = "emacs-28.2-mac-9.1";
hash = "sha256-Ne2jQ2nVLNiQmnkkOXVc5AkLVkTpm8pFC7VNY2gQjPE=";
};
meta = metaFor "macport" "28.2" "emacs-28.2-mac-9.1"; emacs29-macport = import ./generic.nix (mkArgs {
};
emacs29-macport = import ./generic.nix {
pname = "emacs-mac"; pname = "emacs-mac";
version = "29.1"; version = "29.1";
variant = "macport"; variant = "macport";
rev = "emacs-29.1-mac-10.0";
src = fetchFromBitbucket { hash = "sha256-TE829qJdPjeOQ+kD0SfyO8d5YpJjBge/g+nScwj+XVU=";
owner = "mituharu"; });
repo = "emacs-mac";
rev = "emacs-29.1-mac-10.0";
hash = "sha256-TE829qJdPjeOQ+kD0SfyO8d5YpJjBge/g+nScwj+XVU=";
};
meta = metaFor "macport" "29.1" "emacs-29.1-mac-10.0";
};
} }