Skip to content
Merged
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
14 changes: 14 additions & 0 deletions .sops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
keys:
- &user_ethan age10539mc6shf02hpa8huyjktdw3nfyavxdg8pt247wwvq4xrv8h5zs8nc0k0
- &user_et age1s2dhv789xf9jjfr9pdjsww7rf4dutl3qmavgpurlwj6l5khdkfasd4v7xn
- &host_eMac age1hqq6znfaedyrmqkqqnaafa243cus77nts3e5vunxdl5xkfm6ffgqmf70r8
- &host_mercury age1zkx88lththygcwj07xtz54tcvy6ltavnedrpskfpzcdh9tt2ngyq9gvqv5

creation_rules:
- path_regex: '^.*secrets\.(json|yml)'
key_groups:
- age:
- *user_ethan
- *user_et
- *host_eMac
- *host_mercury
13 changes: 13 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ move-rc-files:
sudo mv /etc/bashrc /etc/bashrc.before-nix-darwin
sudo mv /etc/zshrc /etc/zshrc.before-nix-darwin
sudo mv /etc/zprofile /etc/zprofile.before-nix-darwin

edit-secret file:
EDITOR="zeditor --wait" sops {{ file }}

update-secret-files:
find . -regextype egrep -regex '^.*secrets\.(json|yml)' -execdir sops updatekeys {} -y ';'

generate-user-age-key:
mkdir -p ~/.config/sops/age
nix shell nixpkgs#age --command sh -c "age-keygen -o ~/.config/sops/age/keys.txt"

host-age-key:
nix shell nixpkgs#ssh-to-age --command sh -c "sudo cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age"
21 changes: 21 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
haumea.url = "github:nix-community/haumea";
haumea.inputs.nixpkgs.follows = "nixpkgs";

sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";

treefmt.url = "github:numtide/treefmt-nix";
treefmt.inputs.nixpkgs.follows = "nixpkgs";

Expand Down
6 changes: 4 additions & 2 deletions lib/src/darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ let

l = inputs.nixpkgs.lib // builtins;

sharedModules = (l.attrValues flake.darwinModules)
++ [ inputs.home-manager.darwinModules.home-manager ];
sharedModules = (l.attrValues flake.darwinModules) ++ (with inputs; [
home-manager.darwinModules.home-manager
sops-nix.darwinModules.sops
]);

specialArgs = {
inherit flake inputs secrets homeConfigurations;
Expand Down
3 changes: 2 additions & 1 deletion lib/src/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ let

l = inputs.nixpkgs.lib // builtins;

sharedModules = l.attrValues flake.homeModules;
sharedModules = l.attrValues flake.homeModules
++ [ inputs.sops-nix.homeManagerModules.sops ];

extraSpecialArgs = {
inherit flake inputs secrets;
Expand Down
2 changes: 2 additions & 0 deletions modules/development/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
just
nh
nix-output-monitor
sops
inputs.home-manager.packages.${system}.default
];

shellHook = ''
export FLAKE_ROOT="${lib.getExe config.flake-root.package}"
export SOPS_AGE_KEY_FILE=$HOME/.config/sops/age/keys.txt
'';
};
};
Expand Down
4 changes: 4 additions & 0 deletions modules/development/treefmt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
};
prettier.enable = true;
};
settings.formatter = {
prettier.excludes =
[ "secrets.json" "**/secrets.json" "**/secrets.yml" ];
};
};
in {
treefmt.config = treefmtConfig;
Expand Down
8 changes: 8 additions & 0 deletions modules/profiles/home/sops.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ config, ... }: {
sops = {
defaultSopsFile = ../../../secrets.json;
defaultSopsFormat = "json";

age.keyFile = "${config.home.homeDirectory}/.config/sops/age/keys.txt";
};
}
14 changes: 0 additions & 14 deletions modules/profiles/system/core/nix-config.nix

This file was deleted.

