yep, more dotfiles

agenix: define secrets at usage

removed gitguardian hook

wiro.world 1f6edcdf 36cc778f

verified
-3
home-manager/fragments/agenix.nix
···
inherit (self.inputs) agenix;
cfg = config.local.fragment.agenix;
-
-
all-secrets = import ../../secrets;
in
{
options.local.fragment.agenix.enable = lib.mkEnableOption ''
···
imports = [ agenix.homeManagerModules.default ];
config = lib.mkIf cfg.enable {
-
age.secrets = all-secrets.home-manager;
# This allows us to decrypt user space secrets without having to use a
# passwordless ssh key as you cannot interact with age in the service.
age.identityPaths = [ "${config.home.homeDirectory}/.ssh/id_home_manager" ];
-10
home-manager/fragments/git.nix
···
{
options.local.fragment.git.enable = lib.mkEnableOption ''
Git related
-
-
Depends on:
-
- `agenix` fragment: Need for GPG key and GitGuardian API key
'';
config = lib.mkIf cfg.enable {
···
shl = "stash list";
sha = "stash apply";
shp = "stash pop";
-
};
-
-
hooks = {
-
git-guardian = pkgs.writeShellScript "git-guardian" ''
-
export GITGUARDIAN_API_KEY="$(cat ${config.age.secrets.api-gitguardian.path})"
-
${lib.getExe' pkgs.ggshield "ggshield"} secret scan pre-commit "$@"
-
'';
};
extraConfig = {
+2
home-manager/fragments/helix.nix
···
};
};
+
age.secrets.api-wakatime.file = ../../secrets/api-wakatime.age;
+
age.secrets.api-wakapi.file = ../../secrets/api-wakapi.age;
programs.wakatime = {
enable = true;
apiKeyFile = secrets.api-wakapi.path;
+1
home-manager/fragments/rust.nix
···
home.sessionPath = [ "${config.home.sessionVariables.CARGO_HOME}/bin" ];
# cargo config
+
age.secrets.api-crates-io.file = ../../secrets/api-crates-io.age;
home.file."${config.home.sessionVariables.CARGO_HOME}/config.toml".source =
let
clang = lib.getExe pkgs.llvmPackages.clang;
-3
home-manager/profiles/macintosh.nix
···
let
inherit (self.inputs) agenix;
-
-
all-secrets = import ../../secrets;
in
{
imports = [
agenix.homeManagerModules.default
{
-
age.secrets = all-secrets.home-manager;
# This allows us to decrypt user space secrets without having to use a
# passwordless ssh key as you cannot interact with age in the service.
age.identityPaths = [ "${config.home.homeDirectory}/.ssh/id_home_manager" ];
+3 -3
nixos/fragments/agenix.nix
···
inherit (self.inputs) agenix;
cfg = config.local.fragment.agenix;
-
all-secrets = import ../../secrets;
in
{
imports = [
···
config = lib.mkIf cfg.enable {
assertions = [
-
{ assertion = config.services.openssh.enable; message = "`agenix` fragement depends on `openssh` program"; }
+
{ assertion = config.services.openssh.enable; message = "`agenix` fragment depends on `openssh` program"; }
];
age = {
···
# be located on luks protected partitions.
# identityPaths = [ ];
-
secrets = all-secrets.nixos;
+
# Secrets are defined in the fragments that use it
+
# secrets = ...;
};
};
}
+63 -56
nixos/fragments/backup.nix
···
Backup related
'';
-
# TODO: fix module
-
config.assertions = lib.optional cfg.enable { assertion = false; message = "module is broken"; };
-
config.services.restic.backups = lib.mkIf cfg.enable {
-
# Backup documents and repos code
-
google-drive = {
-
repository = "rclone:googledrive:/Backups/${hostname}";
-
passwordFile = secrets.backup-restic-key.path;
-
rcloneConfigFile = secrets.backup-rclone-googledrive.path;
-
initialize = true;
-
paths = [
-
"/home/${mainUsername}/Documents"
-
# Equivalent of `~/Development` but needs extra handling as explained below
-
"/home/${mainUsername}/.local/backup/repos"
-
];
+
config = lib.mkIf cfg.enable {
+
# TODO: fix module
+
assertions = [{ assertion = false; message = "module is broken"; }];
-
# Extra handling for Development folder to respect `.gitignore` files.
-
#
-
# Backup folder should be stored somewhere to avoid changing ctimes
-
# which would cause otherwise unchanged files to be backed up again.
-
# Since `--link-dest` is used, file contents won't be duplicated on disk.
-
backupPrepareCommand = ''
-
# Remove stale Restic locks
-
${lib.getExe pkgs.restic} unlock || true
+
age.secrets.backup-restic-key.file = ../../secrets/backup/restic-key.age;
+
age.secrets.backup-rclone-google-drive.file = ../../secrets/backup/rclone-googledrive.age;
-
${lib.getExe pkgs.rsync} \
-
${"\\" /* Archive mode and delete files that are not in the source directory. `--mkpath` is like `mkdir`'s `-p` option */}
-
--archive --delete --mkpath \
-
${"\\" /* `:-` operator uses .gitignore files as exclude patterns */}
-
--filter=':- .gitignore' \
-
${"\\" /* Exclude nixpkgs repository because they have some weird symlink test files that break rsync */}
-
--exclude 'nixpkgs' \
-
${"\\" /* Hardlink files to avoid taking up more space */}
-
--link-dest=/home/${mainUsername}/Development \
-
/home/${mainUsername}/Development/ /home/${mainUsername}/.local/backup/repos
-
'';
+
services.restic.backups = {
+
# Backup documents and repos code
+
google-drive = {
+
repository = "rclone:googledrive:/Backups/${hostname}";
+
passwordFile = secrets.backup-restic-key.path;
+
rcloneConfigFile = secrets.backup-rclone-googledrive.path;
+
initialize = true;
+
+
paths = [
+
"/home/${mainUsername}/Documents"
+
# Equivalent of `~/Development` but needs extra handling as explained below
+
"/home/${mainUsername}/.local/backup/repos"
+
];
+
+
# Extra handling for Development folder to respect `.gitignore` files.
+
#
+
# Backup folder should be stored somewhere to avoid changing ctimes
+
# which would cause otherwise unchanged files to be backed up again.
+
# Since `--link-dest` is used, file contents won't be duplicated on disk.
+
backupPrepareCommand = ''
+
# Remove stale Restic locks
+
${lib.getExe pkgs.restic} unlock || true
+
+
${lib.getExe pkgs.rsync} \
+
${"\\" /* Archive mode and delete files that are not in the source directory. `--mkpath` is like `mkdir`'s `-p` option */}
+
--archive --delete --mkpath \
+
${"\\" /* `:-` operator uses .gitignore files as exclude patterns */}
+
--filter=':- .gitignore' \
+
${"\\" /* Exclude nixpkgs repository because they have some weird symlink test files that break rsync */}
+
--exclude 'nixpkgs' \
+
${"\\" /* Hardlink files to avoid taking up more space */}
+
--link-dest=/home/${mainUsername}/Development \
+
/home/${mainUsername}/Development/ /home/${mainUsername}/.local/backup/repos
+
'';
-
pruneOpts = [
-
"--keep-daily 7"
-
"--keep-weekly 5"
-
"--keep-yearly 10"
-
];
+
pruneOpts = [
+
"--keep-daily 7"
+
"--keep-weekly 5"
+
"--keep-yearly 10"
+
];
-
# TODO: fix config
-
timerConfig = null;
-
# timerConfig = {
-
# OnCalendar = "00:05";
-
# RandomizedDelaySec = "5h";
-
# };
-
};
+
# TODO: fix config
+
timerConfig = null;
+
# timerConfig = {
+
# OnCalendar = "00:05";
+
# RandomizedDelaySec = "5h";
+
# };
+
};
-
# Backup documents and large files
-
archaic-bak = {
-
repository = "/run/media/${mainUsername}/ArchaicBak/Backups/${hostname}";
-
passwordFile = secrets.backup-restic-key.path;
-
initialize = true;
+
# Backup documents and large files
+
archaic-bak = {
+
repository = "/run/media/${mainUsername}/ArchaicBak/Backups/${hostname}";
+
passwordFile = secrets.backup-restic-key.path;
+
initialize = true;
-
# this would fix issue that folder is created as root
-
# but we cannot access the backup key
-
user = config.local.user.username;
+
# this would fix issue that folder is created as root
+
# but we cannot access the backup key
+
user = config.local.user.username;
-
paths = [ "/home/${mainUsername}/Documents" ];
+
paths = [ "/home/${mainUsername}/Documents" ];
-
# Should only be ran manually when the backup Disk is attached
-
timerConfig = null;
+
# Should only be ran manually when the backup Disk is attached
+
timerConfig = null;
+
};
};
};
}
+2 -5
nixos/profiles/server.nix
···
inherit (self.inputs) srvos agenix tangled;
inherit (self.nixosModules) mindustry-server;
-
all-secrets = import ../../secrets;
-
ext-if = "eth0";
external-ip = "91.99.55.74";
external-netmask = 27;
···
];
config = {
-
age.secrets = all-secrets.deploy;
-
boot.loader.grub.enable = true;
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" "ext4" ];
···
services.tailscale.enable = true;
+
age.secrets.pds-env.file = ../../secrets/pds-env.age;
services.pds = {
enable = true;
package = upkgs.bluesky-pds;
···
};
environmentFiles = [
-
config.age.secrets.pds-config.path
+
config.age.secrets.pds-env.path
];
};
-9
secrets/api-digital-ocean.age
···
-
age-encryption.org/v1
-
-> X25519 QjkxfMP9vtiSZ+Y/7jkOURnuAdVCtQ/Rt1FAalv9Ijs
-
f4YwmiPs/u9A0x0tQ6UNK0697l6E6FrGhmyLJOZGsmI
-
-> ssh-ed25519 SmMcWg 7U9uVnJECX84xjSV1v18pzIb7GDd1zjaLNWfx1SWFBI
-
QZq9+tEJOh9C6XOiZdg4ISE8qt6Dzw9ABKZd6XAwZkk
-
-> ssh-ed25519 Q8rMFA wSgLP9znMedYlvWIJUmm9crT6nmItaxH2ajilON45gE
-
LqWiMQ4wJVVdUQZKXrJINFvVfQAK51vd0F4ENQgnZ7Y
-
--- iGtdwVDXIMUcgytMAUDg0hvcI2mJpupSIrhEaZZxi18
-
�k�UR�H��Jr�e���]�$��U����DT���\9;`o\<N�f�N���K�M�!'���������;���}߯�L���۟:v����@׫�X/�
-9
secrets/api-gitguardian.age
···
-
age-encryption.org/v1
-
-> X25519 P02aVaHZQ2qXu3isJo+EYi3l+8ah016KyFnmSMYZjzk
-
LhVoE334CQuJQkX983mH6HH7zr1UWe3xc+Mz6O0FzDk
-
-> ssh-ed25519 SmMcWg n8gZ++y3KQag3oTL/57CX+/X1wRvDT88hKxVE0CxRVQ
-
Ntsbw27gg3qsnCsx0myrsp08Er+KDL2okMI5wsC5NPU
-
-> ssh-ed25519 Q8rMFA fiOu3mPZzZDRNCKERYeqiVt4dcR1Jbzk0BUF0h2bPCM
-
97jBhXpNGD/p6VmfOZJWn+XMdZlKv/OqbVwfUuha1Qc
-
--- Q1AjMGJdUTSjfkYBSiZBrh5ra7rhfSKW/+f4daXP1iU
-
J��n�AL�����g<�7�En��kM�tk�����c*���L��P�R���M�P��::%�x��������x��V<$�M���\�4�r����6g�r���]
secrets/backup/rclone-googledrive.age secrets/backup-rclone-googledrive.age
secrets/backup/restic-key.age secrets/backup-restic-key.age
-26
secrets/default.nix
···
-
{
-
nixos = {
-
backup-rclone-googledrive.file = ./backup/rclone-googledrive.age;
-
backup-restic-key.file = ./backup/restic-key.age;
-
};
-
-
home-manager = {
-
api-crates-io.file = ./api-crates-io.age;
-
api-digital-ocean.file = ./api-digital-ocean.age;
-
api-gitguardian.file = ./api-gitguardian.age;
-
api-wakatime.file = ./api-wakatime.age;
-
api-wakapi.file = ./api-wakapi.age;
-
};
-
-
deploy = {
-
# Defines `PDS_JWT_SECRET`, `PDS_ADMIN_PASSWORD`,
-
# `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX`, `PDS_EMAIL_SMTP_URL` and
-
# `PDS_EMAIL_FROM_ADDRESS`
-
pds-config.file = ./pds-env.age;
-
};
-
-
none = {
-
pgp-ca5e.file = ./pgp-ca5e.age;
-
ssh-uxgi.file = ./ssh-uxgi.age;
-
};
-
}
+5 -4
secrets/secrets.nix
···
in
{
# Used in NixOS config
-
"backup/rclone-googledrive.age".publicKeys = nixos;
-
"backup/restic-key.age".publicKeys = nixos;
+
"backup-rclone-googledrive.age".publicKeys = nixos;
+
"backup-restic-key.age".publicKeys = nixos;
# Used in Home Manager
"api-crates-io.age".publicKeys = home-manager;
-
"api-digital-ocean.age".publicKeys = home-manager;
-
"api-gitguardian.age".publicKeys = home-manager;
"api-wakatime.age".publicKeys = home-manager;
"api-wakapi.age".publicKeys = home-manager;
+
# Used in server deployment
+
+
# Defines `PDS_JWT_SECRET`, `PDS_ADMIN_PASSWORD`, `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX`, `PDS_EMAIL_SMTP_URL`, `PDS_EMAIL_FROM_ADDRESS`.
"pds-env.age".publicKeys = deploy;
# Not used in config but useful