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 { lib
, buildGoModule , buildGoModule
, fetchFromGitHub , fetchFromGitHub
, runCommand , callPackage
}: }:
let let
pname = "elvish"; pname = "elvish";
version = "0.19.2"; version = "0.19.2";
shellPath = "/bin/elvish";
in in
buildGoModule { buildGoModule {
inherit pname version; inherit pname version;
@@ -32,26 +31,12 @@ buildGoModule {
strictDeps = true; strictDeps = true;
doCheck = false; 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 = { passthru = {
inherit shellPath; shellPath = "/bin/elvish";
tests = {
expectVersion = callPackage ./tests/expect-version.nix { };
};
}; };
meta = { meta = {
@@ -63,6 +48,6 @@ buildGoModule {
status, it is already suitable for most daily interactive use. status, it is already suitable for most daily interactive use.
''; '';
license = lib.licenses.bsd2; 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 { }; sedutil = callPackage ../tools/security/sedutil { };
elvish = callPackage ../shells/elvish { };
emplace = callPackage ../tools/package-management/emplace { }; emplace = callPackage ../tools/package-management/emplace { };
enchive = callPackage ../tools/security/enchive { }; enchive = callPackage ../tools/security/enchive { };