-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
110 lines (99 loc) · 2.88 KB
/
flake.nix
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
rec {
description = "A Elden Ring save file editor for the command line";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ self
, nixpkgs
, flake-utils
}:
let
erutils-drv =
{ lib
, clang13Stdenv
, fetchFromGitHub
, cmake
, fmt_latest
, openssl
}:
let
# Kept in sync with submodules, make sure to update this accordingly.
submodules = {
erdb = fetchFromGitHub {
owner = "EldenRingDatabase";
repo = "erdb";
rev = "87e931605b137f320fae894bddb139aaa54615cb";
sha256 = "sha256-1eauIs6RzzFoElF3IAywGPIgsD+4mlKxENx8TtWNMFU=";
};
};
copySubmodules = lib.concatMapStringsSep "\n"
(submodule: ''
mkdir -p external/${submodule}
cp -r ${submodules.${submodule}}/* external/${submodule}
'')
(builtins.attrNames submodules);
buildDate =
let
year = lib.substring 0 4 self.lastModifiedDate;
month = lib.substring 4 2 self.lastModifiedDate;
day = lib.substring 6 2 self.lastModifiedDate;
in
"${year}-${month}-${day}";
in
clang13Stdenv.mkDerivation rec {
pname = "erutils";
version = "0.pre+date=${buildDate}";
src = lib.cleanSourceWith {
src = lib.cleanSource self;
filter = name: type:
!(baseNameOf name == "build" && type == "directory") && !(baseNameOf name == "generateditems.h" && type == "file");
};
nativeBuildInputs = [
cmake
];
buildInputs = [
fmt_latest
openssl
];
cmakeFlags = [
"-DVERSION=${buildDate}"
];
preConfigure = copySubmodules;
doInstallCheck = true;
installCheckPhase = ''
./erutils --version | grep -q 'v${buildDate}' || exit 1
echo "found version 'v${buildDate}'";
'';
meta = with lib; {
inherit description;
homepage = "https://github.com/IvarWithoutBones/erutils";
license = licenses.asl20;
platforms = platforms.unix;
};
};
in
{
overlays =
let
erutils = final: prev: {
erutils = final.callPackage erutils-drv { };
};
in
{
inherit erutils;
default = erutils;
};
} // flake-utils.lib.eachDefaultSystem (system:
let
inherit (nixpkgs.legacyPackages.${system}) callPackage;
erutils = callPackage erutils-drv { };
in
{
packages = {
inherit erutils;
default = erutils;
};
});
}