1
0
Fork 0
nix-system-configurations/sops/default.nix

50 lines
1.5 KiB
Nix

# SPDX-FileCopyrightText: 2025 Ethan Reece <contact@ethanreece.com>
#
# SPDX-License-Identifier: MIT
{ ... }:
{
perSystem =
{ pkgs, ... }:
{
config = {
devshells.default = {
commands = [
{
help = " generate age user key";
name = "age-generate-user-key";
command = (
let
directory =
if pkgs.stdenv.hostPlatform.isDarwin then
# "~/Library/Application Support/sops/age"
"$nu.home-path | path join 'Library' 'Application Support' 'sops' 'age'"
else
"$nu.home-path | path join '.config' 'sops' 'age'";
# "~/.config/sops/age";
in
''
#!${pkgs.nushell}/bin/nu
let $target_dir = ${directory}
mkdir $target_dir
^"${pkgs.age}/bin/age-keygen" -o ($target_dir | path join "keys.txt")
^"${pkgs.uutils-coreutils-noprefix}/bin/cat" ($target_dir | path join "keys.txt")
''
);
category = " SOPS";
}
{
help = " edit secrets.yaml";
name = "sops-edit";
command = "${pkgs.sops}/bin/sops edit ./sops/secrets.yaml";
category = " SOPS";
}
];
packages = [
pkgs.age
pkgs.sops
];
};
};
};
}