nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5
6 # native
7 autoreconfHook,
8 installShellFiles,
9 ldc,
10 pkg-config,
11
12 # host
13 coreutils,
14 curl,
15 dbus,
16 libnotify,
17 sqlite,
18 systemd,
19 testers,
20
21 # Boolean flags
22 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
23}:
24
25stdenv.mkDerivation (finalAttrs: {
26 pname = "onedrive";
27 version = "2.5.6";
28
29 src = fetchFromGitHub {
30 owner = "abraunegg";
31 repo = "onedrive";
32 rev = "v${finalAttrs.version}";
33 hash = "sha256-AFaz1RkrtsdTZfaWobdcADbzsAhbdCzJPkQX6Pa7hN8=";
34 };
35
36 outputs = [
37 "out"
38 "doc"
39 "man"
40 ];
41
42 nativeBuildInputs = [
43 autoreconfHook
44 installShellFiles
45 ldc
46 pkg-config
47 ];
48
49 buildInputs = [
50 curl
51 dbus
52 libnotify
53 sqlite
54 ]
55 ++ lib.optionals withSystemd [ systemd ];
56
57 configureFlags = [
58 (lib.enableFeature true "notifications")
59 (lib.withFeatureAs withSystemd "systemdsystemunitdir" "${placeholder "out"}/lib/systemd/system")
60 (lib.withFeatureAs withSystemd "systemduserunitdir" "${placeholder "out"}/lib/systemd/user")
61 ];
62
63 # we could also pass --enable-completions to configure but we would then have to
64 # figure out the paths manually and pass those along.
65 postInstall = ''
66 installShellCompletion --cmd onedrive \
67 --bash contrib/completions/complete.bash \
68 --fish contrib/completions/complete.fish \
69 --zsh contrib/completions/complete.zsh
70
71 for s in $out/lib/systemd/user/onedrive.service $out/lib/systemd/system/onedrive@.service; do
72 substituteInPlace $s \
73 --replace-fail "/usr/bin/sleep" "${coreutils}/bin/sleep"
74 done
75 '';
76
77 passthru = {
78 tests.version = testers.testVersion {
79 package = finalAttrs.finalPackage;
80 version = "v${finalAttrs.version}";
81 };
82 };
83
84 meta = {
85 homepage = "https://github.com/abraunegg/onedrive";
86 description = "Complete tool to interact with OneDrive on Linux";
87 license = lib.licenses.gpl3Only;
88 mainProgram = "onedrive";
89 maintainers = with lib.maintainers; [
90 peterhoeg
91 bertof
92 ];
93 platforms = lib.platforms.linux;
94 };
95})