Skip to content
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

nixos/cfdyndns: add option to use CF token #253728

Merged
merged 1 commit into from
Sep 9, 2023

Conversation

nrdxp
Copy link
Contributor

@nrdxp nrdxp commented Sep 6, 2023

Description of changes

Adds an option to set a file path containing a cloudflare API token, instead of using an api key/email combo

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

CLOUDFLARE_RECORDS="${concatStringsSep "," cfg.records}";
};
script = ''
${optionalString (cfg.apikeyFile != null) ''
export CLOUDFLARE_APIKEY="$(cat ${escapeShellArg cfg.apikeyFile})"
export CLOUDFLARE_EMAIL="${cfg.email}"
''}
${optionalString (cfg.apiTokenFile != null) ''
Copy link
Contributor

@jian-lin jian-lin Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will be used if both apikeyFile and apiTokenFile are set? Should we add an assertion to make sure only one of them is set to reduce confusing?

Copy link
Contributor Author

@nrdxp nrdxp Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it depends on the implementation. In the current package in nixpkgs, the Rust binary prefers the api key, email combo, and will use it if both are present. In my recent refactor, the opposite is true and the token is prefered.

Either way, it won't hurt anything and nothing will break, but perhaps an assert would be a nicety; by no means essential though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah did you change that recently or am I just going senile 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am jetlagged, and I don't want to call you senile... but... according to the blame, it was at least 2 years ago 😄 https://github.com/colemickens/cfdyndns/blame/31d576a3700989fe7533081b238154289eab84e2/src/main.rs#L42-L55

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my question is, why did I implement it in cfdyndns and then never make it usable in the module here? Who knows....

@colemickens
Copy link
Member

LGTM, I'll merge soon unless someone else protests and thinks the assert is necessary.

@happysalada happysalada merged commit 69bfaaf into NixOS:master Sep 9, 2023
21 checks passed
@happysalada
Copy link
Contributor

hey, it looked like that PR was ready to merge, so I went ahead, I hope it's fine by everyone.

@happysalada
Copy link
Contributor

also small thing I just noticed looking at this module. Perhaps we should run it as a DynamicUser ?
(I didn't see the explicit need to define a user and a group, maybe I missed something. Unless someone is against it, I'll make a PR at some point).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants