Skip to content

Commit

Permalink
fix(flake-module): use importApply to instantiate module
Browse files Browse the repository at this point in the history
This fixes a long-running issue with the module where `inputs` would
refer to the consuming flake's inputs rather than thoenix's. By using
`importApply` to create the module, we can pass in thoenix's `lib`
output directly.

This means that consuming flakes will no longer have to have their
`thoenix` input named `thoenix` and can name it as they choose.
  • Loading branch information
justinrubek committed Apr 14, 2024
1 parent 5c37854 commit af12869
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions flake-parts/flake-module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{thoenix-lib, ...}: {
self,
lib,
flake-parts-lib,
Expand Down Expand Up @@ -61,9 +61,9 @@

# builds the terranix configuration for each terraform configuration
# and merges them into a single configuration derivation
finalConfigurations = inputs.thoenix.lib.buildTerraformConfigurations {
finalConfigurations = thoenix-lib.buildTerraformConfigurations {
configDir = terraformConfigurationDirectory;
configNames = inputs.thoenix.lib.determineSubdirNames {
configNames = thoenix-lib.determineSubdirNames {
path = terraformConfigurationDirectory;
};
terranixModules = cfg.terranixModules;
Expand Down
8 changes: 5 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
flake-parts,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
flake-parts.lib.mkFlake {inherit inputs;} ({flake-parts-lib, ...}: let
inherit (flake-parts-lib) importApply;
in {
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
imports = [
./lib.nix
Expand Down Expand Up @@ -58,8 +60,8 @@
};
};

flakeModule = ./flake-parts/flake-module.nix;
flakeModule = importApply ./flake-parts/flake-module.nix {thoenix-lib = self.lib;};
customOutputModule = ./custom-outputs.nix;
};
};
});
}

0 comments on commit af12869

Please sign in to comment.