Merge pull request #300 from Lykos153/feature/bundlers
Add option perSystem.<>.bundlers
This commit is contained in:
commit
8f8bb951b2
3 changed files with 44 additions and 0 deletions
|
|
@ -83,6 +83,18 @@ rec {
|
|||
};
|
||||
};
|
||||
|
||||
bundlersExample = mkFlake
|
||||
{ inputs.self = { }; }
|
||||
{
|
||||
imports = [ flake-parts.flakeModules.bundlers ];
|
||||
systems = [ "a" "b" ];
|
||||
perSystem = { system, ... }: {
|
||||
packages.hello = pkg system "hello";
|
||||
bundlers.toTarball = drv: pkg system "tarball-${drv.name}";
|
||||
bundlers.toAppImage = drv: pkg system "appimage-${drv.name}";
|
||||
};
|
||||
};
|
||||
|
||||
modulesFlake = mkFlake
|
||||
{
|
||||
inputs.self = { };
|
||||
|
|
@ -251,6 +263,9 @@ rec {
|
|||
};
|
||||
};
|
||||
|
||||
assert bundlersExample.bundlers.a.toTarball (pkg "a" "hello") == pkg "a" "tarball-hello";
|
||||
assert bundlersExample.bundlers.b.toAppImage (pkg "b" "hello") == pkg "b" "appimage-hello";
|
||||
|
||||
# - exported package becomes part of overlay.
|
||||
# - perSystem is invoked for the right system, when system is non-memoized
|
||||
assert nixpkgsWithEasyOverlay.hello == pkg "x86_64-linux" "hello";
|
||||
|
|
|
|||
28
extras/bundlers.nix
Normal file
28
extras/bundlers.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{ lib
|
||||
, flake-parts-lib
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
inherit
|
||||
(lib)
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
inherit
|
||||
(flake-parts-lib)
|
||||
mkTransposedPerSystemModule
|
||||
;
|
||||
in
|
||||
mkTransposedPerSystemModule {
|
||||
name = "bundlers";
|
||||
option = mkOption {
|
||||
type = types.lazyAttrsOf (types.functionTo types.package);
|
||||
default = { };
|
||||
description = ''
|
||||
An attribute set of bundlers to be used by [`nix bundle`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-bundle.html).
|
||||
|
||||
`nix bundle --bundler .#<name>` <derivation> will bundle <derivation> using the bundler `bundlers.<name>`.
|
||||
'';
|
||||
};
|
||||
file = ./bundlers.nix;
|
||||
}
|
||||
|
|
@ -50,6 +50,7 @@
|
|||
flakeModules = ./extras/flakeModules.nix;
|
||||
modules = ./extras/modules.nix;
|
||||
partitions = ./extras/partitions.nix;
|
||||
bundlers = ./extras/bundlers.nix;
|
||||
};
|
||||
in
|
||||
lib.mkFlake { inherit inputs; } {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue