-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
amazon-cloudwatch-agent: let users specify configuration file paths #358559
amazon-cloudwatch-agent: let users specify configuration file paths #358559
Conversation
694515b
to
648cfce
Compare
648cfce
to
f89ae4a
Compare
f89ae4a
to
612721a
Compare
612721a
to
d01112c
Compare
d01112c
to
68a28f5
Compare
This makes sense to me, but I am concerned about someone specifying both a file and an inline config and having the inline config silently ignored. (I do see you document that the file takes precedence.) Do you think we should error out if both are specified? |
I was imagining someone might define It looks like several other modules which offer both attribute set and path options for configurations (e.g. |
68a28f5
to
d14a440
Compare
I guess the other option is to do: {
lib,
pkgs,
config,
...
}:
let
cfg = config.services.amazon-cloudwatch-agent;
jsonFormat = pkgs.formats.json { };
configurationFile =
if (builtins.typeOf configuration == "path") then
cfg.configuration
else
(jsonFormat.generate "amazon-cloudwatch-agent.json" cfg.configuration);
# ...
in
{
options.services.amazon-cloudwatch-agent = {
configuration = lib.mkOption {
type = lib.types.oneOf [
lib.types.path
jsonFormat.type
];
default = { };
};
};
} Not actually sure if there's another module that does this. Didn't see one from a cursory search. This isn't as nice IMO because the It also gets messy in the future if the configuration format is in some transitional period. Fluent Bit has this problem since they have a legacy classic Separating out each type a configuration might be (path, JSON, YAML, TOML) is probably going to be better on a documentation and dispatch level. The most spartan approach would be to just drop any quality of life module options that serialize attribute sets and only support paths. That way, people need to supply their own derivations that produce a configuration file. This feels a bit heavy handed though and isn't the way most modules are designed. |
Sounds good to me; thanks for the thoughtful reply. I approve, though (for some reason) my approval isn't requested. |
Not sure if OfBorg waits until all checks pass before it requests maintainers for review (RIP aarch64-darwin) or some part of the maintainer metadata isn't quite right. |
Hmm since all checks passed and it still didn't request a review, might be because the input derivation for the package didn't change and NixOS modules don't actually care about the |
you can use codeowners instead for modules. it's indeed not supported |
d14a440
to
4d688ad
Compare
9cb1a7e
to
72a7ea6
Compare
046b30a
to
36278a3
Compare
36278a3
to
6c17dd3
Compare
6c17dd3
to
1a38fd2
Compare
Apparently |
1a38fd2
to
fa1ed8e
Compare
fa1ed8e
to
149dc03
Compare
149dc03
to
43caf2e
Compare
Let users specify configuration file paths.
This is to allow dynamic configuration at runtime (mostly during boot since the systemd unit won't restart unless something runs
nixos-rebuild switch
/test
).Without this feature, users creating NixOS VM images need to create 1 image per agent configuration permutation if they want immutable images (i.e. don't run
nixos-rebuild switch
on boot).This can result in a lot of near-identical images whose only difference is a few options in their CloudWatch Agent configuration (e.g. region option for multi-region AWS deployments). Since VM images are usually on the order of GBs, we end up with a lot of wasted space in Nix stores.
With this feature, users can write their own systemd units that dynamically create configurations (e.g. using information from IMDS, AWS SSM Parameter Store, or AWS Secrets Manager) and write them to a static path.
The tradeoff, however, is that mutable configuration files can cause drift if a change isn't followed by a
systemctl restart amazon-cloudwatch-agent.service
.nixos-rebuild
won't work because we can't access files outside the Nix store in restricted evaluation mode (e.g. can't hash the file and feed it intorestartTriggers
).Also doing some small cleanup.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.
Maintainer Pings
@philipmw