Nixpkgs: Cannot coerce a list to a string when setting services.openvpn.servers.<name>.updateResolvConf = true;

Created on 7 Sep 2020  路  3Comments  路  Source: NixOS/nixpkgs

Describe the bug

I have been getting this error cannot coerce a list to a string, at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/networking/openvpn.nix:16:18 when setting either updateResolvConf to true, or define a custom up command in the openvpn server config, and then run nixos-rebuild boot. I'm currently using the unstable channel.

To Reproduce
Steps to reproduce the behavior:

  1. Set either updateReslvConf or up for your openvpn server
  services.openvpn.servers = {
    myVpn = {
      config = ''
        config /path/to/config/file.ovpn
      '';
      autoStart = false;
      updateResolvConf = true;
      authUserPass.username = "username";
      authUserPass.password = "password";
    };
  };
  1. Run sudo nixos-rebuild boot or switch

Expected behavior

nixos-rebuild should succeed

Screenshots

Here is the output of sudo nixos-rebuild boot --show-trace

building Nix...
building the system configuration...
error: while evaluating the attribute 'config.system.build.toplevel' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:293:5:
while evaluating 'foldr' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:52:20, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:128:12:
while evaluating 'fold'' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:55:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:59:8:
while evaluating 'showWarnings' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:302:28, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/top-level.nix:125:10:
while evaluating 'foldr' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:52:20, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:302:33:
while evaluating 'fold'' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:55:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:59:8:
while evaluating the attribute 'warnings' at undefined position:
while evaluating 'g' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:276:19, called from undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:98:72, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:279:20:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:461:9:
while evaluating the option `warnings':
while evaluating the attribute 'mergedValue' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:493:5:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:487:9:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:586:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:473:28, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:473:17:
while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/systemd.nix':
while evaluating 'dischargeProperties' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:545:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:474:137:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:338:44:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:234:10, called from undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/systemd.nix:887:51, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:234:16:
while evaluating 'optional' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/lists.nix:254:20, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/systemd.nix:891:10:
while evaluating the attribute 'serviceConfig.Type' at undefined position:
while evaluating 'g' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:276:19, called from undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:98:72, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:279:20:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:461:9:
while evaluating the option `systemd.services.openvpn-futuHelsinki.serviceConfig':
while evaluating the attribute 'mergedValue' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:493:5:
while evaluating 'merge' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:292:20, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:495:59:
while evaluating 'filterAttrs' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:124:23, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:293:35:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:125:29, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:125:18:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:293:51, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:125:62:
while evaluating the attribute 'ExecStart' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:344:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:293:86, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:344:15:
while evaluating the attribute 'optionalValue' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:505:5:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:487:9:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:586:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:473:28, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:473:17:
while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/networking/openvpn.nix':
while evaluating 'dischargeProperties' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:545:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:474:137:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:297:60:
while evaluating the attribute 'text' of the derivation 'openvpn-config-futuHelsinki' at /nix/store/bxrxyc98c81d0w9xqw4mvza04yvx7rby-nixos-20.09pre242481.0ecc8b9a56a/nixos/pkgs/build-support/trivial-builders.nix:7:7:
while evaluating 'optionalString' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/strings.nix:180:5, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/networking/openvpn.nix:49:13:
while evaluating the attribute 'text' of the derivation 'openvpn-futuHelsinki-up' at /nix/store/bxrxyc98c81d0w9xqw4mvza04yvx7rby-nixos-20.09pre242481.0ecc8b9a56a/nixos/pkgs/build-support/trivial-builders.nix:7:7:
cannot coerce a list to a string, at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/networking/openvpn.nix:16:18

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

  • system: "x86_64-linux"
  • host os: Linux 5.8.6, NixOS, 20.09pre242481.0ecc8b9a56a (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.7
  • channels(root): "nixos-20.09pre242481.0ecc8b9a56a, nixpkgs, stable-20.03.2910.42674051d12"
  • channels(ndao): "home-manager, nixos-20.09pre240426.f9567594d5a"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixos modules affected by the problem
module: openvpn
bug nixos

All 3 comments

I'm seeing the same on my system and it looks to be related to #91092. The following diff fixes the evaluation for me:

diff --git a/nixos/modules/services/networking/openvpn.nix b/nixos/modules/services/networking/openvpn.nix
index dcd7e9e5fa4..650f9c84ac7 100644
--- a/nixos/modules/services/networking/openvpn.nix
+++ b/nixos/modules/services/networking/openvpn.nix
@@ -11,7 +11,7 @@ let
   makeOpenVPNJob = cfg: name:
     let

-      path = (getAttr "openvpn-${name}" config.systemd.services).path;
+      path = makeBinPath (getAttr "openvpn-${name}" config.systemd.services).path;

       upScript = ''
         #! /bin/sh

/cc @dasJ

Yes, that looks like a legit fix. Can you open a PR?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaibhavsagar picture vaibhavsagar  路  3Comments

tomberek picture tomberek  路  3Comments

ob7 picture ob7  路  3Comments

lverns picture lverns  路  3Comments

copumpkin picture copumpkin  路  3Comments