Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions modules/home-manager/sops.nix
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ let
gnupgHome = cfg.gnupg.home;
sshKeyPaths = cfg.gnupg.sshKeyPaths;
ageKeyFile = cfg.age.keyFile;
ageSshKeyFile = cfg.age.sshKeyFile;
ageSshKeyPaths = cfg.age.sshKeyPaths;
placeholderBySecretName = cfg.placeholder;
userMode = true;
Expand Down Expand Up @@ -250,11 +251,26 @@ in
'';
};

sshKeyFile = lib.mkOption {
type = lib.types.nullOr pathNotInStore;
default = null;
example = "/home/someuser/.ssh/id_ed25519";
description = ''
Path to ssh key file that will be used by age for sops decryption.

Unlike {option}`config.sops.age.sshKeyPaths`, this option makes use of
the native ssh key support in age and requires no conversion.
'';
};

sshKeyPaths = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [ ];
description = ''
Paths to ssh keys added as age keys during sops description.

These ssh keys will be converted into age keys automatically using
ssh-to-age before they are fed to age.
'';
};
};
Expand Down Expand Up @@ -301,6 +317,7 @@ in
|| cfg.gnupg.sshKeyPaths != [ ]
|| cfg.gnupg.qubes-split-gpg.enable == true
|| cfg.age.keyFile != null
|| cfg.age.sshKeyFile != null
|| cfg.age.sshKeyPaths != [ ];
message = "No key source configured for sops. Either set services.openssh.enable or set sops.age.keyFile or sops.gnupg.home or sops.gnupg.qubes-split-gpg.enable";
}
Expand Down
16 changes: 16 additions & 0 deletions modules/nix-darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,27 @@ in
'';
};

sshKeyFile = lib.mkOption {
type = lib.types.nullOr pathNotInStore;
default = null;
example = "/etc/ssh/ssh_host_ed25519_key";
description = ''
Path to ssh key file that will be used by age for sops decryption.

Unlike {option}`config.sops.age.sshKeyPaths`, this option makes use of
the native ssh key support in age and requires no conversion.
'';
};

sshKeyPaths = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = defaultImportKeys "ed25519";
defaultText = lib.literalMD "The ed25519 keys from {option}`config.services.openssh.hostKeys`";
description = ''
Paths to ssh keys added as age keys during sops description.

These ssh keys will be converted into age keys automatically using
ssh-to-age before they are fed to age.
'';
};
};
Expand Down Expand Up @@ -345,6 +360,7 @@ in
cfg.gnupg.home != null
|| cfg.gnupg.sshKeyPaths != [ ]
|| cfg.age.keyFile != null
|| cfg.age.sshKeyFile != null
|| cfg.age.sshKeyPaths != [ ];
message = "No key source configured for sops. Either set services.openssh.enable or set sops.age.keyFile or sops.gnupg.home";
}
Expand Down
1 change: 1 addition & 0 deletions modules/nix-darwin/manifest-for.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ writeTextFile {
gnupgHome = cfg.gnupg.home;
sshKeyPaths = cfg.gnupg.sshKeyPaths;
ageKeyFile = cfg.age.keyFile;
ageSshKeyFile = cfg.age.sshKeyFile;
ageSshKeyPaths = cfg.age.sshKeyPaths;
useTmpfs = false;
placeholderBySecretName = cfg.placeholder;
Expand Down
16 changes: 16 additions & 0 deletions modules/sops/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,27 @@ in
'';
};

sshKeyFile = lib.mkOption {
type = lib.types.nullOr pathNotInStore;
default = null;
example = "/etc/ssh/ssh_host_ed25519_key";
description = ''
Path to ssh key file that will be used by age for sops decryption.

Unlike {option}`config.sops.age.sshKeyPaths`, this option makes use of
the native ssh key support in age and requires no conversion.
'';
};

sshKeyPaths = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = defaultImportKeys "ed25519";
defaultText = lib.literalMD "The ed25519 keys from {option}`config.services.openssh.hostKeys`";
description = ''
Paths to ssh keys added as age keys during sops description.

These ssh keys will be converted into age keys automatically using
ssh-to-age before they are fed to age.
'';
};
};
Expand Down Expand Up @@ -405,6 +420,7 @@ in
cfg.gnupg.home != null
|| cfg.gnupg.sshKeyPaths != [ ]
|| cfg.age.keyFile != null
|| cfg.age.sshKeyFile != null
|| cfg.age.sshKeyPaths != [ ];
message = "No key source configured for sops. Either set services.openssh.enable or set sops.age.keyFile or sops.gnupg.home";
}
Expand Down
1 change: 1 addition & 0 deletions modules/sops/manifest-for.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ else
gnupgHome = cfg.gnupg.home;
sshKeyPaths = cfg.gnupg.sshKeyPaths;
ageKeyFile = cfg.age.keyFile;
ageSshKeyFile = cfg.age.sshKeyFile;
ageSshKeyPaths = cfg.age.sshKeyPaths;
useTmpfs = cfg.useTmpfs;
placeholderBySecretName = cfg.placeholder;
Expand Down
7 changes: 6 additions & 1 deletion pkgs/sops-install-secrets/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type manifest struct {
SSHKeyPaths []string `json:"sshKeyPaths"`
GnupgHome string `json:"gnupgHome"`
AgeKeyFile string `json:"ageKeyFile"`
AgeSSHKeyFile string `json:"ageSshKeyFile"`
AgeSSHKeyPaths []string `json:"ageSshKeyPaths"`
UseTmpfs bool `json:"useTmpfs"`
UserMode bool `json:"userMode"`
Expand Down Expand Up @@ -1325,7 +1326,7 @@ func installSecrets(args []string) error {
}

// Import age keys
if len(manifest.AgeSSHKeyPaths) != 0 || manifest.AgeKeyFile != "" {
if (len(manifest.AgeSSHKeyPaths) != 0 || manifest.AgeKeyFile != "") && manifest.AgeSSHKeyFile == "" {
keyfile := filepath.Join(manifest.SecretsMountPoint, "age-keys.txt")
os.Setenv("SOPS_AGE_KEY_FILE", keyfile)
// Create the keyfile
Expand Down Expand Up @@ -1360,6 +1361,10 @@ func installSecrets(args []string) error {
}
}

if manifest.AgeSSHKeyFile != "" {
os.Setenv("SOPS_AGE_SSH_PRIVATE_KEY_FILE", manifest.AgeSSHKeyFile)
}

if err := decryptSecrets(manifest.Secrets); err != nil {
return err
}
Expand Down
Loading