30 changes: 30 additions & 0 deletions modules/profiles/system/core/nix-config/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ config, pkgs, ... }: {
sops = {
secrets.nix-conf-github-pat = { sopsFile = ./secrets.json; };

templates."nix/nix-conf-access-tokens" = {
content = ''
access-tokens = github.com=${config.sops.placeholder.nix-conf-github-pat}
'';
mode = "0777";
};
};

nixpkgs = {
# NOTE: This relies on all hosts having the same `system`. If a system comes along that is different, this cannot
# be set to the flake-wide `pkgs`, as it is here: https://nix-darwin.github.io/nix-darwin/manual/index.html#opt-nixpkgs.pkgs
inherit pkgs;

flake = {
setFlakeRegistry = true;
setNixPath = true;
};
};

nix = {
extraOptions =
"!include ${config.sops.templates."nix/nix-conf-access-tokens".path}";
gc.automatic = true;
};

}
19 changes: 19 additions & 0 deletions modules/profiles/system/core/nix-config/secrets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"nix-conf-github-pat": "ENC[AES256_GCM,data:DjbmhR4UP3R3qpM7OC+UeSb0WyO8Oylg8pwCcy7bOAr7fpJ/loUy3A==,iv:Q3gjC/T4NGimB3VrcOKsVLjKLCMBD2I6aXU3wUc6e5g=,tag:k8qLHD9Rt1ImKarbOweSMg==,type:str]",
"sops": {
"age": [
{
"recipient": "age10539mc6shf02hpa8huyjktdw3nfyavxdg8pt247wwvq4xrv8h5zs8nc0k0",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBBV1BzVHpRYWMzN2lrTmR1\nTG1CdDc5a2lMbXZxNnc5RnlhMEg0aklyUFNzCkovbElTOGhIZjNuMHFsU3ZNQWhN\nc0VNeFhST3EybGR6eDZqbnhNNUFsTmsKLS0tIGZlK0JDRG5QWWFXdnByQjdZTkti\neVNrQWFCUll2d2VFbFVEdkF1YnhEa2MK0EhU2rJSFMHJ9SUCBWxdgXXOh1gyGKDr\nY0A7DVjbhqZqPUz0DMmnrTn7um7uvxJqy+QEwd/nDUtbHgh1Ws/urQ==\n-----END AGE ENCRYPTED FILE-----\n"
},
{
"recipient": "age1hqq6znfaedyrmqkqqnaafa243cus77nts3e5vunxdl5xkfm6ffgqmf70r8",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBnUkN1VFJoOGJBVUszMmJL\najVnZkZ5bTRHZkJVcXlSS0toNDl2N0dIU2tJCnN5Q0MxdmVxc2s3cTY3bjgxUDBV\nY3YxNFE2YnhNSG1ZR0xDa09MbitLM2sKLS0tIHp4QmhMaEJkWFV1Y1NxSUp5WnVv\nY2tlSjBING01Yi9PeXcvQjZLSWpCUzgKwb98LBNBawqlAEGIuZzBWSh7S/4fLJV5\nVsewLWRGyePe/IbekpnYpENvVVP7oap9QSsdIdlYGyg4zycnQN1w1w==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2026-04-11T03:31:33Z",
"mac": "ENC[AES256_GCM,data:fPoY/fftAipHIGZynbTtIFlGu0s/UZvfLJSCtWDp9YV/5osA5qlY4yUm8sI3wpnNnGBtuJ2Ia2lYTnpUQX5G+pRtKtkBSRJT3c7fZ1pGqE5cqUZWpiR2n8LXLV0kYypng9/uvPEvQp7Qu9P2it1DNzhWu/Buj1w7e2enEZadtXo=,iv:GX58fuVZS5lfp70s8wA2/rrpKclTssmWuGcOKCsJqX4=,tag:IfdXnsr3BCneTyxySd3ZyQ==,type:str]",
"unencrypted_suffix": "_unencrypted",
"version": "3.12.1"
}
}
12 changes: 12 additions & 0 deletions modules/profiles/system/core/sops.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
sops = {
defaultSopsFormat = "json";
defaultSopsFile = ../../../../secrets.json;

age = {
sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
keyFile = "/var/lib/sops-nix/key.txt";
generateKey = true;
};
};
}
1 change: 1 addition & 0 deletions modules/suites/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ with profiles;
navi
paths
rippkgs
sops
starship
tmux.default
tools.common
Expand Down
3 changes: 2 additions & 1 deletion modules/suites/system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ with profiles;
{
base = [
core.lix
core.nix-config
core.nix-config.default
core.sops
darwin.brew
darwin.common
darwin.system-defaults
Expand Down
2 changes: 1 addition & 1 deletion users/ethan/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
./profiles/vscode.nix
];

home.packages = with pkgs; [ borgbackup nixd ];
home.packages = with pkgs; [ restic nixd ];

home = {
username = "ethan";
Expand Down
Loading