nixpkgs/pkgs/applications/misc/keeweb/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

68 lines
2.0 KiB
Nix

{ lib, stdenv, fetchurl, appimageTools, undmg, libsecret }:
let
inherit (stdenv.hostPlatform) system;
throwSystem = throw "Unsupported system: ${system}";
pname = "keeweb";
version = "1.16.5";
name = "${pname}-${version}";
suffix = {
x86_64-linux = "linux.AppImage";
x86_64-darwin = "mac.x64.dmg";
aarch64-darwin = "mac.arm64.dmg";
}.${system} or throwSystem;
src = fetchurl {
url = "https://github.com/keeweb/keeweb/releases/download/v${version}/KeeWeb-${version}.${suffix}";
sha256 = {
x86_64-linux = "18qcr8zyn20n5zrrha0qwgq2ic10bp189fps87lbnmcjknrkac9g";
x86_64-darwin = "0crpjkcqgs7q5c814bx2npjh9kpyyb87yagm5wcy9j21kwrbqv6k";
aarch64-darwin = "1wkf9inrm5qg0c4xrk0s97mx5j21xvlqwwkvydl513gyfzi2g9gp";
}.${system} or throwSystem;
};
appimageContents = appimageTools.extract {
inherit name src;
};
meta = with lib; {
description = "Free cross-platform password manager compatible with KeePass";
homepage = "https://keeweb.info/";
license = licenses.mit;
maintainers = with maintainers; [ sikmir ];
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
linux = appimageTools.wrapType2 rec {
inherit name src meta;
extraPkgs = pkgs: with pkgs; [ libsecret ];
extraInstallCommands = ''
mv $out/bin/{${name},${pname}}
install -Dm644 ${appimageContents}/keeweb.desktop -t $out/share/applications
install -Dm644 ${appimageContents}/keeweb.png -t $out/share/icons/hicolor/256x256/apps
install -Dm644 ${appimageContents}/usr/share/mime/keeweb.xml -t $out/share/mime
substituteInPlace $out/share/applications/keeweb.desktop \
--replace 'Exec=AppRun' 'Exec=${pname}'
'';
};
darwin = stdenv.mkDerivation {
inherit pname version src meta;
nativeBuildInputs = [ undmg ];
sourceRoot = "KeeWeb.app";
installPhase = ''
mkdir -p $out/Applications/KeeWeb.app
cp -R . $out/Applications/KeeWeb.app
'';
};
in
if stdenv.isDarwin
then darwin
else linux