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.
This commit is contained in:
parent
6427ae9578
commit
599e22b1c7
5 changed files with 167 additions and 6 deletions
|
|
@ -1,4 +1,7 @@
|
|||
{
|
||||
sbt-plugins = ./plugins.nix;
|
||||
sbt-credentials = ./credentials.nix;
|
||||
sbt-deprecated-options = ./deprecated-options.nix;
|
||||
sbt-plugins = ./plugins.nix;
|
||||
sbt-repositories = ./repositories.nix;
|
||||
sbt-user-config-path = ./user-config-path.nix;
|
||||
}
|
||||
|
|
|
|||
18
tests/modules/programs/sbt/deprecated-options.nix
Normal file
18
tests/modules/programs/sbt/deprecated-options.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.sbt = {
|
||||
enable = true;
|
||||
baseConfigPath = "gone";
|
||||
};
|
||||
|
||||
test.stubs.sbt = { };
|
||||
|
||||
test.asserts.assertions.expected = [
|
||||
(let offendingFile = toString ./deprecated-options.nix;
|
||||
in ''
|
||||
The option definition `programs.sbt.baseConfigPath' in `${offendingFile}' no longer has any effect; please remove it.
|
||||
Use programs.sbt.baseUserConfigPath instead, but note that the semantics are slightly different.
|
||||
'')
|
||||
];
|
||||
}
|
||||
38
tests/modules/programs/sbt/repositories.nix
Normal file
38
tests/modules/programs/sbt/repositories.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{ 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}"
|
||||
'';
|
||||
};
|
||||
}
|
||||
39
tests/modules/programs/sbt/user-config-path.nix
Normal file
39
tests/modules/programs/sbt/user-config-path.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
plugins = [{
|
||||
org = "a";
|
||||
artifact = "b";
|
||||
version = "c";
|
||||
}];
|
||||
|
||||
credentials = [{
|
||||
realm = "a";
|
||||
host = "b";
|
||||
user = "c";
|
||||
passwordCommand = "d";
|
||||
}];
|
||||
|
||||
repositories = [ "local" ];
|
||||
|
||||
baseSbtPath = ".config/sbt";
|
||||
in {
|
||||
config = {
|
||||
programs.sbt = {
|
||||
enable = true;
|
||||
plugins = plugins;
|
||||
credentials = credentials;
|
||||
repositories = repositories;
|
||||
baseUserConfigPath = ".config/sbt";
|
||||
package = pkgs.writeScriptBin "sbt" "";
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists "home-files/${baseSbtPath}/1.0/plugins/plugins.sbt"
|
||||
assertFileExists "home-files/${baseSbtPath}/1.0/credentials.sbt"
|
||||
assertFileExists "home-files/${baseSbtPath}/repositories"
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue