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,7 +4,22 @@
}: }:
let let
metaFor = variant: version: rev: { 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};
meta = {
homepage = { homepage = {
"mainline" = "https://www.gnu.org/software/emacs/"; "mainline" = "https://www.gnu.org/software/emacs/";
"macport" = "https://bitbucket.org/mituharu/emacs-mac/"; "macport" = "https://bitbucket.org/mituharu/emacs-mac/";
@ -49,60 +64,38 @@ let
}.${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 {
repo = "emacs";
rev = "28.2"; rev = "28.2";
hash = "sha256-4oSLcUDR0MOEt53QOiZSVU8kPJ67GwugmBxdX3F15Ag="; 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 {
repo = "emacs";
rev = "29.1"; rev = "29.1";
hash = "sha256-3HDCwtOKvkXwSULf3W7YgTz4GV8zvYnh2RrL28qzGKg="; 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 {
owner = "mituharu";
repo = "emacs-mac";
rev = "emacs-28.2-mac-9.1"; rev = "emacs-28.2-mac-9.1";
hash = "sha256-Ne2jQ2nVLNiQmnkkOXVc5AkLVkTpm8pFC7VNY2gQjPE="; 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";
src = fetchFromBitbucket {
owner = "mituharu";
repo = "emacs-mac";
rev = "emacs-29.1-mac-10.0"; rev = "emacs-29.1-mac-10.0";
hash = "sha256-TE829qJdPjeOQ+kD0SfyO8d5YpJjBge/g+nScwj+XVU="; hash = "sha256-TE829qJdPjeOQ+kD0SfyO8d5YpJjBge/g+nScwj+XVU=";
}; });
meta = metaFor "macport" "29.1" "emacs-29.1-mac-10.0";
};
} }