Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 451b23beb2db
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c79e0b2ba032
Choose a head ref
  • 12 commits
  • 4 files changed
  • 3 contributors

Commits on Jun 27, 2017

  1. Vault: 0.6.5 -> 0.7.2 with services

    Katyucha authored and Volth committed Jun 27, 2017
    Copy the full SHA
    442f76d View commit details
  2. delete lines

    Katyucha authored and Volth committed Jun 27, 2017

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    mweinelt Martin Weinelt
    Copy the full SHA
    cad450e View commit details
  3. vault: run as an unpivileged user

    Volth committed Jun 27, 2017
    Copy the full SHA
    4c428b4 View commit details
  4. create directory only for "file" storage

    Volth committed Jun 27, 2017
    Copy the full SHA
    d016ef1 View commit details

Commits on Jun 28, 2017

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    marsam Mario Rodas
    Copy the full SHA
    7330e80 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    519f170 View commit details
  3. removed generation of self-signed certificate

    Volth committed Jun 28, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2056c7e View commit details

Commits on Jun 29, 2017

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ca16df1 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    68bf28a View commit details

Commits on Jul 2, 2017

  1. vault: remove-references-to go compiler

    Volth committed Jul 2, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c3996de View commit details

Commits on Jul 3, 2017

  1. Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    334e85e View commit details

Commits on Jul 11, 2017

  1. Merge pull request #26907 from volth/vault

    vault: 0.6.5 -> 0.7.3 with service
    cstrahan authored Jul 11, 2017
    Copy the full SHA
    c79e0b2 View commit details
Showing with 166 additions and 12 deletions.
  1. +2 −0 nixos/modules/misc/ids.nix
  2. +1 −0 nixos/modules/module-list.nix
  3. +143 −0 nixos/modules/services/security/vault.nix
  4. +20 −12 pkgs/tools/security/vault/default.nix
2 changes: 2 additions & 0 deletions nixos/modules/misc/ids.nix
Original file line number Diff line number Diff line change
@@ -139,6 +139,7 @@
btsync = 113;
minecraft = 114;
#monetdb = 115; # unused (not packaged), removed 2016-09-19
vault = 115;
rippled = 116;
murmur = 117;
foundationdb = 118;
@@ -415,6 +416,7 @@
btsync = 113;
#minecraft = 114; # unused
#monetdb = 115; # unused (not packaged), removed 2016-09-19
vault = 115;
#ripped = 116; # unused
#murmur = 117; # unused
foundationdb = 118;
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
@@ -558,6 +558,7 @@
./services/security/tor.nix
./services/security/torify.nix
./services/security/torsocks.nix
./services/security/vault.nix
./services/system/cgmanager.nix
./services/system/cloud-init.nix
./services/system/dbus.nix
143 changes: 143 additions & 0 deletions nixos/modules/services/security/vault.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{ config, lib, pkgs, ... }:

with lib;
let
cfg = config.services.vault;

