Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/openvpn: path now requires conversion to a string #97438

Merged
merged 1 commit into from Sep 9, 2020

Conversation

pbogdan
Copy link
Member

@pbogdan pbogdan commented Sep 8, 2020

Following changes in #91092 the path attribute is now a list
instead of being a string. This resulted resulted in the following evaluation error:

"cannot coerce a list to a string, at [...]/nixos/modules/services/networking/openvpn.nix:16:18"

so we now need to convert it to the right type ourselves.

Closes #97360.

NOTE: I only verified that this fixes the evaluation and that the resulting path looks OK in nix repl.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Following changes in NixOS#91092 the `path` attribute is now a list
instead of being a string. This resulted resulted in the following evaluation error:

"cannot coerce a list to a string, at [...]/nixos/modules/services/networking/openvpn.nix:16:18"

so we now need to convert it to the right type ourselves.

Closes NixOS#97360.
Copy link
Contributor

@megheaiulian megheaiulian left a comment

Choose a reason for hiding this comment

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

I've tested this change with a existing openvpn config and everything seems to be working again ...

@nathandao
Copy link

nathandao commented Sep 9, 2020

Would a kind soul give me instruction on how to apply this patch and test it locally too? - I'm still very new to nixos :D

@pbogdan
Copy link
Member Author

pbogdan commented Sep 9, 2020

@nathandao The simplest way would be to rebuild your system directly from this branch (which is based on nixos-unstable with my commit added on top). You can do that with:

$ sudo nixos-rebuild (boot|switch) -I nixpkgs=https://api.github.com/repos/NixOS/nixpkgs/tarball/pull/97438/head

Slightly more involved would require that you have a local nixpkgs checkout on your machine. You could then create a new branch that uses the exact nixpkgs revision you want to use, checkout this PR locally, cherry-pick the change to your branch and rebuild with:

$ sudo nixos-rebuild (boot|switch) -I nixpkgs=/path/to/your/checkout

@nathandao
Copy link

Thanks @pbogdan! Rebuilt my system based on the branch and it works! : )

@ajs124 ajs124 merged commit c97fcc3 into NixOS:master Sep 9, 2020
@dasJ
Copy link
Member

dasJ commented Sep 9, 2020

Needs backport to 20.09

@infinisil
Copy link
Member

Backported in 159760a

@Galagora
Copy link
Contributor

sbin should also be part of the search path too:

@@ -11,7 +11,8 @@
   makeOpenVPNJob = cfg: name:
     let

-      path = makeBinPath (getAttr "openvpn-${name}" config.systemd.services).path;
+      packages = (getAttr "openvpn-${name}" config.systemd.services).path;
+      path = "${makeBinPath packages}:${makeSearchPathOutput "bin" "sbin" packages}";

       upScript = ''
         #! /bin/sh

@pbogdan
Copy link
Member Author

pbogdan commented Sep 11, 2020

It's a nixpkgs convention, enforced by the standard fixupPhase, to move binaries from /sbin to /bin and I can't see a single usage of dontMoveSbin in nixpkgs tree. Do you have an example when your patch would be necessary (not that adding /sbin would hurt AFAICT)?

@Galagora
Copy link
Contributor

I copied that snippet from the systemd module, so I assumed that /sbin was included for a reason, but if the binaries are always copied over then it shouldn't matter anyways.

@pbogdan pbogdan deleted the openvpn-path branch October 10, 2020 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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