tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
wine, winetricks: add updateScript
Ryan Hendrickson
3 years ago
729486a6
836c2dfd
+125
4 changed files
expand all
collapse all
unified
split
pkgs
applications
emulators
wine
base.nix
sources.nix
update-lib.sh
winetricks.nix
+1
pkgs/applications/emulators/wine/base.nix
···
185
185
186
186
passthru = {
187
187
inherit pkgArches;
188
188
+
inherit (src) updateScript;
188
189
tests = { inherit (nixosTests) wine; };
189
190
};
190
191
meta = {
+71
pkgs/applications/emulators/wine/sources.nix
···
12
12
pkgs.fetchFromGitHub { inherit owner repo rev sha256; } // args;
13
13
fetchFromGitLab = args@{domain, owner, repo, rev, sha256, ...}:
14
14
pkgs.fetchFromGitLab { inherit domain owner repo rev sha256; } // args;
15
15
+
16
16
+
updateScriptPreamble = ''
17
17
+
set -eou pipefail
18
18
+
PATH=${with pkgs; lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused jq nix ]}
19
19
+
sources_file=${__curPos.file}
20
20
+
source ${./update-lib.sh}
21
21
+
'';
22
22
+
23
23
+
inherit (pkgs) writeShellScript;
15
24
in rec {
16
25
17
26
stable = fetchurl rec {
···
42
51
# Also look for root certificates at $NIX_SSL_CERT_FILE
43
52
./cert-path.patch
44
53
];
54
54
+
55
55
+
updateScript = writeShellScript "update-wine-stable" (''
56
56
+
${updateScriptPreamble}
57
57
+
major=''${UPDATE_NIX_OLD_VERSION%.*}
58
58
+
latest_stable=$(get_latest_wine_version "$major.0")
59
59
+
latest_gecko=$(get_latest_lib_version wine-gecko)
60
60
+
61
61
+
# Can't use autobump on stable because we don't want the path
62
62
+
# <source/7.0/wine-7.0.tar.xz> to become <source/7.0.1/wine-7.0.1.tar.xz>.
63
63
+
if [[ "$UPDATE_NIX_OLD_VERSION" != "$latest_stable" ]]; then
64
64
+
set_version_and_sha256 stable "$latest_stable" "$(nix-prefetch-url "$wine_url_base/source/$major.0/wine-$latest_stable.tar.xz")"
65
65
+
fi
66
66
+
67
67
+
autobump stable.gecko32 "$latest_gecko"
68
68
+
autobump stable.gecko64 "$latest_gecko"
69
69
+
70
70
+
do_update
71
71
+
'');
45
72
};
46
73
47
74
unstable = fetchurl rec {
···
56
83
url = "https://dl.winehq.org/wine/wine-mono/${version}/wine-mono-${version}-x86.msi";
57
84
sha256 = "sha256-ZBP/Mo679+x2icZI/rNUbYEC3thlB50fvwMxsUs6sOw=";
58
85
};
86
86
+
87
87
+
updateScript = writeShellScript "update-wine-unstable" ''
88
88
+
${updateScriptPreamble}
89
89
+
major=''${UPDATE_NIX_OLD_VERSION%.*}
90
90
+
latest_unstable=$(get_latest_wine_version "$major.x")
91
91
+
latest_mono=$(get_latest_lib_version wine-mono)
92
92
+
93
93
+
update_staging() {
94
94
+
staging_url=$(get_source_attr staging.url)
95
95
+
set_source_attr staging sha256 "\"$(to_sri "$(nix-prefetch-url --unpack "''${staging_url//$1/$2}")")\""
96
96
+
}
97
97
+
98
98
+
autobump unstable "$latest_unstable" "" update_staging
99
99
+
autobump unstable.mono "$latest_mono"
100
100
+
101
101
+
do_update
102
102
+
'';
59
103
};
60
104
61
105
staging = fetchFromGitHub rec {
···
81
125
inherit (unstable) gecko32 gecko64;
82
126
83
127
inherit (unstable) mono;
128
128
+
129
129
+
updateScript = writeShellScript "update-wine-wayland" ''
130
130
+
${updateScriptPreamble}
131
131
+
wayland_rev=$(get_source_attr wayland.rev)
132
132
+
133
133
+
latest_wayland_rev=$(curl -s 'https://gitlab.collabora.com/api/v4/projects/2847/repository/branches/wayland' | jq -r .commit.id)
134
134
+
135
135
+
if [[ "$wayland_rev" != "$latest_wayland_rev" ]]; then
136
136
+
latest_wayland=$(curl -s 'https://gitlab.collabora.com/alf/wine/-/raw/wayland/VERSION' | cut -f3 -d' ')
137
137
+
wayland_url=$(get_source_attr wayland.url)
138
138
+
set_version_and_sha256 wayland "$latest_wayland" "$(nix-prefetch-url --unpack "''${wayland_url/$wayland_rev/$latest_wayland_rev}")"
139
139
+
set_source_attr wayland rev "\"$latest_wayland_rev\""
140
140
+
fi
141
141
+
142
142
+
do_update
143
143
+
'';
84
144
};
85
145
86
146
winetricks = fetchFromGitHub rec {
···
90
150
owner = "Winetricks";
91
151
repo = "winetricks";
92
152
rev = version;
153
153
+
154
154
+
updateScript = writeShellScript "update-winetricks" ''
155
155
+
${updateScriptPreamble}
156
156
+
winetricks_repourl=$(get_source_attr winetricks.gitRepoUrl)
157
157
+
158
158
+
latest_winetricks=$(list-git-tags --url="$winetricks_repourl" | grep -E '^[0-9]{8}$' | sort --reverse --numeric-sort | head -n 1)
159
159
+
160
160
+
autobump winetricks "$latest_winetricks" 'nix-prefetch-url --unpack'
161
161
+
162
162
+
do_update
163
163
+
'';
93
164
};
94
165
}
+49
pkgs/applications/emulators/wine/update-lib.sh
···
1
1
+
wine_url_base=https://dl.winehq.org/wine
2
2
+
3
3
+
sed_exprs=()
4
4
+
5
5
+
get_source_attr() {
6
6
+
nix-instantiate --eval --json -E "(let pkgs = import ./. {}; in pkgs.callPackage $sources_file { inherit pkgs; }).$1" | jq -r
7
7
+
}
8
8
+
9
9
+
set_source_attr() {
10
10
+
path="$1"
11
11
+
name="$2"
12
12
+
value="$3"
13
13
+
line=$(nix-instantiate --eval -E "(builtins.unsafeGetAttrPos \"$name\" (let pkgs = import ./. {}; in pkgs.callPackage $sources_file { inherit pkgs; }).$path).line")
14
14
+
sed_exprs+=(-e "${line}s@[^ ].*\$@$name = $value;@")
15
15
+
}
16
16
+
17
17
+
set_version_and_sha256() {
18
18
+
set_source_attr "$1" version "\"$2\""
19
19
+
set_source_attr "$1" sha256 "\"$(to_sri "$3")\""
20
20
+
}
21
21
+
22
22
+
get_latest_wine_version() {
23
23
+
list-directory-versions --pname=wine --url="$wine_url_base/source/$1" | grep -v 'diff\|rc\|tar' | sort --reverse --version-sort -u | head -n 1
24
24
+
}
25
25
+
26
26
+
get_latest_lib_version() {
27
27
+
curl -s "$wine_url_base/$1/" | grep -o 'href="[0-9.]*/"' | sed 's_^href="\(.*\)/"_\1_' | sort --reverse --version-sort -u | head -n 1
28
28
+
}
29
29
+
30
30
+
to_sri() {
31
31
+
nix --extra-experimental-features nix-command hash to-sri --type sha256 "$1"
32
32
+
}
33
33
+
34
34
+
autobump() {
35
35
+
attr="$1"
36
36
+
latest="$2"
37
37
+
fetcher="${3:-nix-prefetch-url}"
38
38
+
more="${4:-}"
39
39
+
version=$(get_source_attr "$attr.version")
40
40
+
if [[ "$version" != "$latest" ]]; then
41
41
+
url=$(get_source_attr "$attr.url")
42
42
+
set_version_and_sha256 "$attr" "$latest" "$($fetcher "${url//$version/$latest}")"
43
43
+
[[ -z "$more" ]] || $more "$version" "$latest"
44
44
+
fi
45
45
+
}
46
46
+
47
47
+
do_update() {
48
48
+
[[ "${#sed_exprs[@]}" -eq 0 ]] || sed -i "${sed_exprs[@]}" "$sources_file"
49
49
+
}
+4
pkgs/applications/emulators/wine/winetricks.nix
···
24
24
"$out/bin/winetricks"
25
25
'';
26
26
27
27
+
passthru = {
28
28
+
inherit (src) updateScript;
29
29
+
};
30
30
+
27
31
meta = {
28
32
description = "A script to install DLLs needed to work around problems in Wine";
29
33
license = lib.licenses.lgpl21;