mirror of
https://github.com/nix-community/flakelight.git
synced 2025-02-15 00:49:29 +01:00
Add support for bundlers
This commit is contained in:
parent
6d00e0f544
commit
d7c7f4634a
36
api_guide.md
36
api_guide.md
@ -610,6 +610,42 @@ For example, to set Rust and Zig formatters:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### bundlers
|
||||||
|
|
||||||
|
The `bundler` and `bundlers` options allow you to set `bundlers.${system}`
|
||||||
|
outputs.
|
||||||
|
|
||||||
|
`bundlers` is an attribute set of bundler functions or a function that takes
|
||||||
|
packages and returns an attribute set of bundler functions.
|
||||||
|
|
||||||
|
`bundler` sets `bundlers.default`.
|
||||||
|
|
||||||
|
For example, a bundler that returns the passed package:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
inputs.flakelight.url = "github:accelbread/flakelight";
|
||||||
|
outputs = { flakelight, ... }:
|
||||||
|
flakelight ./. {
|
||||||
|
bundler = x: x;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
As another example, a bundler that always returns `hello`:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
inputs.flakelight.url = "github:accelbread/flakelight";
|
||||||
|
outputs = { flakelight, ... }:
|
||||||
|
flakelight ./. {
|
||||||
|
bundlers = { hello, ... }: {
|
||||||
|
default = x: hello;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### nixosConfigurations and homeConfigurations
|
### nixosConfigurations and homeConfigurations
|
||||||
|
|
||||||
The `nixosConfigurations` and `homeConfigurations` attributes let you set
|
The `nixosConfigurations` and `homeConfigurations` attributes let you set
|
||||||
|
37
builtinModules/bundlers.nix
Normal file
37
builtinModules/bundlers.nix
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# flakelight -- Framework for simplifying flake setup
|
||||||
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
{ config, lib, flakelight, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkMerge mkOption mkIf;
|
||||||
|
inherit (lib.types) functionTo lazyAttrsOf nullOr package uniq;
|
||||||
|
inherit (flakelight.types) optFunctionTo;
|
||||||
|
|
||||||
|
bundler = uniq (functionTo package);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
bundler = mkOption {
|
||||||
|
type = nullOr bundler;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
bundlers = mkOption {
|
||||||
|
type = nullOr (optFunctionTo (lazyAttrsOf bundler));
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkMerge [
|
||||||
|
(mkIf (config.bundler != null) {
|
||||||
|
bundlers.default = config.bundler;
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf (config.bundlers != null) {
|
||||||
|
perSystem = pkgs: {
|
||||||
|
bundlers = config.bundlers pkgs;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
@ -35,6 +35,8 @@ in
|
|||||||
template = autoImportArgs' "template";
|
template = autoImportArgs' "template";
|
||||||
templates = autoImportArgs' "templates";
|
templates = autoImportArgs' "templates";
|
||||||
formatters = autoImport' "formatters";
|
formatters = autoImport' "formatters";
|
||||||
|
bundler = autoImport' "bundler";
|
||||||
|
bundlers = autoImport' "bundlers";
|
||||||
nixosModule = autoImport' "nixosModule";
|
nixosModule = autoImport' "nixosModule";
|
||||||
nixosModules = autoImportArgs' "nixosModules";
|
nixosModules = autoImportArgs' "nixosModules";
|
||||||
nixosConfigurations = autoImportArgs' [ "nixosConfigurations" "nixos" ];
|
nixosConfigurations = autoImportArgs' [ "nixosConfigurations" "nixos" ];
|
||||||
@ -72,6 +74,8 @@ in
|
|||||||
(mkIf (template != null) { inherit template; })
|
(mkIf (template != null) { inherit template; })
|
||||||
(mkIf (templates != null) { inherit templates; })
|
(mkIf (templates != null) { inherit templates; })
|
||||||
(mkIf (formatters != null) { inherit formatters; })
|
(mkIf (formatters != null) { inherit formatters; })
|
||||||
|
(mkIf (bundler != null) { inherit bundler; })
|
||||||
|
(mkIf (bundlers != null) { inherit bundlers; })
|
||||||
(mkIf (nixosModule != null) { inherit nixosModule; })
|
(mkIf (nixosModule != null) { inherit nixosModule; })
|
||||||
(mkIf (nixosModules != null) { inherit nixosModules; })
|
(mkIf (nixosModules != null) { inherit nixosModules; })
|
||||||
(mkIf (nixosConfigurations != null) { inherit nixosConfigurations; })
|
(mkIf (nixosConfigurations != null) { inherit nixosConfigurations; })
|
||||||
|
Loading…
Reference in New Issue
Block a user