nixpkgs/pkgs/by-name/yu/yubico-piv-tool/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

108 lines
2.5 KiB
Nix

{
lib,
check,
cmake,
darwin,
fetchFromGitHub,
gengetopt,
help2man,
nix-update-script,
openssl,
pcsclite,
pkg-config,
stdenv,
testers,
zlib,
withApplePCSC ? stdenv.hostPlatform.isDarwin,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "yubico-piv-tool";
version = "2.6.1";
outputs = [
"out"
"dev"
"man"
];
src = fetchFromGitHub {
owner = "Yubico";
repo = "yubico-piv-tool";
rev = "refs/tags/yubico-piv-tool-${finalAttrs.version}";
hash = "sha256-RYT/kBlUfVkJG8RNELVQ5gyC+HDteD5xqaI479nsvKw=";
};
postPatch = ''
substituteInPlace CMakeLists.txt --replace-fail "-Werror" ""
'';
nativeBuildInputs = [
cmake
gengetopt
help2man
pkg-config
];
buildInputs = [
openssl
zlib
] ++ (if withApplePCSC then [ darwin.apple_sdk.frameworks.PCSC ] else [ pcsclite ]);
cmakeFlags = [
(lib.cmakeBool "GENERATE_MAN_PAGES" true)
(lib.cmakeFeature "BACKEND" (if withApplePCSC then "macscard" else "pcsc"))
(lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin")
(lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include")
(lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib")
(lib.cmakeFeature "CMAKE_INSTALL_MANDIR" "share/man")
];
doCheck = true;
nativeCheckInputs = [ check ];
passthru = {
updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"yubico-piv-tool-([0-9.]+)$"
];
};
tests = {
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "yubico-piv-tool --version";
};
};
};
meta = {
homepage = "https://developers.yubico.com/yubico-piv-tool/";
changelog = "https://developers.yubico.com/yubico-piv-tool/Release_Notes.html";
description = ''
Used for interacting with the Privilege and Identification Card (PIV)
application on a YubiKey
'';
longDescription = ''
The Yubico PIV tool is used for interacting with the Privilege and
Identification Card (PIV) application on a YubiKey.
With it you may generate keys on the device, importing keys and
certificates, and create certificate requests, and other operations.
A shared library and a command-line tool is included.
'';
license = lib.licenses.bsd2;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [
viraptor
anthonyroussel
];
mainProgram = "yubico-piv-tool";
pkgConfigModules = [
"ykcs11"
"ykpiv"
];
};
})