2020-06-07 14:03:12 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2020-05-09 11:45:13 +00:00
|
|
|
{ pkgs, lib, depot, ... }:
|
|
|
|
let
|
|
|
|
secretsync = pkgs.buildGoModule rec {
|
|
|
|
pname = "secretsync";
|
|
|
|
version = "0.0.1";
|
|
|
|
|
|
|
|
src = ./.;
|
2023-12-14 11:17:47 +00:00
|
|
|
vendorHash = "sha256:0n8dvdgn6izb4qcjdcsqjzximkkpf5i2xb4ap5aa2n8c36w2dn5h";
|
2020-05-09 11:45:13 +00:00
|
|
|
|
|
|
|
subPackages = [ "." ];
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Simple package for dumping secret files from disk to GitLab variables";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in secretsync // {
|
|
|
|
configure = baseConfig:
|
|
|
|
let
|
|
|
|
config = {
|
|
|
|
name = "secretsync";
|
|
|
|
pkg = secretsync;
|
|
|
|
gitlabAccessToken = "";
|
|
|
|
gitlabEndpoint = "https://hg.lukegb.com";
|
|
|
|
gitlabProject = "lukegb/depot";
|
|
|
|
variablesToFile = {};
|
2020-05-09 13:26:54 +00:00
|
|
|
manifestVariable = "";
|
|
|
|
workingDir = "";
|
2020-05-09 11:45:13 +00:00
|
|
|
logToStderr = true;
|
|
|
|
} // baseConfig;
|
|
|
|
args = {
|
|
|
|
gitlab_access_token = config.gitlabAccessToken;
|
|
|
|
gitlab_endpoint = config.gitlabEndpoint;
|
|
|
|
gitlab_project = config.gitlabProject;
|
|
|
|
variable_to_file = lib.mapAttrsToList (name: value: "${name}=${value}") config.variablesToFile;
|
|
|
|
logtostderr = config.logToStderr;
|
2020-05-09 13:26:54 +00:00
|
|
|
} // (if config.manifestVariable == "" then {} else { manifest_variable = config.manifestVariable; });
|
2020-05-09 11:45:13 +00:00
|
|
|
in
|
|
|
|
pkgs.writeShellScriptBin config.name ''
|
2020-05-09 13:26:54 +00:00
|
|
|
cd "${config.workingDir}"
|
2020-05-09 11:45:13 +00:00
|
|
|
exec "${config.pkg}/bin/secretsync" ${lib.cli.toGNUCommandLineShell {} args}
|
|
|
|
'';
|
|
|
|
}
|