elvish: refactor

- move installCheck to passthru.tests
- migrate to by-name
This commit is contained in:
Anderson Torres 2023-09-18 14:24:35 -03:00
parent 88a627e012
commit c3f4c7f54c
4 changed files with 39 additions and 23 deletions

View file

@ -1,13 +1,12 @@
{ lib
, buildGoModule
, fetchFromGitHub
, runCommand
, callPackage
}:
let
pname = "elvish";
version = "0.19.2";
shellPath = "/bin/elvish";
in
buildGoModule {
inherit pname version;
@ -32,26 +31,12 @@ buildGoModule {
strictDeps = true;
doCheck = false;
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out${shellPath} -c "
fn expect {|key expected|
var actual = \$buildinfo[\$key]
if (not-eq \$actual \$expected) {
fail '\$buildinfo['\$key']: expected '(to-string \$expected)', got '(to-string \$actual)
}
}
expect version ${version}
"
runHook postInstallCheck
'';
passthru = {
inherit shellPath;
shellPath = "/bin/elvish";
tests = {
expectVersion = callPackage ./tests/expect-version.nix { };
};
};
meta = {
@ -63,6 +48,6 @@ buildGoModule {
status, it is already suitable for most daily interactive use.
'';
license = lib.licenses.bsd2;
maintainers = with lib.maintainers; [ vrthra AndersonTorres ];
maintainers = with lib.maintainers; [ AndersonTorres ];
};
}

View file

@ -0,0 +1,8 @@
fn expect {|key expected|
var actual = $buildinfo[$key]
if (not-eq $actual $expected) {
fail '$buildinfo['$key']: expected '(to-string $expected)', got '(to-string $actual)
}
}
expect version @version@

View file

@ -0,0 +1,25 @@
{ lib
, stdenv
, elvish
, substituteAll
}:
stdenv.mkDerivation {
pname = "elvish-simple-test";
inherit (elvish) version;
nativeBuildInputs = [ elvish ];
dontInstall = true;
buildCommand = ''
elvish ${substituteAll {
src = ./expect-version.elv;
inherit (elvish) version;
}}
touch $out
'';
meta.timeout = 10;
}

View file

@ -3749,8 +3749,6 @@ with pkgs;
sedutil = callPackage ../tools/security/sedutil { };
elvish = callPackage ../shells/elvish { };
emplace = callPackage ../tools/package-management/emplace { };
enchive = callPackage ../tools/security/enchive { };