Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions bundlers/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
lib,
flake-parts-lib,
inputs,
...
}:
{
imports = [
(flake-parts-lib.mkTransposedPerSystemModule {
name = "bundlers";
option = lib.mkOption {
type = lib.types.lazyAttrsOf (lib.types.functionTo lib.types.package);
default = { };
};
file = ./flake.nix;
})
];

perSystem =
{
pkgs,
inputs',
config,
...
}:
let
nfpmConfig =
pkg:
pkgs.writeText "${pkg.pname}-nfpm-config.yaml" (
builtins.toJSON {
name = pkg.pname;
inherit (pkg)
version
;
inherit (pkg.meta)
homepage
description
;
license = pkg.meta.license.spdxId or null;
contents = [
{
src = lib.getExe pkg;
dst = "/usr/bin/${pkg.meta.mainProgram or (lib.getName pkg)}";
}
];
}
);

installerFor =
packager: pkg:
pkgs.runCommand "${pkg.pname}-${packager}-pkg" { } ''
mkdir -p "$out"
cd "$out"
${lib.getExe pkgs.nfpm} package \
--config ${nfpmConfig pkg} \
--packager ${packager} \
--target "$out"
'';

installers = [
"deb" # Debian/Ubuntu
"rpm" # Fedora/RHEL/SUSE
"apk" # Alpine
"archlinux" # Arch
];

nfpmBundlers = lib.pipe installers [
(lib.map (i: {
name = "to${lib.toUpper (lib.substring 0 1 i)}${lib.substring 1 (-1) i}";
value = installerFor i;
}))
lib.listToAttrs
];
in
{
bundlers = {
toAppimage = inputs'.nix-appimage.bundlers.default;
} // nfpmBundlers;
};
}
131 changes: 2 additions & 129 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,6 @@
};
};

nix-bundlers = {
url = "github:NixOS/bundlers";
inputs.nixpkgs.follows = "nixpkgs";
# TODO: re-add when CI's `nix` starts supporting transitive overrides
# inputs.nix-utils.inputs.nixpkgs.follows = "nixpkgs";
# inputs.nix-utils.inputs.flake-utils.follows = "flake-utils";
# inputs.nix-bundle.inputs.utils.follows = "flake-utils";
};

nix-appimage = {
url = "github:ralismark/nix-appimage";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -263,6 +254,7 @@
./modules
./packages
./shells
./bundlers
];
systems = [
"x86_64-linux"
Expand Down
Loading