sbt-extras: Convert VM test into installCheckPhase

This commit is contained in:
Tim Steinbach 2021-02-21 18:34:07 -05:00 committed by Tim Steinbach
parent a59e171286
commit cb72a93d2e
3 changed files with 50 additions and 54 deletions

View File

@ -345,7 +345,6 @@ in
samba-wsdd = handleTest ./samba-wsdd.nix {};
sanoid = handleTest ./sanoid.nix {};
sbt = handleTest ./sbt.nix {};
sbt-extras = handleTest ./sbt-extras.nix {};
sddm = handleTest ./sddm.nix {};
searx = handleTest ./searx.nix {};
service-runner = handleTest ./service-runner.nix {};

View File

@ -1,16 +0,0 @@
import ./make-test-python.nix ({ pkgs, ...} : {
name = "sbt-extras";
meta = with pkgs.lib.maintainers; {
maintainers = [ nequissimus ];
};
machine = { pkgs, ... }:
{
environment.systemPackages = [ pkgs.sbt-extras ];
};
testScript =
''
machine.succeed("(sbt -h)")
'';
})

View File

@ -1,6 +1,20 @@
{ lib, stdenv, fetchFromGitHub, which, curl, makeWrapper, jdk, writeScript
, common-updater-scripts, cacert, git, nixfmt, nix, jq, coreutils, gnused
, nixosTests }:
{ lib
, stdenv
, fetchFromGitHub
, which
, curl
, makeWrapper
, jdk
, writeScript
, common-updater-scripts
, cacert
, git
, nixfmt
, nix
, jq
, coreutils
, gnused
}:
stdenv.mkDerivation rec {
pname = "sbt-extras";
@ -28,41 +42,40 @@ stdenv.mkDerivation rec {
wrapProgram $out/bin/sbt --prefix PATH : ${lib.makeBinPath [ which curl ]}
'';
passthru = {
tests = { inherit (nixosTests) sbt-extras; };
doInstallCheck = true;
installCheckPhase = ''
$out/bin/sbt -h >/dev/null
'';
updateScript = writeScript "update.sh" ''
#!${stdenv.shell}
set -xo errexit
PATH=${
lib.makeBinPath [
common-updater-scripts
curl
cacert
git
nixfmt
nix
jq
coreutils
gnused
]
}
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')"
latestSha="$(curl -L -s https://api.github.com/repos/paulp/sbt-extras/commits\?sha\=master\&since\=$oldVersion | jq -r '.[0].sha')"
if [ ! "null" = "$latestSha" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
default_nix="$nixpkgs/pkgs/development/tools/build-managers/sbt-extras/default.nix"
latestDate="$(curl -L -s https://api.github.com/repos/paulp/sbt-extras/commits/$latestSha | jq '.commit.committer.date' | sed 's|"\(.*\)T.*|\1|g')"
update-source-version ${pname} "$latestSha" --version-key=rev
update-source-version ${pname} "$latestDate" --ignore-same-hash
nixfmt "$default_nix"
else
echo "${pname} is already up-to-date"
fi
'';
};
passthru.updateScript = writeScript "update.sh" ''
#!${stdenv.shell}
set -xo errexit
PATH=${
lib.makeBinPath [
common-updater-scripts
curl
cacert
git
nixfmt
nix
jq
coreutils
gnused
]
}
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')"
latestSha="$(curl -L -s https://api.github.com/repos/paulp/sbt-extras/commits\?sha\=master\&since\=$oldVersion | jq -r '.[0].sha')"
if [ ! "null" = "$latestSha" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
default_nix="$nixpkgs/pkgs/development/tools/build-managers/sbt-extras/default.nix"
latestDate="$(curl -L -s https://api.github.com/repos/paulp/sbt-extras/commits/$latestSha | jq '.commit.committer.date' | sed 's|"\(.*\)T.*|\1|g')"
update-source-version ${pname} "$latestSha" --version-key=rev
update-source-version ${pname} "$latestDate" --ignore-same-hash
nixfmt "$default_nix"
else
echo "${pname} is already up-to-date"
fi
'';
meta = {
description =