nixpkgs/pkgs/by-name/bi/bitwarden-cli/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

80 lines
1.8 KiB
Nix

{ lib
, stdenv
, buildNpmPackage
, nodejs_20
, fetchFromGitHub
, python3
, cctools
, nix-update-script
, nixosTests
, xcbuild
}:
buildNpmPackage rec {
pname = "bitwarden-cli";
version = "2024.9.0";
src = fetchFromGitHub {
owner = "bitwarden";
repo = "clients";
rev = "cli-v${version}";
hash = "sha256-o5nRG2j73qheDOyeFfSga64D8HbTn1EUrCiN0W+Xn0w=";
};
postPatch = ''
# remove code under unfree license
rm -r bitwarden_license
'';
nodejs = nodejs_20;
npmDepsHash = "sha256-L7/frKCNlq0xr6T+aSqyEQ44yrIXwcpdU/djrhCJNNk=";
nativeBuildInputs = [
(python3.withPackages (ps: with ps; [ setuptools ]))
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
cctools
xcbuild.xcrun
];
makeCacheWritable = true;
env = {
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
npm_config_build_from_source = "true";
};
# node-argon2 builds with LTO, but that causes missing symbols. So disable it
# and rebuild. See https://github.com/ranisalt/node-argon2/pull/415
preConfigure = ''
pushd node_modules/argon2
substituteInPlace binding.gyp --replace-fail '"-flto", ' ""
"$npm_config_node_gyp" rebuild
popd
'';
npmBuildScript = "build:oss:prod";
npmWorkspace = "apps/cli";
npmFlags = [ "--legacy-peer-deps" ];
passthru = {
tests = {
vaultwarden = nixosTests.vaultwarden.sqlite;
};
updateScript = nix-update-script {
extraArgs = [ "--commit" "--version=stable" "--version-regex=^cli-v(.*)$" ];
};
};
meta = with lib; {
changelog = "https://github.com/bitwarden/clients/releases/tag/${src.rev}";
description = "Secure and free password manager for all of your devices";
homepage = "https://bitwarden.com";
license = lib.licenses.gpl3Only;
mainProgram = "bw";
maintainers = with maintainers; [ dotlambda ];
};
}