Skip to content

nixos/nextcloud: use LoadCredential to read secrets - #152141

Closed
lassulus wants to merge 1 commit into
NixOS:masterfrom
lassulus:nextcloud_credentials
Closed

lassulus wants to merge 1 commit into
NixOS:masterfrom
lassulus:nextcloud_credentials

Conversation

@lassulus

Copy link
Copy Markdown
Member
Motivation for this change

It's tedious to setup something to chown the secrets to the nextcloud user. also I think we should use more LoadCredential everywhere since it seems like the better way to handle credentials.

Haven't tested this yet, so it will stay a draft for now

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/)
  • 22.05 Release Notes (or backporting 21.11 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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions Bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 25, 2021
@ofborg ofborg Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Dec 25, 2021
@lassulus
lassulus force-pushed the nextcloud_credentials branch 2 times, most recently from 5b6d613 to 60a96a7 Compare December 25, 2021 22:57
@lassulus

Copy link
Copy Markdown
Member Author

so the nixos tests are happy now. still haven't tested it manually though

@lassulus
lassulus force-pushed the nextcloud_credentials branch from 60a96a7 to 0caa7e3 Compare February 15, 2022 14:28
@lassulus
lassulus marked this pull request as ready for review February 15, 2022 14:39

@Ma27 Ma27 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The MySQL test seems to be having some issues - even though it succeeds:

nextcloud: must succeed: curl -sSf http://nextcloud/login
nextcloud # [   17.332546] nginx[866]: 2022/02/20 16:23:45 [error] 866#866: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "CREDENTIALS_DIRECTORY" in /nix/store/yzhadqgd4qhvxxkqw6sqy2pfmfc1l10y-nextcloud-config.php on line 3" while reading response header from upstream, client: ::1, server: nextcloud, request: "GET /login HTTP/1.1", upstream: "fastcgi://unix:/run/phpfpm/nextcloud.sock:", host: "nextcloud"

Also, nextcloud-occ doesn't seem to know about CREDENTIALS_DIRECTORY as well, correct?

"adminpass:${cfg.config.adminpassFile}"
(lib.optional (cfg.config.dbpassFile != null) "dbpass:${cfg.config.dbpassFile}")
(lib.optional (cfg.config.objectstore.s3.enable) "s3:${cfg.config.objectstore.s3.secretFile}")
];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rather than duplicating the value of LoadCredential for several services, how about declaring it once at the top?

Also, how about

[ "adminpass:${cfg.config.adminpassFile}" ]
++ lib.optional (cfg.config.dbpassFile != null) "dbpass:${cfg.config.dbpassFile}"

@Ma27
Ma27 marked this pull request as draft June 16, 2022 23:20
# "The files of the app [all apps in /var/lib/nextcloud/apps] were not replaced correctly"
# Restarting phpfpm on Nextcloud package update fixes these issues (but this is a workaround).
phpfpm-nextcloud.restartTriggers = [ cfg.package ];
phpfpm-nextcloud.serviceConfig.LoadCredential = lib.flatten [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This lib.flatten is unneeded, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

afair lib.optinonal false ... returns [] which are filtered out by flatten

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, right.

I guess to avoid lib.flatten you'd have to use this style: [ elem1 ] ++ lib.optional cond elem2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah but that looked worse IMHO :)

@stale stale Bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 18, 2023
@lassulus

Copy link
Copy Markdown
Member Author

probably won't have time to ever finish this

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

Labels

2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants