Skip to content

mCaptcha: Projects-old -> Projects#817

Merged
eljamm merged 15 commits into
ngi-nix:mainfrom
Axler1:mcaptcha-migration
Apr 17, 2025
Merged

mCaptcha: Projects-old -> Projects#817
eljamm merged 15 commits into
ngi-nix:mainfrom
Axler1:mcaptcha-migration

Conversation

@Axler1
Copy link
Copy Markdown
Contributor

@Axler1 Axler1 commented Apr 14, 2025

To resolve #736

@Axler1
Copy link
Copy Markdown
Contributor Author

Axler1 commented Apr 14, 2025

@eljamm , could you please review it? I am encountering some problems when running the example and the test.

For the test, I get the following error when executing this command: nix --extra-experimental-features "nix-command flakes" build .#checks.x86_64-linux.projects/mcaptcha/nixos/tests/basic

error: suspicious ownership or permission on '/nix/store/i9dmdq6rxhapj7jndvi19h60lr430qcf-boot.json.drv.chroot/root/nix/store/235hwkfrhxjgzwms9cis8h58f7ilb3qq-boot.json' for output 'out'; rejecting this build output
error: 1 dependencies of derivation '/nix/store/56gi4friqw2yp1jbv00bfkfwldwdz812-nixos-system-mcaptcha-test.drv' failed to build
error: 1 dependencies of derivation '/nix/store/l07w7albsckfnqxf7bg8aifv2x7k99yj-nixos-vm.drv' failed to build
error: 1 dependencies of derivation '/nix/store/vrhbhxni5gjdqq9b8sgbjsd6nmxdfxr0-nixos-test-driver-test-of-mcaptcha-with-database-and-other-services-running-on-a-different-node.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3svh4s6ychfxhgpzgv4nkc78a3cai8lk-vm-test-run-test-of-mcaptcha-with-database-and-other-services-running-on-a-different-node.drv' failed to build

For the example, I get the following error when executing this command: nix --extra-experimental-features "nix-command flakes" build .#checks.x86_64-linux.projects/mcaptcha/nixos/examples/basic

error:
       … while calling the 'head' builtin
         at /nix/store/dn9smqqg60pn1a3c1sk2m0m8iakm84zs-source/lib/attrsets.nix:1534:13:
         1533|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1534|             head values
             | ^ |
         1535|           else

       … while evaluating the attribute 'value'
         at /nix/store/dn9smqqg60pn1a3c1sk2m0m8iakm84zs-source/lib/modules.nix:1083:7:
         1082|     // {
         1083|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             | ^ |
         1084|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/dn9smqqg60pn1a3c1sk2m0m8iakm84zs-source/nixos/modules/system/activation/top-level.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'database' missing
       at /nix/store/k94aj0a7wig0s4s91yd8rvb9hkdv5pqq-source/projects/mcaptcha/services/mcaptcha/module.nix:155:81:
          154|         assertion = (!cfg.database.createLocally) -> (cfg.settings.database.username != null);
          155|         message = "If `${opt.database.createLocally}` is not specified, then `${opt.settings.database.username}` must be specified";
             | ^ |
          156|       }

