Skip to content

Commit 958f694

Browse files
committed
feat(bundlers)!: Export deb, rpm and AppImage bundlers
- All logic is contained in a new `./bundlers/default.nix` module - Add a `bundlers` `perSystem` output - Export `deb` and `rpm` bundlers from our fork of `juliosueiras-nix/nix-utils` (used by `NixOS/bundlers`, which we originally used) - Export the `AppImage` bundler from `ralismark/nix-appimage`
1 parent 6b5a645 commit 958f694

File tree

3 files changed

+81
-79
lines changed

3 files changed

+81
-79
lines changed

bundlers/default.nix

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
lib,
3+
flake-parts-lib,
4+
inputs,
5+
...
6+
}:
7+
{
8+
imports = [
9+
(flake-parts-lib.mkTransposedPerSystemModule {
10+
name = "bundlers";
11+
option = lib.mkOption {
12+
type = lib.types.lazyAttrsOf (lib.types.functionTo lib.types.package);
13+
default = { };
14+
};
15+
file = ./flake.nix;
16+
})
17+
];
18+
19+
perSystem =
20+
{
21+
pkgs,
22+
inputs',
23+
config,
24+
...
25+
}:
26+
let
27+
nfpmConfig =
28+
pkg:
29+
pkgs.writeText "${pkg.pname}-nfpm-config.yaml" (
30+
builtins.toJSON {
31+
name = pkg.pname;
32+
inherit (pkg)
33+
version
34+
;
35+
inherit (pkg.meta)
36+
homepage
37+
description
38+
;
39+
license = pkg.meta.license.spdxId or null;
40+
contents = [
41+
{
42+
src = lib.getExe pkg;
43+
dst = "/usr/bin/${pkg.meta.mainProgram or (lib.getName pkg)}";
44+
}
45+
];
46+
}
47+
);
48+
49+
installerFor =
50+
packager: pkg:
51+
pkgs.runCommand "${pkg.pname}-${packager}-pkg" { } ''
52+
mkdir -p "$out"
53+
cd "$out"
54+
${lib.getExe pkgs.nfpm} package \
55+
--config ${nfpmConfig pkg} \
56+
--packager ${packager} \
57+
--target "$out"
58+
'';
59+
60+
installers = [
61+
"deb" # Debian/Ubuntu
62+
"rpm" # Fedora/RHEL/SUSE
63+
"apk" # Alpine
64+
"archlinux" # Arch
65+
];
66+
67+
nfpmBundlers = lib.pipe installers [
68+
(lib.map (i: {
69+
name = "to${lib.toUpper (lib.substring 0 1 i)}${lib.substring 1 (-1) i}";
70+
value = installerFor i;
71+
}))
72+
lib.listToAttrs
73+
];
74+
in
75+
{
76+
bundlers = {
77+
toAppimage = inputs'.nix-appimage.bundlers.default;
78+
} // nfpmBundlers;
79+
};
80+
}

flake.lock

Lines changed: 0 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,6 @@
229229
};
230230
};
231231

232-
nix-bundlers = {
233-
url = "github:NixOS/bundlers";
234-
inputs.nixpkgs.follows = "nixpkgs";
235-
# TODO: re-add when CI's `nix` starts supporting transitive overrides
236-
# inputs.nix-utils.inputs.nixpkgs.follows = "nixpkgs";
237-
# inputs.nix-utils.inputs.flake-utils.follows = "flake-utils";
238-
# inputs.nix-bundle.inputs.utils.follows = "flake-utils";
239-
};
240-
241232
nix-appimage = {
242233
url = "github:ralismark/nix-appimage";
243234
inputs.nixpkgs.follows = "nixpkgs";
@@ -263,6 +254,7 @@
263254
./modules
264255
./packages
265256
./shells
257+
./bundlers
266258
];
267259
systems = [
268260
"x86_64-linux"

0 commit comments

Comments
 (0)