8bffdd4ccf
This treewide conditions execution of the built applications for the purpose of generating shell completions behind `stdenv.buildPlatform.canExecute stdenv.hostPlatform`, which helps cross. This is a common issue I spot during review, let's prevent copy-paste errors by fixing it treewide.
Candidates were located with:
```shell
rg 'installShellCompletion' -l -tnix | xargs grep -F 'stdenv.buildPlatform.canExecute stdenv.hostPlatform' -L
```
Then I migrated the obvious cases which would not require a rebuild, as a means of testing.
This diff was not scripted. Should be zero rebuilds.
<details>
<summary>
Alternatives
</summary>
Alternatively I could have use this pattern:
```nix
postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
let
emulator = stdenv.hostPlatform.emulator buildPackages;
in
''
installShellCompletion --cmd foobar \
--bash <(${emulator} $out/bin/foobar completion bash) \
--fish <(${emulator} $out/bin/foobar completion fish) \
--zsh <(${emulator} $out/bin/foobar completion zsh)
''
);
```
but that would cause rebuilds and will also require testing.
---
An other alternative is to use the binary from the corresponding package in `buildPackages`.
This however would also cause rebuilds and will also require testing.
</details>
86 lines
1.9 KiB
Nix
86 lines
1.9 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
buildPythonPackage,
|
|
fetchFromGitHub,
|
|
pythonOlder,
|
|
installShellFiles,
|
|
setuptools-scm,
|
|
shtab,
|
|
importlib-metadata,
|
|
jaraco-classes,
|
|
jaraco-context,
|
|
jaraco-functools,
|
|
jeepney,
|
|
secretstorage,
|
|
pyfakefs,
|
|
pytestCheckHook,
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
pname = "keyring";
|
|
version = "25.6.0";
|
|
pyproject = true;
|
|
disabled = pythonOlder "3.8";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "jaraco";
|
|
repo = "keyring";
|
|
tag = "v${version}";
|
|
hash = "sha256-qu9HAlZMLlIVs8c9ClzWUljezhrt88gu1kouklMNxMY=";
|
|
};
|
|
|
|
build-system = [ setuptools-scm ];
|
|
|
|
nativeBuildInputs = [
|
|
installShellFiles
|
|
shtab
|
|
];
|
|
|
|
dependencies = [
|
|
jaraco-classes
|
|
jaraco-context
|
|
jaraco-functools
|
|
]
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [
|
|
jeepney
|
|
secretstorage
|
|
]
|
|
++ lib.optionals (pythonOlder "3.12") [ importlib-metadata ];
|
|
|
|
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
installShellCompletion --cmd keyring \
|
|
--bash <($out/bin/keyring --print-completion bash) \
|
|
--zsh <($out/bin/keyring --print-completion zsh)
|
|
'';
|
|
|
|
pythonImportsCheck = [
|
|
"keyring"
|
|
"keyring.backend"
|
|
];
|
|
|
|
nativeCheckInputs = [
|
|
pyfakefs
|
|
pytestCheckHook
|
|
];
|
|
|
|
disabledTestPaths = [
|
|
"tests/backends/test_macOS.py"
|
|
]
|
|
# These tests fail when sandboxing is enabled because they are unable to get a password from keychain.
|
|
++ lib.optional stdenv.hostPlatform.isDarwin "tests/test_multiprocess.py";
|
|
|
|
meta = with lib; {
|
|
description = "Store and access your passwords safely";
|
|
homepage = "https://github.com/jaraco/keyring";
|
|
changelog = "https://github.com/jaraco/keyring/blob/${src.tag}/NEWS.rst";
|
|
license = licenses.mit;
|
|
mainProgram = "keyring";
|
|
maintainers = with maintainers; [
|
|
lovek323
|
|
dotlambda
|
|
];
|
|
platforms = platforms.unix;
|
|
};
|
|
}
|