summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/da/daggerfall-unity/package.nix
blob: 2a94cbc6b451c382d27d41ae3aa974009b27bb7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
  alsa-lib,
  autoPatchelfHook,
  copyDesktopItems,
  fetchurl,
  fetchzip,
  lib,
  libGL,
  libpulseaudio,
  libudev0-shim,
  libxcursor,
  libxi,
  libxinerama,
  libxrandr,
  libxscrnsaver,
  libxxf86vm,
  makeDesktopItem,
  nix-update-script,
  stdenv,
  vulkan-loader,
  zlib,
  pname ? "daggerfall-unity",
  includeUnfree ? false,
}:
let
  docFiles = [
    (fetchurl {
      url = "https://www.dfworkshop.net/static_files/daggerfallunity/Daggerfall%20Unity%20Manual.pdf";
      hash = "sha256-FywlD0K5b4vUWzyzANlF9575XTDLivbsym7F+qe0Dm8=";
      name = "Daggerfall Unity Manual.pdf";
      meta.license = lib.licenses.mit;
    })
  ]
  ++ lib.optionals includeUnfree [
    (fetchurl {
      url = "https://cdn.bethsoft.com/bethsoft.com/manuals/Daggerfall/daggerfall-en.pdf";
      hash = "sha256-24KSP/E7+KvSRTMDq63NVlVWTFZnQj1yya8wc36yrC0=";
      meta.license = lib.licenses.unfree;
    })
  ];
in
stdenv.mkDerivation (finalAttrs: {
  inherit pname;
  version = "1.1.1";

  src = fetchzip {
    url = "https://github.com/Interkarma/daggerfall-unity/releases/download/v${finalAttrs.version}/dfu_linux_64bit-v${finalAttrs.version}.zip";
    hash = "sha256-JuhhVLpREM9e9UtlDttvFUhHWpH7Sh79OEo1OM4ggKA=";
    stripRoot = false;
  };

  nativeBuildInputs = [
    autoPatchelfHook
    copyDesktopItems
  ];

  buildInputs = [
    alsa-lib
    libGL
    libpulseaudio
    libudev0-shim
    libxcursor
    libxi
    libxinerama
    libxrandr
    libxscrnsaver
    libxxf86vm
    vulkan-loader
    zlib
  ];

  strictDeps = true;

  installPhase = ''
    runHook preInstall

    mkdir --parents "$out/bin" "$out/share/doc" "$out/share/icons/hicolor/128x128/apps/"
    cp --recursive * "$out"
    ln --symbolic "$out/${finalAttrs.meta.mainProgram}" "$out/bin/"
    ln --symbolic $out/DaggerfallUnity_Data/Resources/UnityPlayer.png $out/share/icons/hicolor/128x128/apps/daggerfall-unity.png

    ${lib.strings.concatMapStringsSep "\n" (file: ''
      cp "${file}" "$out/share/doc/${file.name}"
    '') docFiles}

    runHook postInstall
  '';

  appendRunpaths = [ (lib.makeLibraryPath finalAttrs.buildInputs) ];

  desktopItems = [
    (makeDesktopItem {
      name = "daggerfall-unity";
      desktopName = "Daggerfall Unity";
      comment = finalAttrs.meta.description;
      icon = "daggerfall-unity";
      exec = finalAttrs.meta.mainProgram;
      categories = [ "Game" ];
    })
  ];

  passthru.updateScript = nix-update-script {
    extraArgs = [ "--version-regex=^v(\\d+(\\.\\d+)*)$" ];
  };

  meta = {
    homepage = "https://www.dfworkshop.net/";
    description = "Open source recreation of Daggerfall in the Unity engine";
    longDescription = ''
      Daggerfall Unity is an open source recreation of Daggerfall in the Unity engine created by Daggerfall Workshop.

      Experience the adventure and intrigue of Daggerfall with all of its original charm along with hundreds of fixes, quality of life enhancements, and extensive mod support.

      Includes Daggerfall Unity manual.

      ${lib.optionalString includeUnfree ''
        This "unfree" variant also includes the manual for Daggerfall (the game, not the open source engine).
      ''}
    '';
    changelog = "https://github.com/Interkarma/daggerfall-unity/releases/tag/v${finalAttrs.version}";
    mainProgram = "DaggerfallUnity.x86_64";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ l0b0 ];
    platforms = [ "x86_64-linux" ];
  };
})