From 9d5713843f65cd0dcf06d40dd34d8b1f2bd25da8 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sat, 29 Jul 2023 00:35:01 -0300 Subject: [PATCH] ed: refactor A crazy refactor that factors the sources to a separate file, in order to accomodate extra sources in parallel to the stable one. --- pkgs/applications/editors/ed/default.nix | 51 +++++------------------- pkgs/applications/editors/ed/generic.nix | 30 ++++++++++++++ pkgs/applications/editors/ed/sources.nix | 34 ++++++++++++++++ pkgs/top-level/all-packages.nix | 3 +- 4 files changed, 77 insertions(+), 41 deletions(-) create mode 100644 pkgs/applications/editors/ed/generic.nix create mode 100644 pkgs/applications/editors/ed/sources.nix diff --git a/pkgs/applications/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix index af6c8f7c6f8d..cf27d772596f 100644 --- a/pkgs/applications/editors/ed/default.nix +++ b/pkgs/applications/editors/ed/default.nix @@ -1,42 +1,13 @@ -{ lib, stdenv, fetchurl, lzip }: +{ lib, pkgs }: -# Note: this package is used for bootstrapping fetchurl, and thus -# cannot use fetchpatch! All mutable patches (generated by GitHub or -# cgit) that are needed here should be included directly in Nixpkgs as -# files. +lib.makeScope pkgs.newScope (self: + let + inherit (self) callPackage; + in { + sources = import ./sources.nix { + inherit lib; + inherit (pkgs) fetchurl; + }; -stdenv.mkDerivation rec { - pname = "ed"; - version = "1.19"; - - src = fetchurl { - url = "mirror://gnu/ed/${pname}-${version}.tar.lz"; - hash = "sha256-zi8uXEJHkKqW0J2suT2bv9wLfrYknJy3U4RS6Ox3zUg="; - }; - - nativeBuildInputs = [ lzip ]; - - configureFlags = [ - "CC=${stdenv.cc.targetPrefix}cc" - ]; - - doCheck = true; - - meta = { - description = "An implementation of the standard Unix editor"; - longDescription = '' - GNU ed is a line-oriented text editor. It is used to create, - display, modify and otherwise manipulate text files, both - interactively and via shell scripts. A restricted version of ed, - red, can only edit files in the current directory and cannot - execute shell commands. Ed is the "standard" text editor in the - sense that it is the original editor for Unix, and thus widely - available. For most purposes, however, it is superseded by - full-screen editors such as GNU Emacs or GNU Moe. - ''; - license = lib.licenses.gpl3Plus; - homepage = "https://www.gnu.org/software/ed/"; - maintainers = [ ]; - platforms = lib.platforms.unix; - }; -} + ed = callPackage (self.sources.ed) { }; + }) diff --git a/pkgs/applications/editors/ed/generic.nix b/pkgs/applications/editors/ed/generic.nix new file mode 100644 index 000000000000..70ec6badf25e --- /dev/null +++ b/pkgs/applications/editors/ed/generic.nix @@ -0,0 +1,30 @@ +{ pname +, version +, src +, patches ? [ ] +, meta +}: + +# Note: this package is used for bootstrapping fetchurl, and thus cannot use +# fetchpatch! All mutable patches (generated by GitHub or cgit) that are needed +# here should be included directly in Nixpkgs as files. + +{ lib +, stdenv +, fetchurl +, lzip +}: + +stdenv.mkDerivation { + inherit pname version src patches; + + nativeBuildInputs = [ lzip ]; + + configureFlags = [ + "CC=${stdenv.cc.targetPrefix}cc" + ]; + + doCheck = true; + + inherit meta; +} diff --git a/pkgs/applications/editors/ed/sources.nix b/pkgs/applications/editors/ed/sources.nix new file mode 100644 index 000000000000..5d3535a834dc --- /dev/null +++ b/pkgs/applications/editors/ed/sources.nix @@ -0,0 +1,34 @@ +{ lib +, fetchurl +}: + +let + meta = { + description = "The GNU implementation of the standard Unix editor"; + longDescription = '' + GNU ed is a line-oriented text editor. It is used to create, display, + modify and otherwise manipulate text files, both interactively and via + shell scripts. A restricted version of ed, red, can only edit files in the + current directory and cannot execute shell commands. Ed is the 'standard' + text editor in the sense that it is the original editor for Unix, and thus + widely available. For most purposes, however, it is superseded by + full-screen editors such as GNU Emacs or GNU Moe. + ''; + license = lib.licenses.gpl3Plus; + homepage = "https://www.gnu.org/software/ed/"; + maintainers = with lib.maintainers; [ AndersonTorres ]; + platforms = lib.platforms.unix; + }; +in +{ + ed = let + pname = "ed"; + version = "1.19"; + src = fetchurl { + url = "mirror://gnu/ed/ed-${version}.tar.lz"; + hash = "sha256-zi8uXEJHkKqW0J2suT2bv9wLfrYknJy3U4RS6Ox3zUg="; + }; + in import ./generic.nix { + inherit pname version src meta; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 53d510124184..3b74a7ae8cb1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -30991,7 +30991,8 @@ with pkgs; ecs-agent = callPackage ../applications/virtualization/ecs-agent { }; - ed = callPackage ../applications/editors/ed { }; + inherit (recurseIntoAttrs (callPackage ../applications/editors/ed { })) + ed; edbrowse = callPackage ../applications/editors/edbrowse { };