@Axler1 Axler1 changed the title Mcaptcha migration mCaptcha: Projects-old -> Projects Apr 14, 2025
Comment thread projects/mcaptcha/default.nix Outdated
Comment thread projects/mcaptcha/default.nix Outdated
# - Set attributes to `null` to indicate that they're needed, but not available
# - Remove comments that are only relevant to the template when using it
metadata = {
summary = "mCaptcha is a backend component for a CAPTCHA system designed to provide a seamless user experience without unnecessary complexity.";
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.

Let's keep it short

Suggested change
summary = "mCaptcha is a backend component for a CAPTCHA system designed to provide a seamless user experience without unnecessary complexity.";
summary = "Privacy-friendly Proof of Work (PoW) based CAPTCHA system";

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.

Let's remove this file, since it's not testing anything

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.

Please delete the projects-old/mCaptcha directory

Comment thread projects/mcaptcha/default.nix Outdated
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.

The directory should be projects/mCaptcha, not projects/mcaptcha. Please mind the letter's case.

Comment thread projects/mcaptcha/default.nix Outdated
Comment on lines +38 to +49
# examples = {
# bringService = {
# description = "use a database and other services running on a different node";
# module = ./services/mcaptcha/examples/basic.nix;
# tests.bringService = import ./services/mcaptcha/tests/bring-your-own-services.nix args;
# };
# createLocally = {
# description = "use a database and other services running on the same node";
# module = ./services/mcaptcha/examples/basic.nix;
# tests.createLocally = import ./services/mcaptcha/tests/create-locally.nix args;
# };
# };
Copy link
Copy Markdown
Contributor

@eljamm eljamm Apr 14, 2025

Choose a reason for hiding this comment

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

Let's just make these free-standing tests (see here)

Suggested change
# examples = {
# bringService = {
# description = "use a database and other services running on a different node";
# module = ./services/mcaptcha/examples/basic.nix;
# tests.bringService = import ./services/mcaptcha/tests/bring-your-own-services.nix args;
# };
# createLocally = {
# description = "use a database and other services running on the same node";
# module = ./services/mcaptcha/examples/basic.nix;
# tests.createLocally = import ./services/mcaptcha/tests/create-locally.nix args;
# };
# };

Comment thread projects/mcaptcha/default.nix Outdated
};
};
};
};
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.

Suggested change
};
};
nixos.tests.bring-your-own-services = import ./services/mcaptcha/tests/bring-your-own-services.nix args;
nixos.tests.create-locally = import ./services/mcaptcha/tests/create-locally.nix args;
nixos.tests.basic = import ./services/mcaptcha/tests/basic.nix args;

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.

From the error you got, we know that this example is not going to be enough to set up the service. Lets just delete this file and set the example attribute to null examples.basic = null; to indicate that it's something we want, but is not available, yet.

       error: attribute 'database' missing
       at /nix/store/nmsrnrwd7yw953rsr23myp2xcjwcvixp-source/projects/mcaptcha/services/mcaptcha/module.nix:155:81:
          154|         assertion = (!cfg.database.createLocally) -> (cfg.settings.database.username != null);
          155|         message = "If `${opt.database.createLocally}` is not specified, then `${opt.settings.database.username}` must be specified";
             |                                                                                 ^
          156|       }

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.

Same comment as the service example. Let's remove this since it's not simple to set up.

@Axler1
Copy link
Copy Markdown
Contributor Author

Axler1 commented Apr 15, 2025

