Skip to content

Commit

Permalink
pkgs/by-name: testVersion -> checkVersionHook where applicable
Browse files Browse the repository at this point in the history
This should help

- Simplify expressions
- Reduce (some) repition/workarounds
- Improve automated testing by making these checks a requirement to
  build
- Maintain consistency between which of these version check
  implementations are used across pkgs/by-name
- Provide more real-world examples of this newly added hook
- Avoid #312345 in many places
  • Loading branch information
getchoo committed Jul 16, 2024
1 parent 8d26c67 commit b1eb076
Show file tree
Hide file tree
Showing 207 changed files with 851 additions and 1,114 deletions.
10 changes: 5 additions & 5 deletions pkgs/by-name/al/alephone/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
SDL2_ttf,
speex,
unzip,
versionCheckHook,
zlib,
zziplib,
alephone,
testers,
}:

stdenv.mkDerivation (finalAttrs: {
Expand Down Expand Up @@ -86,6 +86,10 @@ stdenv.mkDerivation (finalAttrs: {
zziplib
];

# test that the version is correct
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

configureFlags = [ "--with-boost-libdir=${boost.out}/lib" ];
makeFlags = [ "AR:=$(AR)" ];

Expand All @@ -101,10 +105,6 @@ stdenv.mkDerivation (finalAttrs: {
popd
'';

passthru.tests.version =
# test that the version is correct
testers.testVersion { package = alephone; };

meta = {
description = "Aleph One is the open source continuation of Bungie’s Marathon 2 game engine";
mainProgram = "alephone";
Expand Down
10 changes: 4 additions & 6 deletions pkgs/by-name/am/amazon-ssm-agent/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
, bashInteractive
, nix-update-script
, nixosTests
, testers
, amazon-ssm-agent
, versionCheckHook
}:

let
Expand Down Expand Up @@ -143,13 +142,12 @@ buildGoModule rec {
--prefix PATH : "${lib.makeBinPath [ bashInteractive ]}"
'';

nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

passthru = {
tests = {
inherit (nixosTests) amazon-ssm-agent;
version = testers.testVersion {
package = amazon-ssm-agent;
command = "amazon-ssm-agent --version";
};
};
updateScript = nix-update-script { };
};
Expand Down
8 changes: 2 additions & 6 deletions pkgs/by-name/an/ansible-cmdb/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
fetchFromGitHub,
substituteAll,
python3Packages,
testers,
ansible-cmdb,
versionCheckHook,
}:
let
inherit (python3Packages)
Expand Down Expand Up @@ -45,10 +44,7 @@ buildPythonApplication {
jsonxs
];

passthru.tests.version = testers.testVersion {
package = ansible-cmdb;
version = "v${version}";
};
nativeInstallCheckInputs = [ versionCheckHook ];

meta = {
description = "Generate host overview from ansible fact gathering output";
Expand Down
10 changes: 3 additions & 7 deletions pkgs/by-name/ap/aphorme/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
, libxkbcommon
, libGL
, stdenv
, testers
, aphorme
, autoPatchelfHook
, versionCheckHook
}:

rustPlatform.buildRustPackage rec {
Expand Down Expand Up @@ -35,11 +34,8 @@ rustPlatform.buildRustPackage rec {
libxkbcommon
];

passthru.tests.version = testers.testVersion {
package = aphorme;
command = "aphorme --version";
version = "aphorme ${version}";
};
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

meta = {
description = "Program launcher for window managers, written in Rust";
Expand Down
14 changes: 5 additions & 9 deletions pkgs/by-name/ap/apvlv/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
libxml2,
libxshmfence,
man,
nix-update-script,
pcre,
pkg-config,
poppler,
stdenv,
testers,
versionCheckHook,
webkitgtk,
wrapGAppsHook3,
}:
Expand Down Expand Up @@ -89,13 +88,10 @@ stdenv.mkDerivation (finalAttrs: {
"../apvlv.desktop"
];

passthru = {
tests.version = testers.testVersion {
command = "${lib.getExe finalAttrs.finalPackage} -v";
package = finalAttrs.finalPackage;
version = "${finalAttrs.version}-rel";
};
};
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

versionCheckProgramArg = "-v";

meta = {
changelog = "https://github.com/naihe2010/apvlv/blob/v${finalAttrs.version}/NEWS";
Expand Down
10 changes: 4 additions & 6 deletions pkgs/by-name/ar/artalk/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
lib,
buildGoModule,
fetchFromGitHub,
artalk,
fetchurl,
installShellFiles,
stdenv,
testers,
versionCheckHook,
}:
buildGoModule rec {
pname = "artalk";
Expand Down Expand Up @@ -41,6 +40,9 @@ buildGoModule rec {

nativeBuildInputs = [ installShellFiles ];

nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

postInstall =
''
# work around case insensitive file systems
Expand All @@ -54,10 +56,6 @@ buildGoModule rec {
--zsh <($out/bin/artalk completion zsh)
'';

passthru.tests = {
version = testers.testVersion { package = artalk; };
};

meta = {
description = "Self-hosted comment system";
homepage = "https://github.com/ArtalkJS/Artalk";
Expand Down
10 changes: 3 additions & 7 deletions pkgs/by-name/at/athens/package.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{ lib
, fetchFromGitHub
, buildGoModule
, testers
, athens
, versionCheckHook
}:
buildGoModule rec {
pname = "athens";
Expand All @@ -26,11 +25,8 @@ buildGoModule rec {
mv $out/bin/proxy $out/bin/athens
'';

passthru = {
tests.version = testers.testVersion {
package = athens;
};
};
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

meta = with lib; {
description = "Go module datastore and proxy";
Expand Down
12 changes: 5 additions & 7 deletions pkgs/by-name/aw/awscli2/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
, fetchpatch
, installShellFiles
, nix-update-script
, testers
, awscli2
, versionCheckHook
}:

let
Expand Down Expand Up @@ -121,6 +120,8 @@ py.pkgs.buildPythonApplication rec {
pytestCheckHook
];

nativeInstallCheckInputs = [ versionCheckHook ];

postInstall = ''
installShellCompletion --cmd aws \
--bash <(echo "complete -C $out/bin/aws_completer aws") \
Expand Down Expand Up @@ -154,17 +155,14 @@ py.pkgs.buildPythonApplication rec {
"awscli"
];

versionCheckProgram = "${placeholder "out"}/bin/aws";

passthru = {
python = py; # for aws_shell
updateScript = nix-update-script {
# Excludes 1.x versions from the Github tags list
extraArgs = [ "--version-regex" "^(2\.(.*))" ];
};
tests.version = testers.testVersion {
package = awscli2;
command = "aws --version";
inherit version;
};
};

meta = with lib; {
Expand Down
7 changes: 4 additions & 3 deletions pkgs/by-name/ba/basedpyright/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
buildNpmPackage,
python3,
stdenvNoCC,
testers,
basedpyright,
versionCheckHook
}:

let
Expand Down Expand Up @@ -112,9 +111,11 @@ buildNpmPackage rec {

dontNpmBuild = true;

nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

passthru = {
updateScript = ./update.sh;
tests.version = testers.testVersion { package = basedpyright; };
};

meta = {
Expand Down
1 change: 1 addition & 0 deletions pkgs/by-name/be/benchexec/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ python3.pkgs.buildPythonApplication rec {

passthru.tests =
let
# TODO: maybe allow `versionCheckHook` to support doing this?
testVersion = result: testers.testVersion {
command = "${result} --version";
package = benchexec;
Expand Down
9 changes: 4 additions & 5 deletions pkgs/by-name/bl/blade-formatter/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
runCommand,
blade-formatter,
nodejs,
versionCheckHook,
}:

buildNpmPackage rec {
Expand All @@ -26,14 +27,12 @@ buildNpmPackage rec {

npmDepsHash = "sha256-wEz0DTbg+Fdmsf0Qyeu9QS+I8gkPJeaJC/3HuP913og=";

nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

passthru = {
updateScript = ./update.sh;
tests = {
version = testers.testVersion {
package = blade-formatter;
command = "blade-formatter --version";
};

simple = testers.testEqualContents {
assertion = "blade-formatter formats a basic blade file";
expected = writeText "expected" ''
Expand Down
1 change: 1 addition & 0 deletions pkgs/by-name/bl/blastem/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';

# TODO: use `versionCheckHook` when possible
passthru.tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "blastem -v";
Expand Down
6 changes: 4 additions & 2 deletions pkgs/by-name/bl/blueutil/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
stdenv,
fetchFromGitHub,
darwin,
testers,
nix-update-script,
versionCheckHook
}:

let
Expand Down Expand Up @@ -37,8 +37,10 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';

nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

passthru = {
tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
updateScript = nix-update-script { };
};

Expand Down
12 changes: 6 additions & 6 deletions pkgs/by-name/ca/caddy/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
, buildGoModule
, fetchFromGitHub
, nixosTests
, caddy
, testers
, installShellFiles
, stdenv
, versionCheckHook
}:
let
version = "2.8.4";
Expand Down Expand Up @@ -61,12 +60,13 @@ buildGoModule {
--zsh <($out/bin/caddy completion zsh)
'';

nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

versionCheckProgramArg = "version";

passthru.tests = {
inherit (nixosTests) caddy;
version = testers.testVersion {
command = "${caddy}/bin/caddy version";
package = caddy;
};
};

meta = with lib; {
Expand Down
9 changes: 4 additions & 5 deletions pkgs/by-name/ca/cargo-shear/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
fetchFromGitHub,
lib,
rustPlatform,
testers,
cargo-shear,
versionCheckHook
}:
let
version = "1.0.0";
Expand All @@ -23,9 +22,9 @@ rustPlatform.buildRustPackage {

# https://github.com/Boshen/cargo-shear/blob/a0535415a3ea94c86642f39f343f91af5cdc3829/src/lib.rs#L20-L23
SHEAR_VERSION = version;
passthru.tests.version = testers.testVersion {
package = cargo-shear;
};

nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

meta = {
description = "Detect and remove unused dependencies from Cargo.toml";
Expand Down
7 changes: 3 additions & 4 deletions pkgs/by-name/ca/castxml/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
llvmPackages,
python3,
stdenv,
testers,
versionCheckHook,
zlib,
# Boolean flags
withHTML ? true,
Expand Down Expand Up @@ -59,9 +59,8 @@ stdenv.mkDerivation (finalAttrs: {

strictDeps = true;

passthru.tests = testers.testVersion {
package = finalAttrs.finalPackage;
};
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;

meta = {
homepage = "https://github.com/CastXML/CastXML";
Expand Down
Loading

0 comments on commit b1eb076

Please sign in to comment.