NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18k stars 14.02k forks source link

nixos/bookstack: conflicting types for appKeyFile #305566

Closed erooke closed 6 months ago

erooke commented 6 months ago

Describe the bug

While trying to use the bookstack module I encountered this error:

error:
       … while calling the 'head' builtin

         at /nix/store/3kwj19dbdfxnjbcns4hw307ylhz3wgrm-source/lib/attrsets.nix:1541:11:

         1540|         || pred here (elemAt values 1) (head values) then
         1541|           head values
             |           ^
         1542|         else

       … while evaluating the attribute 'value'

         at /nix/store/3kwj19dbdfxnjbcns4hw307ylhz3wgrm-source/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

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

       error: A definition for option `services.bookstack.config.APP_KEY._secret' is not of type `null or string'. Definition values:
       - In `/nix/store/3kwj19dbdfxnjbcns4hw307ylhz3wgrm-source/nixos/modules/services/web-apps/bookstack.nix': /run/keys/bookstack-appkey
error: Recipe `rebuild` failed on line 17 with exit code 1

Despite having not set services.bookstack.config.APP_KEY._secret. It looks like the module is setting services.bookstack.config.APP_KEY._secret to be services.bookstack.appKeyFile despite them having disparate types.

Steps To Reproduce

The following configuration triggers the issue.

services.bookstack = {
  enable = true;
  appKeyFile = /run/keys/bookstack-appkey;
};

Expected behavior

The config does not type error on variables I have not manipulated.

Additional context

Nixpkgs revision

5c24cf2f0a12ad855f444c30b2421d044120c66f

Workaround

I was able to work around this problem with the following config:

services.bookstack = {
  enable = true;
  appKeyFile = /run/keys/bookstack-appkey;
  config.APP_KEY._secret = lib.mkForce (toString config.services.bookstack.appKeyFile);
};

Notify maintainers

@ymarkus

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.26, NixOS, 24.05 (Uakari), 24.05.20240419.5c24cf2`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - nixpkgs: `/etc/nix/path/nixpkgs`

Add a :+1: reaction to issues you find important.

eclairevoyant commented 6 months ago

you shouldn't be using a path here, use a string instead

erooke commented 6 months ago

You can't use a string, it complains that it has to be a path.

Apr 20, 2024 6:47:44 PM éclairevoyant @.***>:

you shouldn't be using a path here, use a string instead

— Reply to this email directly, view it on GitHub[https://github.com/NixOS/nixpkgs/issues/305566#issuecomment-2067816137], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ALEG4APREVH2X2RGEVYZG4TY6L5BNAVCNFSM6AAAAABGQRWXVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRXHAYTMMJTG4]. You are receiving this because you authored the thread. [Tracking image][https://github.com/notifications/beacon/ALEG4AI7LLC7ZW4JSL7WHO3Y6L5BNA5CNFSM6AAAAABGQRWXVWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTT3IBPMS.gif]

erooke commented 6 months ago

https://github.com/NixOS/nixpkgs/blob/754a00b38a44e774dba3518ced7efbf51a8970ba/nixos/modules/services/web-apps/bookstack.nix#L51 in particular here is it where it forces that's a path

eclairevoyant commented 6 months ago

lib.types.path includes any string that starts with /

erooke commented 6 months ago

I could have sworn I had tried that :sweat_smile:. Thanks.