From 2842021bf9d21bc50ed4f61d1faf9c254f3c08ef Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 25 Aug 2024 14:00:09 -0300 Subject: [PATCH] onedrive: rework - finalAttrs - lib.enable* flags - ghet rid of pname - test version - get rid of nested with - nixfmt-rfc-style --- pkgs/by-name/on/onedrive/package.nix | 88 +++++++++++++++++----------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/pkgs/by-name/on/onedrive/package.nix b/pkgs/by-name/on/onedrive/package.nix index 89faea0f5657..8a10eaa2dddb 100644 --- a/pkgs/by-name/on/onedrive/package.nix +++ b/pkgs/by-name/on/onedrive/package.nix @@ -1,57 +1,79 @@ -{ stdenv -, lib -, fetchFromGitHub -, autoreconfHook -, ldc -, installShellFiles -, pkg-config -, curl -, sqlite -, libnotify -, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd -, systemd +{ + lib, + autoreconfHook, + curl, + fetchFromGitHub, + installShellFiles, + ldc, + libnotify, + pkg-config, + sqlite, + stdenv, + systemd, + testers, + # Boolean flags + withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "onedrive"; version = "2.4.25"; src = fetchFromGitHub { owner = "abraunegg"; - repo = pname; - rev = "v${version}"; + repo = "onedrive"; + rev = "v${finalAttrs.version}"; hash = "sha256-M6EOJiykmAKWIuAXdm9ebTSX1eVoO+1axgzxlAmuI8U="; }; - nativeBuildInputs = [ autoreconfHook ldc installShellFiles pkg-config ]; + outputs = [ + "out" + "doc" + "man" + ]; + + nativeBuildInputs = [ + autoreconfHook + installShellFiles + ldc + pkg-config + ]; buildInputs = [ curl - sqlite libnotify - ] ++ lib.optional withSystemd systemd; + sqlite + ] ++ lib.optionals withSystemd [ systemd ]; configureFlags = [ - "--enable-notifications" - ] ++ lib.optionals withSystemd [ - "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system" - "--with-systemduserunitdir=${placeholder "out"}/lib/systemd/user" + (lib.enableFeature true "notifications") + (lib.withFeatureAs withSystemd "systemdsystemunitdir" "${placeholder "out"}/lib/systemd/system") + (lib.withFeatureAs withSystemd "systemduserunitdir" "${placeholder "out"}/lib/systemd/user") ]; # we could also pass --enable-completions to configure but we would then have to # figure out the paths manually and pass those along. postInstall = '' - installShellCompletion --bash --name ${pname} contrib/completions/complete.bash - installShellCompletion --zsh --name _${pname} contrib/completions/complete.zsh - installShellCompletion --fish --name ${pname} contrib/completions/complete.fish + installShellCompletion --bash --name onedrive contrib/completions/complete.bash + installShellCompletion --fish --name onedrive contrib/completions/complete.fish + installShellCompletion --zsh --name _onedrive contrib/completions/complete.zsh ''; - meta = with lib; { - description = "Complete tool to interact with OneDrive on Linux"; - mainProgram = "onedrive"; - homepage = "https://github.com/abraunegg/onedrive"; - license = licenses.gpl3Only; - maintainers = with maintainers; [ peterhoeg bertof ]; - platforms = platforms.linux; + passthru = { + tests.version = testers.testVersion { + package = finalAttrs.finalPackage; + }; }; -} + + meta = { + homepage = "https://github.com/abraunegg/onedrive"; + description = "Complete tool to interact with OneDrive on Linux"; + license = lib.licenses.gpl3Only; + mainProgram = "onedrive"; + maintainers = with lib.maintainers; [ + peterhoeg + bertof + ]; + platforms = lib.platforms.linux; + }; +})