1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00
home-manager/tests/modules/programs/sbt/repositories.nix
Philippe Laflamme 599e22b1c7
sbt: allow managing the ~/.sbt/repositories file
sbt allows overriding the default repositories to use to resolve
dependencies. This is often used with proxies and/or private
repositories to host internal packages.

This change adds a `repositories` attribute to `sbt` to allow
specifying the values that will go in `~/.sbt/repositories` file.

To support the above change we also deprecate the `baseConfigPath`
option in favour of `baseUserConfigPath` which points one level higher
by default. This allows not using relative paths to refer to the
top-level configuration directory.

Also adds tests for the new option and the deprecation of the previous
one.
2022-10-07 00:23:29 +02:00

38 lines
1.1 KiB
Nix

{ pkgs, ... }:
let
repositories = [
"local"
{ my-maven-proxy = "http://repo.mavenproxy.io/a/b/c/d"; }
"maven-local"
{
my-ivy-proxy =
"http://repo.company.com/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]";
}
"maven-central"
];
expectedRepositories = builtins.toFile "repositories" ''
[repositories]
local
my-maven-proxy: http://repo.mavenproxy.io/a/b/c/d
maven-local
my-ivy-proxy: http://repo.company.com/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
maven-central
'';
repositoriesSbtPath = ".sbt/repositories";
in {
config = {
programs.sbt = {
enable = true;
repositories = repositories;
package = pkgs.writeScriptBin "sbt" "";
};
nmt.script = ''
assertFileExists "home-files/${repositoriesSbtPath}"
assertFileContent "home-files/${repositoriesSbtPath}" "${expectedRepositories}"
'';
};
}