Add secrets support to dev VMs
This commit is contained in:
parent
8c61cea30d
commit
fcad909111
@ -1,6 +1,7 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
let
|
let
|
||||||
homeFlake = "$HOME/.config/nixpkgs/flake.nix";
|
homeFlake = "$HOME/.config/nixpkgs/flake.nix";
|
||||||
|
devKey = ".keys/dev.key";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
commands = [
|
commands = [
|
||||||
@ -67,7 +68,9 @@ in
|
|||||||
command =
|
command =
|
||||||
''
|
''
|
||||||
cd "$PRJ_ROOT"
|
cd "$PRJ_ROOT"
|
||||||
nix run ".#nixosConfigurations.\"$1\".config.my.buildAs.devVM"
|
tmp="$(mktemp -d nix-vm.XXXXXXXXXX --tmpdir)"
|
||||||
|
install -Dm0400 "${devKey}" "$tmp/xchg/dev.key"
|
||||||
|
TMPDIR="$tmp" USE_TMPDIR=1 nix run ".#nixosConfigurations.\"$1\".config.my.buildAs.devVM"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -62,6 +62,7 @@ in
|
|||||||
virtualisation = {
|
virtualisation = {
|
||||||
diskImage = dummyOption;
|
diskImage = dummyOption;
|
||||||
forwardPorts = dummyOption;
|
forwardPorts = dummyOption;
|
||||||
|
sharedDirectories = dummyOption;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ lib, config, secretsPath, ... }:
|
{ lib, config, secretsPath, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) mapAttrs;
|
inherit (builtins) mapAttrs;
|
||||||
|
inherit (lib) mkMerge mkIf;
|
||||||
inherit (lib.my) mkOpt';
|
inherit (lib.my) mkOpt';
|
||||||
|
|
||||||
cfg = config.my.secrets;
|
cfg = config.my.secrets;
|
||||||
@ -11,7 +12,14 @@ in
|
|||||||
files = mkOpt' (attrsOf unspecified) { } "Secrets to decrypt with agenix.";
|
files = mkOpt' (attrsOf unspecified) { } "Secrets to decrypt with agenix.";
|
||||||
};
|
};
|
||||||
|
|
||||||
config.age.secrets = mapAttrs (f: opts: {
|
config = mkMerge [
|
||||||
file = "${secretsPath}/${f}.age";
|
{
|
||||||
} // opts) cfg.files;
|
age.secrets = mapAttrs (f: opts: {
|
||||||
|
file = "${secretsPath}/${f}.age";
|
||||||
|
} // opts) cfg.files;
|
||||||
|
}
|
||||||
|
(mkIf config.my.build.isDevVM {
|
||||||
|
age.identityPaths = [ "/tmp/xchg/dev.key" ];
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user