Skip to content

Commit

Permalink
feat: add flakeModules.bomper output
Browse files Browse the repository at this point in the history
This flake-parts module can be used to create a wrapped version of
bomper with configuration pre-specified. This allows for usage of bomper
without commiting a configuration file into the repository. Simply
specify the configuration as a string and the module will created a
wrapped version of bomper that passes the configuration to it as its
first argument and passes the rest through.

This has removed the need for the flake to depend on itself by
dogfooding the module. See `flake-parts/bomper.nix` for an example of
how to use this.
  • Loading branch information
justinrubek committed May 4, 2024
1 parent e9e8289 commit 1376355
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 692 deletions.
3 changes: 0 additions & 3 deletions bomp.ron

This file was deleted.

12 changes: 12 additions & 0 deletions flake-parts/bomper.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
_: {
perSystem = {...}: {
bomper = {
enable = true;
configuration = ''
(
cargo: Some(Autodetect),
)
'';
};
};
}
2 changes: 1 addition & 1 deletion flake-parts/cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
pkgs.bacon
# version control
pkgs.cocogitto
inputs'.bomper.packages.cli
config.bomper.wrappedBomper
# formatting
self'.packages.treefmt
# misc
Expand Down
55 changes: 55 additions & 0 deletions flake-parts/flake-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
localFlake: {
self,
lib,
flake-parts-lib,
inputs,
...
}: {
options = {
perSystem = flake-parts-lib.mkPerSystemOption ({
config,
inputs',
pkgs,
system,
...
}: let
cfg = config.bomper;
in {
options = {
bomper = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable generation bomper.
'';
};

configuration = lib.mkOption {
type = lib.types.lines;
description = ''
The contents of the configuration file to pass to bomper.
'';
};

wrappedBomper = lib.mkOption {
type = lib.types.package;
readOnly = true;
description = "A wrapped version of bomper with configuration already specified.";
};
};
};

config = let
configFile = pkgs.writeText "bomper-config" cfg.configuration;
in
lib.mkIf cfg.enable {
bomper.wrappedBomper = localFlake.withSystem system ({config, ...}: (pkgs.writeShellApplication {
name = "bomper";
runtimeInputs = [config.packages.cli];
text = ''exec bomper --config-file ${configFile} "$@"'';
}));
};
});
};
}
Loading

0 comments on commit 1376355

Please sign in to comment.