I have a derivation whose output is a bunch of files. Currently, I am symlinking the derivations output to a known location, then using that location for what I actually want to do with the files. That works, but I am just wondering if there’s a way to skip this step.
Here’s what I’m currently doing (just for clarification):
{ config, pkgs, ... }:
let
config_files = pkgs.stdenv.mkDerivation {
name = "surfshark-config";
src = pkgs.fetchurl {
url = "https://my.surfshark.com/vpn/api/v1/server/configurations";
sha256 = "sha256-QY/kRqJK5yyTarcO7YhHhUm89gMSUzq7d+Uv0d1kxKM=";
};
phases = [ "installPhase" ];
buildInputs = [ pkgs.unzip pkgs.rename ];
installPhase = ''
unzip $src
find . -type f ! -name '*_udp.ovpn' -delete
find . -type f -exec sed -i "s+auth-user-pass+auth-user-pass \"${config.sops.secrets.openvpn.path}\"+" {} +
rename 's/prod.surfshark.com_udp.//' *
mkdir -p $out
mv * $out
'';
};
getConfig = filePath: {
name = "${builtins.substring 0 (builtins.stringLength filePath - 5) filePath}";
value = { config = '' config /etc/openvpn/client/configs/${filePath} ''; autoStart = false; };
};
openVPNConfigs = map getConfig (builtins.attrNames (builtins.readDir config_files));
in
{
sops.secrets.openvpn = { };
networking.networkmanager.plugins = [ pkgs.networkmanager-openvpn ];
environment.etc."openvpn/client/configs".source = config_files;
services.openvpn.servers = builtins.listToAttrs openVPNConfigs;
}
Essentially, I would love to get rid of this line:
environment.etc."openvpn/client/configs".source = config_files;