-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkFlatPak.nix
More file actions
52 lines (49 loc) · 1.23 KB
/
mkFlatPak.nix
File metadata and controls
52 lines (49 loc) · 1.23 KB
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
{
lib,
flatpak-builder,
runCommand,
toArx, # This is the nix-bundle package/derivation
}:
{
program,
pname ? (lib.last (lib.splitString "/" program)),
name ? pname,
appId ? "io.github.${pname}",
}:
let
manifest = builtins.toFile "manifest.json" (
builtins.toJSON {
app-id = appId;
runtime = "org.freedesktop.Platform";
runtime-version = "23.08";
sdk = "org.freedesktop.Sdk";
command = pname;
modules = [
{
name = pname;
buildsystem = "simple";
build-commands = [
"install -D ${toArx} /app/bin/${pname}"
];
}
];
}
);
in
runCommand "${name}-flatpak"
{
nativeBuildInputs = [ flatpak-builder ];
# flatpak-builder requires a writable HOME for cache and lock files
HOME = "/build";
# See issue https://github.com/DigitalBrewStudios/nix-bundle-flatpak/issues/1 for more info.
meta.broken = true;
}
''
export XDG_CACHE_HOME=$TMPDIR/flatpak-cache
mkdir -p $XDG_CACHE_HOME
# Build the Flatpak repo
flatpak-builder --repo=repo --force-clean build-dir ${manifest}
# Export the final .flatpak bundle
mkdir -p $out
flatpak build-bundle repo $out/${name}.flatpak ${appId}
''