Closed ocharles closed 5 years ago
Should be pretty easy to support.
I wonder if having only expressions would be better. If you need a file you can always do an expression as "import ./file.nix". I will have a think about it.
It might be slightly trickier than I thought, nixos-rebuild doesn't seem to take expressions for config - so we could send them a patch, and maybe work around by writing a temporary file for each config expression. The main problem is the temporary files can't be in /tmp/ as they need to be in the working dir for relative paths to work properly.
Ahh, that's a good point. So maybe local_file
is the way to go...
OTOH, we could imagine
resource "nix_nixos" "foo" {
configuration = <<EOT
EOT
working_dir = "/any/path/here";
}
configuration
would then create a file in the given working_dir
for use with nixos-rebuild
.
relative to the current terraform file would be okay, not too sure how to ensure that though.
@ocharles ok, new idea... if configuration_path AND configuration are both set, it means to write the config/build expression to disk at that location, otherwise just read it. I think that resolves the problem.
I think I will prototype it tomorrow.
Ok, this is implemented, you will need to update your config to try it, but the change is quite simple.
You need to change nixos_config to nixos_config_path. Now nixos_config can be used for inline configuration, and the generated config will be written to nixos_config_path.
If you don't need inline config, you just don't specify it and the behavior is the same as before.
That sounds good to me! Thanks for your work on this, Terraform is starting to look very viable!
On Fri, 19 Apr 2019, 2:43 pm andrewchambers, notifications@github.com wrote:
Closed #10 https://github.com/andrewchambers/terraform-provider-nix/issues/10.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/andrewchambers/terraform-provider-nix/issues/10#event-2288235800, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAFDDT56HQO3KWIXAQFAALPRHEALANCNFSM4HG362QQ .
I'm currently using
local_file
, but it'd really be easier if I could just givenix_nixos
aconfiguration.nix
expression: