mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
sbt: cache passwordCommand
output
This will cache the output of `passwordCommand` per authentication realm. Context: the `credentials` key in `sbt` is a `TaskKey[Seq[Credentials]]`. In `sbt`, tasks are evaluated on-demand and their output is not cached. This particular key is referenced by all submodules in a project. When the command is relatively expensive (e.g.: `pass show foo`), this results in several seconds of delay when doing basic things like `compile` or `test` which makes this unusable without some kind of caching.
This commit is contained in:
parent
599e22b1c7
commit
7fee13eb4c
2 changed files with 11 additions and 6 deletions
|
@ -8,13 +8,16 @@ let
|
|||
addSbtPlugin("${plugin.org}" % "${plugin.artifact}" % "${plugin.version}")
|
||||
'';
|
||||
|
||||
renderCredential = cred: ''
|
||||
credentials += Credentials("${cred.realm}", "${cred.host}", "${cred.user}", "${cred.passwordCommand}".!!.trim)
|
||||
renderCredential = idx: cred:
|
||||
let symbol = "credential_${toString idx}";
|
||||
in ''
|
||||
lazy val ${symbol} = "${cred.passwordCommand}".!!.trim
|
||||
credentials += Credentials("${cred.realm}", "${cred.host}", "${cred.user}", ${symbol})
|
||||
'';
|
||||
|
||||
renderCredentials = creds: ''
|
||||
import scala.sys.process._
|
||||
${concatStrings (map renderCredential creds)}'';
|
||||
${concatStrings (imap0 renderCredential creds)}'';
|
||||
|
||||
renderRepository = value:
|
||||
if isString value then ''
|
||||
|
|
|
@ -19,8 +19,10 @@ let
|
|||
];
|
||||
expectedCredentialsSbt = pkgs.writeText "credentials.sbt" ''
|
||||
import scala.sys.process._
|
||||
credentials += Credentials("Sonatype Nexus Repository Manager", "example.com", "user", "echo password".!!.trim)
|
||||
credentials += Credentials("Sonatype Nexus Repository Manager X", "v2.example.com", "user1", "echo password1".!!.trim)
|
||||
lazy val credential_0 = "echo password".!!.trim
|
||||
credentials += Credentials("Sonatype Nexus Repository Manager", "example.com", "user", credential_0)
|
||||
lazy val credential_1 = "echo password1".!!.trim
|
||||
credentials += Credentials("Sonatype Nexus Repository Manager X", "v2.example.com", "user1", credential_1)
|
||||
'';
|
||||
credentialsSbtPath = ".sbt/1.0/credentials.sbt";
|
||||
in {
|
||||
|
|
Loading…
Reference in a new issue