Skip to content

Commit

Permalink
emacs: refactor
Browse files Browse the repository at this point in the history
- Remove the excessive repetition of inherited packages
- Factor the excessive repetition of metadata in sources.nix
  • Loading branch information
AndersonTorres committed Aug 26, 2023
1 parent e05a78c commit f6a6dc8
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 96 deletions.
44 changes: 12 additions & 32 deletions pkgs/applications/editors/emacs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
})
121 changes: 57 additions & 64 deletions pkgs/applications/editors/emacs/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 editor—and more. At its core
is an interpreter for Emacs Lisp, a dialect of the Lisp programming
language with extensions to support text editing.
Expand All @@ -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=";
};

meta = metaFor "mainline" "28.2" "28.2";
};
rev = "28.2";
hash = "sha256-4oSLcUDR0MOEt53QOiZSVU8kPJ67GwugmBxdX3F15Ag=";
});

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=";
};

meta = metaFor "macport" "28.2" "emacs-28.2-mac-9.1";
};
rev = "emacs-28.2-mac-9.1";
hash = "sha256-Ne2jQ2nVLNiQmnkkOXVc5AkLVkTpm8pFC7VNY2gQjPE=";
});

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=";
});
}

0 comments on commit f6a6dc8

Please sign in to comment.