mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 23:36:17 +01:00
Merge pull request #330755 from museoa/upload-micro
micro: adopt and rework
This commit is contained in:
commit
0ed15c6879
7 changed files with 158 additions and 99 deletions
|
@ -1,67 +0,0 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, buildGoModule
|
||||
, fetchFromGitHub
|
||||
, installShellFiles
|
||||
, callPackage
|
||||
, wl-clipboard
|
||||
, xclip
|
||||
, makeWrapper
|
||||
, withXclip ? true
|
||||
, withWlclip ? true
|
||||
}:
|
||||
let
|
||||
clipboardPkgs = if stdenv.isLinux then
|
||||
lib.optional withXclip xclip ++
|
||||
lib.optional withWlclip wl-clipboard
|
||||
else [ ];
|
||||
in
|
||||
buildGoModule rec {
|
||||
pname = "micro";
|
||||
version = "2.0.13";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "zyedidia";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
hash = "sha256-fe+7RkUwCveBk14bYzg5uLGOqTVVJsrqixBQhCS79hY=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-ePhObvm3m/nT+7IyT0W6K+y+9UNkfd2kYjle2ffAd9Y=";
|
||||
|
||||
nativeBuildInputs = [ installShellFiles makeWrapper ];
|
||||
|
||||
subPackages = [ "cmd/micro" ];
|
||||
|
||||
ldflags = let t = "github.com/zyedidia/micro/v2/internal"; in [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X ${t}/util.Version=${version}"
|
||||
"-X ${t}/util.CommitHash=${src.rev}"
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
GOOS= GOARCH= go generate ./runtime
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
installManPage assets/packaging/micro.1
|
||||
install -Dm444 -t $out/share/applications assets/packaging/micro.desktop
|
||||
install -Dm644 assets/micro-logo-mark.svg $out/share/icons/hicolor/scalable/apps/micro.svg
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
wrapProgram "$out/bin/micro" \
|
||||
--prefix PATH : "${lib.makeBinPath clipboardPkgs}"
|
||||
'';
|
||||
|
||||
passthru.tests.expect = callPackage ./test-with-expect.nix { };
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://micro-editor.github.io";
|
||||
description = "Modern and intuitive terminal-based text editor";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ dtzWill ];
|
||||
mainProgram = "micro";
|
||||
};
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
{ micro, expect, runCommand, writeScript }:
|
||||
|
||||
let expect-script = writeScript "expect-script" ''
|
||||
#!${expect}/bin/expect -f
|
||||
|
||||
spawn micro file.txt
|
||||
expect "file.txt"
|
||||
|
||||
send "Hello world!"
|
||||
expect "Hello world!"
|
||||
|
||||
# Send ctrl-q (exit)
|
||||
send "\021"
|
||||
|
||||
expect "Save changes to file.txt before closing?"
|
||||
send "y"
|
||||
|
||||
expect eof
|
||||
''; in
|
||||
runCommand "micro-test-expect"
|
||||
{
|
||||
nativeBuildInputs = [ micro expect ];
|
||||
passthru = { inherit expect-script; };
|
||||
} ''
|
||||
# Micro really wants a writable $HOME for its config directory.
|
||||
export HOME=$(pwd)
|
||||
expect -f ${expect-script}
|
||||
grep "Hello world!" file.txt
|
||||
touch $out
|
||||
''
|
113
pkgs/by-name/mi/micro/package.nix
Normal file
113
pkgs/by-name/mi/micro/package.nix
Normal file
|
@ -0,0 +1,113 @@
|
|||
{
|
||||
lib,
|
||||
stdenv,
|
||||
buildGoModule,
|
||||
fetchFromGitHub,
|
||||
installShellFiles,
|
||||
callPackage,
|
||||
wl-clipboard,
|
||||
xclip,
|
||||
makeWrapper,
|
||||
# Boolean flags
|
||||
withXclip ? stdenv.isLinux,
|
||||
withWlClipboard ?
|
||||
if withWlclip != null then
|
||||
lib.warn ''
|
||||
withWlclip is deprecated and will be removed;
|
||||
use withWlClipboard instead.
|
||||
'' withWlclip
|
||||
else
|
||||
stdenv.isLinux,
|
||||
# Deprecated options
|
||||
# Remove them before or right after next version update from Nixpkgs or this
|
||||
# package itself
|
||||
withWlclip ? null,
|
||||
}:
|
||||
|
||||
let
|
||||
self = buildGoModule {
|
||||
pname = "micro";
|
||||
version = "2.0.13";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "zyedidia";
|
||||
repo = "micro";
|
||||
rev = "v${self.version}";
|
||||
hash = "sha256-fe+7RkUwCveBk14bYzg5uLGOqTVVJsrqixBQhCS79hY=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-ePhObvm3m/nT+7IyT0W6K+y+9UNkfd2kYjle2ffAd9Y=";
|
||||
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"man"
|
||||
];
|
||||
|
||||
subPackages = [ "cmd/micro" ];
|
||||
|
||||
ldflags =
|
||||
let
|
||||
t = "github.com/zyedidia/micro/v2/internal";
|
||||
in
|
||||
[
|
||||
"-s"
|
||||
"-w"
|
||||
"-X ${t}/util.Version=${self.version}"
|
||||
"-X ${t}/util.CommitHash=${self.src.rev}"
|
||||
];
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
preBuild = ''
|
||||
GOOS= GOARCH= go generate ./runtime
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
installManPage assets/packaging/micro.1
|
||||
install -Dm444 assets/packaging/micro.desktop $out/share/applications/micro.desktop
|
||||
install -Dm644 assets/micro-logo-mark.svg $out/share/icons/hicolor/scalable/apps/micro.svg
|
||||
'';
|
||||
|
||||
postFixup =
|
||||
let
|
||||
clipboardPackages =
|
||||
lib.optionals withXclip [ xclip ]
|
||||
++ lib.optionals withWlClipboard [ wl-clipboard ];
|
||||
in
|
||||
lib.optionalString (withXclip || withWlClipboard) ''
|
||||
wrapProgram "$out/bin/micro" \
|
||||
--prefix PATH : "${lib.makeBinPath clipboardPackages}"
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tests = lib.packagesFromDirectoryRecursive {
|
||||
inherit callPackage;
|
||||
directory = ./tests;
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://micro-editor.github.io";
|
||||
description = "Modern and intuitive terminal-based text editor";
|
||||
longDescription = ''
|
||||
micro is a terminal-based text editor that aims to be easy to use and
|
||||
intuitive, while also taking advantage of the capabilities of modern
|
||||
terminals.
|
||||
|
||||
As its name indicates, micro aims to be somewhat of a successor to the
|
||||
nano editor by being easy to install and use. It strives to be enjoyable
|
||||
as a full-time editor for people who prefer to work in a terminal, or
|
||||
those who regularly edit files over SSH.
|
||||
'';
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "micro";
|
||||
maintainers = with lib.maintainers; [ AndersonTorres ];
|
||||
};
|
||||
};
|
||||
in
|
||||
self
|
13
pkgs/by-name/mi/micro/tests/_001-hello-expect/hello.tcl
Normal file
13
pkgs/by-name/mi/micro/tests/_001-hello-expect/hello.tcl
Normal file
|
@ -0,0 +1,13 @@
|
|||
spawn micro file.txt
|
||||
expect "file.txt"
|
||||
|
||||
send "Hello world!"
|
||||
expect "Hello world!"
|
||||
|
||||
# ctrl-q (exit)
|
||||
send "\021"
|
||||
|
||||
expect "Save changes to file.txt before closing?"
|
||||
send "y"
|
||||
|
||||
expect eof
|
26
pkgs/by-name/mi/micro/tests/_001-hello-expect/package.nix
Normal file
26
pkgs/by-name/mi/micro/tests/_001-hello-expect/package.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
expect,
|
||||
micro,
|
||||
runCommand,
|
||||
}:
|
||||
|
||||
let
|
||||
expect-script = builtins.path {
|
||||
name = "hello.tcl";
|
||||
path = ./hello.tcl;
|
||||
};
|
||||
in
|
||||
runCommand "micro-expect-hello-world"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
expect
|
||||
micro
|
||||
];
|
||||
}
|
||||
# Micro needs a writable $HOME for throwing its configuration
|
||||
''
|
||||
export HOME=$(pwd)
|
||||
expect -f ${expect-script}
|
||||
grep "Hello world!" file.txt
|
||||
cat file.txt > $out
|
||||
''
|
6
pkgs/by-name/mi/micro/tests/version.nix
Normal file
6
pkgs/by-name/mi/micro/tests/version.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{ micro, testers }:
|
||||
|
||||
testers.testVersion {
|
||||
package = micro;
|
||||
command = "micro -version";
|
||||
}
|
|
@ -32760,8 +32760,6 @@ with pkgs;
|
|||
|
||||
mythtv = libsForQt5.callPackage ../applications/video/mythtv { };
|
||||
|
||||
micro = callPackage ../applications/editors/micro { };
|
||||
|
||||
mle = callPackage ../applications/editors/mle { };
|
||||
|
||||
namaka = callPackage ../development/tools/misc/namaka { };
|
||||
|
|
Loading…
Reference in a new issue