configFile = pkgs.writeText "vault.hcl" ''
listener "tcp" {
address = "${cfg.address}"
${if (cfg.tlsCertFile == null || cfg.tlsKeyFile == null) then ''
tls_disable = "true"
'' else ''
tls_cert_file = "${cfg.tlsCertFile}"
tls_key_file = "${cfg.tlsKeyFile}"
''}
${cfg.listenerExtraConfig}
}
storage "${cfg.storageBackend}" {
${optionalString (cfg.storagePath != null) ''path = "${cfg.storagePath}"''}
${optionalString (cfg.storageConfig != null) cfg.storageConfig}
}
${optionalString (cfg.telemetryConfig != "") ''
telemetry {
${cfg.telemetryConfig}
}
''}
'';
in
{
options = {

services.vault = {

enable = mkEnableOption "Vault daemon";

address = mkOption {
type = types.str;
default = "127.0.0.1:8200";
description = "The name of the ip interface to listen to";
};

tlsCertFile = mkOption {
type = types.nullOr types.str;
default = null;
example = "/path/to/your/cert.pem";
description = "TLS certificate file. TLS will be disabled unless this option is set";
};

tlsKeyFile = mkOption {
type = types.nullOr types.str;
default = null;
example = "/path/to/your/key.pem";
description = "TLS private key file. TLS will be disabled unless this option is set";
};

listenerExtraConfig = mkOption {
type = types.lines;
default = ''
tls_min_version = "tls12"
'';
description = "extra configuration";
};

storageBackend = mkOption {
type = types.enum [ "inmem" "file" "consul" "zookeeper" "s3" "azure" "dynamodb" "etcd" "mssql" "mysql" "postgresql" "swift" "gcs" ];
default = "inmem";
description = "The name of the type of storage backend";
};

storagePath = mkOption {
type = types.nullOr types.path;
default = if cfg.storageBackend == "file" then "/var/lib/vault" else null;
description = "Data directory for file backend";
};

storageConfig = mkOption {
type = types.nullOr types.lines;
default = null;
description = "Storage configuration";
};

telemetryConfig = mkOption {
type = types.lines;
default = "";
description = "Telemetry configuration";
};
};
};

config = mkIf cfg.enable {
assertions = [
{ assertion = cfg.storageBackend == "inmem" -> (cfg.storagePath == null && cfg.storageConfig == null);
message = ''The "inmem" storage expects no services.vault.storagePath nor services.vault.storageConfig'';
}
{ assertion = (cfg.storageBackend == "file" -> (cfg.storagePath != null && cfg.storageConfig == null)) && (cfg.storagePath != null -> cfg.storageBackend == "file");
message = ''You must set services.vault.storagePath only when using the "file" backend'';
}
];

users.extraUsers.vault = {
name = "vault";
group = "vault";
uid = config.ids.uids.vault;
description = "Vault daemon user";
};
users.extraGroups.vault.gid = config.ids.gids.vault;

systemd.services.vault = {
description = "Vault server daemon";

wantedBy = ["multi-user.target"];
after = [ "network.target" ]
++ optional (config.services.consul.enable && cfg.storageBackend == "consul") "consul.service";

restartIfChanged = false; # do not restart on "nixos-rebuild switch". It would seal the storage and disrupt the clients.

preStart = optionalString (cfg.storagePath != null) ''
install -d -m0700 -o vault -g vault "${cfg.storagePath}"
'';

serviceConfig = {
User = "vault";
Group = "vault";
PermissionsStartOnly = true;
ExecStart = "${pkgs.vault}/bin/vault server -config ${configFile}";
PrivateDevices = true;
PrivateTmp = true;
ProtectSystem = "full";
ProtectHome = "read-only";
AmbientCapabilities = "cap_ipc_lock";
NoNewPrivileges = true;
KillSignal = "SIGINT";
TimeoutStopSec = "30s";
Restart = "on-failure";
StartLimitInterval = "60s";
StartLimitBurst = 3;
};

unitConfig.RequiresMountsFor = optional (cfg.storagePath != null) cfg.storagePath;
};
};

}
32 changes: 20 additions & 12 deletions pkgs/tools/security/vault/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
{ stdenv, fetchFromGitHub, go, gox, removeReferencesTo }:

let
vaultBashCompletions = fetchFromGitHub {
@@ -7,27 +7,35 @@ let
rev = "e2f59b64be1fa5430fa05c91b6274284de4ea77c";
sha256 = "10m75rp3hy71wlmnd88grmpjhqy0pwb9m8wm19l0f463xla54frd";
};
in buildGoPackage rec {
in stdenv.mkDerivation rec {
name = "vault-${version}";
version = "0.6.5";

goPackagePath = "github.com/hashicorp/vault";
version = "0.7.3";

src = fetchFromGitHub {
owner = "hashicorp";
repo = "vault";
rev = "v${version}";
sha256 = "0ci46zn9d9h26flgjf4inmvk4mb1hlixvx5g7vg02raw0cqvknnb";
sha256 = "15wj1pfgzwzjfrqy7b5bx4y9f0hbpqlfif58l5xamwm88229qk4m";
};

buildFlagsArray = ''
-ldflags=
-X github.com/hashicorp/vault/version.GitCommit=${version}
nativeBuildInputs = [ go gox removeReferencesTo ];

buildPhase = ''
substituteInPlace scripts/build.sh --replace 'git rev-parse HEAD' 'echo ${src.rev}'
mkdir -p src/github.com/hashicorp
ln -s $(pwd) src/github.com/hashicorp/vault
GOPATH=$(pwd) make
'';

postInstall = ''
mkdir -p $bin/share/bash-completion/completions/
cp ${vaultBashCompletions}/vault-bash-completion.sh $bin/share/bash-completion/completions/vault
installPhase = ''
mkdir -p $out/bin $out/share/bash-completion/completions
cp pkg/*/* $out/bin/
find $out/bin -type f -exec remove-references-to -t ${go} '{}' +
cp ${vaultBashCompletions}/vault-bash-completion.sh $out/share/bash-completion/completions/vault
'';

meta = with stdenv.lib; {