Skip to content

Conversation

paepckehh
Copy link
Contributor

add nixos service integration for recently (22.05) added encrypted-dns-server (#398775)
(https://github.com/DNSCrypt/encrypted-dns-server) via hardened systemd profile.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (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.

Add a 👍 reaction to pull requests you find important.

@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 May 27, 2025
@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch from 5261b37 to 278d2c9 Compare May 27, 2025 20:55
@paepckehh paepckehh marked this pull request as ready for review May 27, 2025 20:56
@paepckehh paepckehh requested review from misuzu and Atemu May 27, 2025 20:56
@github-actions github-actions 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 May 27, 2025
@paepckehh paepckehh requested a review from drupol May 29, 2025 05:28
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

I added some feedback, feel free to get some inspiration from others existing services.

Also, can you please add some tests?

@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch 2 times, most recently from e1e2828 to a6b172b Compare May 29, 2025 07:26
@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch 3 times, most recently from 0c8da07 to b55d550 Compare May 29, 2025 07:47
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

Can you please add nixosTests to the encrypted-dns-server package too now?

@paepckehh
Copy link
Contributor Author

Can you please add nixosTests to the encrypted-dns-server package too now?

The package has a versionCheckHook to ensure the binary build process, the service integration does at least has port bind verification now. Can you help me out to understand your request? What is missing? A real-world end-to-end application layer/data test?

@drupol
Copy link
Contributor

drupol commented May 29, 2025

The goal is indeed to enable integration tests from the package itself.

In nixpkgs, you'll find many examples:

rg 'nixosTests' pkgs/by-name/

@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch from b55d550 to ae2a5ea Compare May 29, 2025 09:59
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

Please make the modification of the package in another commit.

@paepckehh
Copy link
Contributor Author

Please make the modification of the package in another commit.

... two commits within the same PR or a separate one?

@drupol
Copy link
Contributor

drupol commented May 29, 2025

Two commits in the same PR.

@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch from ae2a5ea to 3f3fd84 Compare May 29, 2025 10:10
@drupol
Copy link
Contributor

drupol commented May 29, 2025

As per the documentation, the commit message should be:

nixos/encrypted-dns-server: init

Same goes for the PR title.

@paepckehh paepckehh changed the title nixos/encrypted-dns-server: add nixos service integration via systemd nixos/encrypted-dns-server: init May 29, 2025
@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch from 3f3fd84 to bcc435e Compare May 29, 2025 10:46
@h7x4 h7x4 added 8.has: module (new) This PR adds a module in `nixos/` 8.has: tests This PR has tests labels Jun 1, 2025
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/2410

DynamicUser = true;
ExecStart = "${pkgs.encrypted-dns-server}/bin/encrypted-dns --config ${cfg.configFile}";
LockPersonality = true;
LogsDirectory = "encrypted-dns-server";
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it write to /var/log? If not...

Suggested change
LogsDirectory = "encrypted-dns-server";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

currently not (discussion still pending upstream), so drop it for now and re-add it later if required

wantedBy = [ "multi-user.target" ];
serviceConfig = {
AmbientCapabilities = "CAP_NET_BIND_SERVICE";
CacheDirectory = "encrypted-dns-server";
Copy link
Contributor

Choose a reason for hiding this comment

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

The same as with logs

Suggested change
CacheDirectory = "encrypted-dns-server";

services.encrypted-dns-server = {
enable = true;
settings = {
state_file = "/var/lib/encrypted-dns-server/encrypted-dns.state";
Copy link
Contributor

Choose a reason for hiding this comment

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

Should work without this option with correct WorkingDirectory

Suggested change
state_file = "/var/lib/encrypted-dns-server/encrypted-dns.state";

@misuzu misuzu added the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label Jun 2, 2025
@github-actions github-actions bot removed the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label Jun 3, 2025
@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch from b0f32c6 to 3a426da Compare June 3, 2025 09:13
@github-actions github-actions bot added 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation labels Jun 3, 2025
@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch 2 times, most recently from 868f196 to 96079fd Compare June 3, 2025 09:29
@paepckehh paepckehh requested review from misuzu and drupol June 3, 2025 09:35
@@ -424,6 +424,7 @@ in
ejabberd = runTest ./xmpp/ejabberd.nix;
elk = handleTestOn [ "x86_64-linux" ] ./elk.nix { };
emacs-daemon = runTest ./emacs-daemon.nix;
encrypted-dns-server = runTest ./encrypted-dns-server.nix;
Copy link
Contributor

Choose a reason for hiding this comment

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

The test doesn't evaluate

       error: Module `nixos/tests/encrypted-dns-server.nix' has an unsupported attribute `defaults'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: defaults driver driverInteractive drvPath enableOCR extraBaseModules extraDriverArgs extraPythonPackages globalTimeout hostPkgs includeTestScriptReferences interactive machine name node nodes nodesCompat out outPath outputName outputs passthru qemu rawTestDerivation result skipLint skipTypeCheck sshBackdoor system test testScript testScriptString type withoutTestScriptReferences) into the explicit `config' attribute.

@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch from 96079fd to 25bb69e Compare June 7, 2025 08:47
@paepckehh paepckehh force-pushed the encrypted-dns-server-service branch from 25bb69e to c5488e9 Compare June 7, 2025 08:56
@paepckehh
Copy link
Contributor Author

  • added service maintainer
  • added service tests to pkg as well
  • make configuration examples / doc consistent by using pkg version, not current master

@paepckehh paepckehh requested a review from misuzu June 7, 2025 08:59
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/2439

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/2489

Comment on lines +35 to +36
inherit (nixosTests) encrypted-dns-server;
service = nixosTests.encrypted-dns-server;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 2 lines here? The first one is enough!

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (new) This PR adds a module in `nixos/` 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: tests This PR has tests 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.

5 participants