@eljamm I still have issues when I run the tests :(

nix --extra-experimental-features "nix-command flakes" build .#checks.x86_64-linux.projects/mCaptcha/nixos/tests/create-locally

error: suspicious ownership or permission on '/nix/store/i9dmdq6rxhapj7jndvi19h60lr430qcf-boot.json.drv.chroot/root/nix/store/235hwkfrhxjgzwms9cis8h58f7ilb3qq-boot.json' for output 'out'; rejecting this build output
error: 1 dependencies of derivation '/nix/store/iy8b5a9sl47vn9mxp45b9fag7jah8a4k-nixos-system-mcaptcha-test.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f4fwfnmdwkc9im554gmrg4qyq16gx311-nixos-vm.drv' failed to build
error: 1 dependencies of derivation '/nix/store/js0c8lf973fb1zd36dfsqv6zcskkd5c6-nixos-test-driver-test-of-mcaptcha-with-database-and-other-services-all-running-on-the-same-node.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ds2fkgn56chm300q4q89rhkc5r2ahm7s-vm-test-run-test-of-mcaptcha-with-database-and-other-services-all-running-on-the-same-node.drv' failed to build

nix --extra-experimental-features "nix-command flakes" build .#checks.x86_64-linux.projects/mCaptcha/nixos/tests/build-your-own-services

error: flake 'git+file:///workspaces/ngipkgs' does not provide attribute 'packages.x86_64-linux.checks.x86_64-linux.projects/mCaptcha/nixos/tests/build-your-own-services', 'legacyPackages.x86_64-linux.checks.x86_64-linux.projects/mCaptcha/nixos/tests/build-your-own-services' or 'checks.x86_64-linux.projects/mCaptcha/nixos/tests/build-your-own-services'

imports = [
sources.modules.ngipkgs
sources.modules.services.mcaptcha
sources.examples.mcaptcha.basic
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.

If examples.basic = null; then there is no example to import.

Suggested change
sources.examples.mcaptcha.basic

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.

I though the basic test did something, but apparently that wasn't the case. Let's just remove this file.

Comment thread projects/mCaptcha/default.nix Outdated

nixos.tests.bring-your-own-services = import ./services/mcaptcha/tests/bring-your-own-services.nix args;
nixos.tests.create-locally = import ./services/mcaptcha/tests/create-locally.nix args;
nixos.tests.basic = import ./services/mcaptcha/tests/basic.nix args;
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.

Suggested change
nixos.tests.basic = import ./services/mcaptcha/tests/basic.nix args;

@Axler1
Copy link
Copy Markdown
Contributor Author

Axler1 commented Apr 15, 2025

@eljamm I've been trying different ways but I keep getting the same error. Even disabling the sandbox, but the issue persists.

nix --extra-experimental-features "nix-command flakes" build .\#checks.x86_64-linux.projects/mCaptcha/nixos/tests/bring-your-own-services --option sandbox relaxed

error: suspicious ownership or permission on '/nix/store/i9dmdq6rxhapj7jndvi19h60lr430qcf-boot.json.drv.chroot/root/nix/store/235hwkfrhxjgzwms9cis8h58f7ilb3qq-boot.json' for output 'out'; rejecting this build output
error: 1 dependencies of derivation '/nix/store/56gi4friqw2yp1jbv00bfkfwldwdz812-nixos-system-mcaptcha-test.drv' failed to build
error: 1 dependencies of derivation '/nix/store/l07w7albsckfnqxf7bg8aifv2x7k99yj-nixos-vm.drv' failed to build
error: 1 dependencies of derivation '/nix/store/vrhbhxni5gjdqq9b8sgbjsd6nmxdfxr0-nixos-test-driver-test-of-mcaptcha-with-database-and-other-services-running-on-a-different-node.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3svh4s6ychfxhgpzgv4nkc78a3cai8lk-vm-test-run-test-of-mcaptcha-with-database-and-other-services-running-on-a-different-node.drv' failed to build

nix --extra-experimental-features "nix-command flakes" build .\#checks.x86_64-linux.projects/mCaptcha/nixos/tests/create-locally --option sandbox false

error: suspicious ownership or permission on '/nix/store/235hwkfrhxjgzwms9cis8h58f7ilb3qq-boot.json' for output 'out'; rejecting this build output
error: 1 dependencies of derivation '/nix/store/iy8b5a9sl47vn9mxp45b9fag7jah8a4k-nixos-system-mcaptcha-test.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f4fwfnmdwkc9im554gmrg4qyq16gx311-nixos-vm.drv' failed to build
error: 1 dependencies of derivation '/nix/store/js0c8lf973fb1zd36dfsqv6zcskkd5c6-nixos-test-driver-test-of-mcaptcha-with-database-and-other-services-all-running-on-the-same-node.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ds2fkgn56chm300q4q89rhkc5r2ahm7s-vm-test-run-test-of-mcaptcha-with-database-and-other-services-all-running-on-the-same-node.drv' failed to build

Could you please run the tests to see if it's my system that is causing the issues? 🙏

@eljamm
Copy link
Copy Markdown
Contributor

eljamm commented Apr 16, 2025

I think the command fails because the Nix store isn't properly supported when it's mounted on an NFS/NTFS filesystem 0 1, if that's what you're doing. The project tests themselves are fine, since they're passing in CI.

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.

We don't need projects/mCaptcha/programs since I think the mcaptcha and mcaptcha-cache artefacts only run properly in the context of the service module.

@Axler1
Copy link
Copy Markdown
Contributor Author

Axler1 commented Apr 16, 2025

I think the command fails because the Nix store isn't properly supported when it's mounted on an NFS/NTFS filesystem 0 1, if that's what you're doing. The project tests themselves are fine, since they're passing in CI.

Yeah, so that's what it was about.

@Axler1 Axler1 marked this pull request as ready for review April 16, 2025 18:16
@Axler1 Axler1 requested a review from eljamm April 16, 2025 18:19
Copy link
Copy Markdown
Contributor

@eljamm eljamm left a comment

Choose a reason for hiding this comment

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

Looks good, nice!

@eljamm eljamm merged commit fc70b9f into ngi-nix:main Apr 17, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Migrate mCaptcha from projects-old to projects

2 participants