mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-22 10:19:39 +01:00
In Sbt (prior to 2.0) a sbt key not scoped to `ThisBuild` will always be at the project level, rather than at the build level. In order to do some things, like use a private repository configured by sbt with sbt-scalafix, we need the credentials scope to the build, otherwise the credentials show as non-existent.
40 lines
1.2 KiB
Nix
40 lines
1.2 KiB
Nix
{ pkgs, ... }:
|
|
|
|
let
|
|
credentials = [
|
|
{
|
|
realm = "Sonatype Nexus Repository Manager";
|
|
host = "example.com";
|
|
user = "user";
|
|
passwordCommand = "echo password";
|
|
}
|
|
{
|
|
realm = "Sonatype Nexus Repository Manager X";
|
|
host = "v2.example.com";
|
|
user = "user1";
|
|
passwordCommand = "echo password1";
|
|
}
|
|
];
|
|
expectedCredentialsSbt = pkgs.writeText "credentials.sbt" ''
|
|
import scala.sys.process._
|
|
lazy val credential_0 = "echo password".!!.trim
|
|
ThisBuild / credentials += Credentials("Sonatype Nexus Repository Manager", "example.com", "user", credential_0)
|
|
lazy val credential_1 = "echo password1".!!.trim
|
|
ThisBuild / credentials += Credentials("Sonatype Nexus Repository Manager X", "v2.example.com", "user1", credential_1)
|
|
'';
|
|
credentialsSbtPath = ".sbt/1.0/credentials.sbt";
|
|
in
|
|
{
|
|
config = {
|
|
programs.sbt = {
|
|
enable = true;
|
|
credentials = credentials;
|
|
package = pkgs.writeScriptBin "sbt" "";
|
|
};
|
|
|
|
nmt.script = ''
|
|
assertFileExists "home-files/${credentialsSbtPath}"
|
|
assertFileContent "home-files/${credentialsSbtPath}" "${expectedCredentialsSbt}"
|
|
'';
|
|
};
|
|
}
|