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

View file

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