Compare commits

...

9 Commits

22 changed files with 226 additions and 343 deletions

View File

@@ -13,7 +13,7 @@ let
deployment = {
targetHost = self.nixosConfigurations.${hostname}.config.ssh.publicHostname;
targetUser = self.nixosConfigurations.${hostname}.config.ssh.username;
buildOnTarget = builtins.any (t: t != "local") tags;
buildOnTarget = builtins.any (t: t != "local" && t != "arm") tags;
inherit tags;
};
};
@@ -22,7 +22,8 @@ let
hostname: mkNode hostname (utils.hostMeta ../hosts/${hostname}).deployment.tags
);
in
inputs.colmena.lib.makeHive {
inputs.colmena.lib.makeHive (
{
meta = {
nixpkgs = import inputs.nixpkgs {
localSystem = "x86_64-linux";
@@ -31,6 +32,6 @@ inputs.colmena.lib.makeHive {
nodeNixpkgs = builtins.mapAttrs (_: v: v.pkgs) self.nixosConfigurations;
nodeSpecialArgs = builtins.mapAttrs (_: v: v._module.specialArgs or { }) self.nixosConfigurations;
};
inherit nodes;
}
// nodes
)

View File

@@ -1,221 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
readonly ALLOWED_MAIN_BRANCHES=("main" "master" "develop")
readonly BRANCH_TYPES=(
"feat For new features"
"hotfix For urgent fixes"
"fix For fixes"
"release For preparing releases"
"chore For non-code tasks"
)
error() {
echo "Error: $1" >&2
exit 1
}
warn() {
echo "Warning: $1" >&2
}
check_dependencies() {
local missing=()
for cmd in git fzf; do
if ! command -v "$cmd" &> /dev/null; then
missing+=("$cmd")
fi
done
if [[ ${#missing[@]} -gt 0 ]]; then
error "Missing required commands: ${missing[*]}"
fi
}
check_git_repo() {
if ! git rev-parse --git-dir &> /dev/null; then
error "Not in a git repository"
fi
}
check_current_branch() {
local current_branch
current_branch=$(git branch --show-current)
local is_main_branch=false
for branch in "${ALLOWED_MAIN_BRANCHES[@]}"; do
if [[ "$current_branch" == "$branch" ]]; then
is_main_branch=true
break
fi
done
if [[ "$is_main_branch" == false ]]; then
warn "Not branching from a main branch (current: $current_branch)"
read -rp "Continue anyway? [y/N] " response
if [[ ! "$response" =~ ^[Yy]$ ]]; then
exit 0
fi
fi
}
get_user_email() {
local email
email=$(git config --get user.email 2>/dev/null)
if [[ -z "$email" ]]; then
error "Git user email not configured. Run: git config user.email 'your@email.com'"
fi
echo "$email"
}
select_branch_type() {
local selected
selected=$(printf '%s\n' "${BRANCH_TYPES[@]}" | \
fzf --prompt="Select branch type: " \
--height=40% \
--border \
--info=inline) || error "Branch type selection cancelled"
echo "${selected%% *}"
}
select_jira_ticket() {
local email=$1
if ! command -v jira &> /dev/null; then
warn "Jira CLI not found. Proceeding without ticket ID."
return 0
fi
echo "Fetching Jira tickets for $email..." >&2
local jira_data
jira_data=$(jira issue list --assignee="$email" --order-by=priority --plain --no-headers 2>/dev/null) || {
warn "Could not fetch Jira tickets. Proceeding without ticket ID."
return 0
}
if [[ -z "$jira_data" ]]; then
warn "No Jira tickets found. Proceeding without ticket ID."
return 0
fi
echo "$jira_data" >&2
echo "" >&2
local formatted_tickets
formatted_tickets=$(echo "$jira_data" | awk '{
ticket_id = $2
$1 = $2 = ""
description = $0
gsub(/^[ \t]+/, "", description)
if (length(description) > 60) {
description = substr(description, 1, 57) "..."
}
print ticket_id " - " description
}')
if [[ -z "$formatted_tickets" ]]; then
warn "No tickets to display. Proceeding without ticket ID."
return 0
fi
local selected_ticket
selected_ticket=$(echo -e "SKIP - Create branch without ticket ID\n$formatted_tickets" | \
fzf --prompt="Select Jira ticket (or skip): " \
--height=40% \
--border \
--info=inline) || error "Ticket selection cancelled"
if [[ "$selected_ticket" != "SKIP"* ]]; then
echo "${selected_ticket%% -*}"
fi
}
get_branch_description() {
local ticket_id=$1
local editor="${EDITOR:-vi}"
local tmpfile
tmpfile=$(mktemp)
trap "rm -f '$tmpfile'" EXIT
if [[ -n "$ticket_id" ]]; then
cat > "$tmpfile" << EOF
# Selected ticket: $ticket_id
# Enter your branch description below in kebab-case (e.g., my-description):
# The ticket ID will be automatically included in the branch name.
# Lines starting with # will be ignored.
EOF
else
cat > "$tmpfile" << 'EOF'
# Enter your branch description below in kebab-case (e.g., my-description):
# Lines starting with # will be ignored.
EOF
fi
"$editor" "$tmpfile" < /dev/tty > /dev/tty
local desc
desc=$(grep -v '^#' "$tmpfile" | tr -d '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
echo "$desc"
}
validate_description() {
local desc=$1
if [[ -z "$desc" ]]; then
error "No description provided"
fi
if [[ ! "$desc" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]]; then
error "Invalid branch description format.\nUse lowercase letters, numbers, and hyphens only.\nNo trailing or consecutive hyphens allowed.\nExample: my-feature-description"
fi
}
create_branch() {
local type=$1
local ticket_id=$2
local desc=$3
local branch
if [[ -n "$ticket_id" ]]; then
branch="$type/$ticket_id-$desc"
else
branch="$type/$desc"
fi
if git show-ref --verify --quiet "refs/heads/$branch"; then
error "Branch '$branch' already exists"
fi
echo ""
echo "Creating branch: $branch"
git checkout -b "$branch"
}
main() {
check_dependencies
check_git_repo
check_current_branch
local email
email=$(get_user_email)
local type
type=$(select_branch_type)
echo "About to call select_jira_ticket" >&2
local ticket_id=""
ticket_id=$(select_jira_ticket "$email")
local desc
desc=$(get_branch_description "$ticket_id")
validate_description "$desc"
create_branch "$type" "$ticket_id" "$desc"
}
main "$@"

View File

@@ -42,11 +42,11 @@
},
"nixCats": {
"locked": {
"lastModified": 1770584904,
"narHash": "sha256-9Zaz8lbKF2W9pwXZEnbiGsicHdBoU+dHt3Wv3mCJoZ8=",
"lastModified": 1774835836,
"narHash": "sha256-6ok7iv/9R82vl6MYe3Lwyyb6S5bmW2PxEZtmjzlqyPs=",
"owner": "BirdeeHub",
"repo": "nixCats-nvim",
"rev": "538fdde784d2909700d97a8ef307783b33a86fb1",
"rev": "ebb9f279a55ca60ff4e37e4accf6518dc627aa8d",
"type": "github"
},
"original": {
@@ -73,11 +73,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1770843696,
"narHash": "sha256-LovWTGDwXhkfCOmbgLVA10bvsi/P8eDDpRudgk68HA8=",
"lastModified": 1775608838,
"narHash": "sha256-2ySoGH+SAi34U0PeuQgABC0WiH9LQ3tkyHTiE93KUeg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2343bbb58f99267223bc2aac4fc9ea301a155a16",
"rev": "9a01fad67a57e44e1b3e1d905c6881bcfb209e8a",
"type": "github"
},
"original": {
@@ -106,11 +106,11 @@
"plugins-helm-ls-nvim": {
"flake": false,
"locked": {
"lastModified": 1768584652,
"narHash": "sha256-jnMc87OjURNcqsva0npYgVyUrWc5C6L7yHpNvt9eSmg=",
"lastModified": 1773934114,
"narHash": "sha256-8trqFsA7nTKSdtkiAL0Sa9bXjh5ONtAqN7XNE/B8ukM=",
"owner": "qvalentin",
"repo": "helm-ls.nvim",
"rev": "f0b9a1723890971a6d84890b50dbf5f40974ea1b",
"rev": "20df43509b02a3ce3c6b3eee254d6e2bffa9a370",
"type": "github"
},
"original": {

View File

@@ -78,8 +78,6 @@
mcp-hub
nixd
nixfmt
nodePackages.prettier
nodePackages.typescript-language-server
ormolu
prettierd
rust-analyzer
@@ -88,6 +86,7 @@
stylelint
stylua
tree-sitter
typescript-language-server
vscode-langservers-extracted
vtsls
yaml-language-server

View File

@@ -70,9 +70,6 @@
};
in
{
nix.nixPath = [
"nixpkgs=${inputs.nixpkgs}"
]; # <https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md>
nixosConfigurations =
(lib.genAttrs hostDirNames (
host:

View File

@@ -4,13 +4,19 @@
pkgs,
myUtils,
osConfig ? null,
inputs ? null,
...
}:
let
sops = myUtils.sopsAvailability config osConfig;
standalone = osConfig == null;
in
{
sops.secrets = lib.mkIf standalone (
myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" "anki" [ "sync-user" "sync-key" ] { }
);
warnings = lib.optional (
!sops.available && config.programs.anki.enable
) "anki is enabled but sops secrets are not available. anki sync will not be configured.";
@@ -24,8 +30,8 @@ in
review-heatmap
];
profiles."User 1".sync = lib.mkIf sops.available {
usernameFile = "${sops.secrets."anki-sync-user".path}";
keyFile = "${sops.secrets."anki-sync-key".path}";
usernameFile = "${sops.secrets."anki/sync-user".path}";
keyFile = "${sops.secrets."anki/sync-key".path}";
};
};
}

View File

@@ -5,13 +5,31 @@
dotsPath,
myUtils,
osConfig ? null,
inputs ? null,
...
}:
let
sops = myUtils.sopsAvailability config osConfig;
standalone = osConfig == null;
in
{
sops = lib.mkIf standalone {
secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" "taskwarrior" [
"sync-server-url"
"sync-server-client-id"
"sync-encryption-secret"
] { };
templates."taskrc.d/sync" = {
content = ''
sync.server.url=${config.sops.placeholder."taskwarrior/sync-server-url"}
sync.server.client_id=${config.sops.placeholder."taskwarrior/sync-server-client-id"}
sync.encryption_secret=${config.sops.placeholder."taskwarrior/sync-encryption-secret"}
'';
};
};
warnings =
lib.optional (!sops.available && config.programs.taskwarrior.enable)
"taskwarrior is enabled, but sops templates are not available. taskwarrior sync will not be configured.";

View File

@@ -23,6 +23,7 @@ in
inherit lib config;
device = "/dev/nvme1n1";
})
../../modules/anki
../../modules/audio
../../modules/backups
../../modules/bluetooth
@@ -31,19 +32,23 @@ in
../../modules/firewall
../../modules/fonts
../../modules/gaming
../../modules/networking
../../modules/git
../../modules/hcloud
../../modules/keyboard
../../modules/localization
../../modules/networking
../../modules/nvidia
../../modules/ai-tools
(import ../../modules/secrets { inherit lib inputs config; })
../../modules/ssh
../../modules/storage
../../modules/stylix
../../modules/syncthing
../../modules/tailscale
../../modules/taskwarrior
../../modules/users
../../modules/wol
../../modules/yubikey
../../modules/hcloud
];
home-manager.users.${config.host.username} = import ../../home/hosts/andromache {
@@ -62,7 +67,11 @@ in
inherit (config.host) username;
nixSigningKey.enable = true;
};
tailscale.enable = true;
docker.user = config.host.username;
hcloud = {
enable = true;
inherit (config.host) username;

View File

@@ -23,11 +23,14 @@ in
device = "/dev/nvme0n1";
})
../../modules/desktops/niri
../../modules/anki
../../modules/audio
../../modules/backups
../../modules/bluetooth
../../modules/git
../../modules/keyboard
../../modules/networking
../../modules/ai-tools
../../modules/users
../../modules/localization
../../modules/fonts
@@ -38,6 +41,7 @@ in
../../modules/docker
../../modules/nfc
../../modules/firewall
../../modules/taskwarrior
];
home-manager.users.${config.host.username} = import ../../home/hosts/astyanax {

View File

@@ -1 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzP1PjIDb1tN9nhPOK88HYDtTNk9SN9ZpEem2id49Fa h@astyanax
sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIJApgl/+QaAtrg0OK5ihXasdcnDwzFo6qtHbgnqGFl25AAAABHNzaDo= h@astyanax

View File

@@ -12,20 +12,24 @@
./host.nix
./disk.nix
../../modules/common
../../modules/boot/bootloader.nix
../../modules/keyboard
../../modules/networking
../../modules/users
../../modules/anki
../../modules/audio
../../modules/localization
../../modules/x
../../modules/boot/bootloader.nix
../../modules/fonts
../../modules/git
../../modules/keyboard
../../modules/localization
../../modules/networking
../../modules/ai-tools
../../modules/ssh
../../modules/storage
../../modules/stylix
(import ../../modules/secrets {
inherit lib inputs config;
})
../../modules/taskwarrior
../../modules/users
../../modules/x
];
home-manager.users.${config.host.username} = import ../../home/hosts/vm {

View File

@@ -0,0 +1,24 @@
{ config, myUtils, ... }:
let
inherit (config.secrets) sopsDir username;
owner = config.users.users.${username}.name;
in
{
config.sops = {
secrets = myUtils.mkSopsSecrets sopsDir "opencode" [ "api-key" ] { inherit owner; };
templates."opencode/auth.json" = {
inherit owner;
path = "/home/${username}/.local/share/opencode/auth.json";
content = ''
{
"zai-coding-plan": {
"type": "api",
"key": "${config.sops.placeholder."opencode/api-key"}"
}
}
'';
};
};
}

11
modules/anki/default.nix Normal file
View File

@@ -0,0 +1,11 @@
{ config, myUtils, ... }:
let
inherit (config.secrets) sopsDir username;
owner = config.users.users.${username}.name;
in
{
config.sops = {
secrets = myUtils.mkSopsSecrets sopsDir "anki" [ "sync-user" "sync-key" ] { inherit owner; };
};
}

View File

@@ -1,6 +1,7 @@
{
lib,
config,
myUtils,
...
}:
@@ -13,12 +14,12 @@ in
restic-backup = {
repository = lib.mkOption {
type = lib.types.str;
default = "b2:${config.sops.placeholder.b2-bucket-name}:${config.networking.hostName}";
default = "b2:${config.sops.placeholder."backblaze-b2/bucket-name"}:${config.networking.hostName}";
};
passwordFile = lib.mkOption {
type = lib.types.str;
default = config.sops.secrets.restic-password.path;
default = config.sops.secrets."restic/password".path;
};
paths = lib.mkOption {
@@ -30,28 +31,18 @@ in
config = {
sops = {
secrets = {
restic-password = {
sopsFile = "${sopsDir}/restic-password";
};
b2-bucket-name = {
sopsFile = "${sopsDir}/b2-bucket-name";
};
b2-account-id = {
sopsFile = "${sopsDir}/b2-account-id";
};
b2-account-key = {
sopsFile = "${sopsDir}/b2-account-key";
};
};
secrets = lib.mkMerge [
(myUtils.mkSopsSecrets sopsDir "restic" [ "password" ] { })
(myUtils.mkSopsSecrets sopsDir "backblaze-b2" [ "bucket-name" "account-id" "account-key" ] { })
];
templates = {
"restic/repo-${config.networking.hostName}" = {
content = "b2:${config.sops.placeholder.b2-bucket-name}:${config.networking.hostName}";
content = "b2:${config.sops.placeholder."backblaze-b2/bucket-name"}:${config.networking.hostName}";
};
"restic/b2-env-${config.networking.hostName}" = {
content = ''
B2_ACCOUNT_ID=${config.sops.placeholder.b2-account-id}
B2_ACCOUNT_KEY=${config.sops.placeholder.b2-account-key}
B2_ACCOUNT_ID=${config.sops.placeholder."backblaze-b2/account-id"}
B2_ACCOUNT_KEY=${config.sops.placeholder."backblaze-b2/account-key"}
'';
};
};

View File

@@ -25,6 +25,7 @@ in
system.stateVersion = lib.mkDefault "25.05";
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md
optimise = {
automatic = true;
dates = [ "05:00" ];

View File

@@ -19,7 +19,10 @@ in
};
config = {
programs.niri.enable = true;
programs.niri = {
enable = true;
useNautilus = false;
};
xdg.portal = {
enable = true;
@@ -33,6 +36,7 @@ in
};
services = {
gnome.gnome-keyring.enable = false;
dbus.enable = true;
logind.settings.Login = {
HandleLidSwitch = "suspend";

29
modules/git/default.nix Normal file
View File

@@ -0,0 +1,29 @@
{
config,
...
}:
let
inherit (config.secrets) username;
owner = config.users.users.${username}.name;
in
{
config.sops.templates = {
".gitconfig.email" = {
inherit owner;
path = "/home/${username}/.gitconfig.email";
content = ''
[user]
email = ${config.sops.placeholder."email/personal"}
'';
};
".gitconfig.work.email" = {
inherit owner;
path = "/home/${username}/.gitconfig.work.email";
content = ''
[user]
email = ${config.sops.placeholder."email/work"}
'';
};
};
}

View File

@@ -1,6 +1,7 @@
{
lib,
config,
myUtils,
...
}:
@@ -18,8 +19,7 @@ in
};
config = lib.mkIf cfg.enable {
sops.secrets.hcloud-token = {
sopsFile = "${sopsDir}/hcloud-token";
sops.secrets = myUtils.mkSopsSecrets sopsDir "hcloud" [ "api-token" ] {
owner = config.users.users.${cfg.username}.name;
};
@@ -31,7 +31,7 @@ in
[[contexts]]
name = "server"
token = "${config.sops.placeholder.hcloud-token}"
token = "${config.sops.placeholder."hcloud/api-token"}"
'';
};
};

View File

@@ -2,6 +2,7 @@
lib,
inputs,
config,
myUtils,
...
}:
@@ -9,13 +10,7 @@ let
cfg = config.secrets;
inherit (cfg) sopsDir;
owner = config.users.users.${cfg.username}.name;
mkSecret = name: {
${name} = {
sopsFile = "${sopsDir}/${name}";
inherit owner;
};
};
mkSopsSecrets = myUtils.mkSopsSecrets sopsDir;
in
{
imports = [ inputs.sops-nix.nixosModules.sops ];
@@ -46,61 +41,15 @@ in
age.keyFile = "/home/${cfg.username}/.config/sops/age/keys.txt";
secrets = lib.mkMerge [
(mkSecret "taskwarrior-sync-server-url")
(mkSecret "taskwarrior-sync-server-client-id")
(mkSecret "taskwarrior-sync-encryption-secret")
(mkSecret "anki-sync-user")
(mkSecret "anki-sync-key")
(mkSecret "email-personal")
(mkSecret "email-work")
(mkSecret "opencode-api-key")
(lib.mkIf cfg.nixSigningKey.enable (mkSecret cfg.nixSigningKey.name))
(mkSopsSecrets "email" [ "personal" "work" ] { inherit owner; })
(lib.mkIf cfg.nixSigningKey.enable (
mkSopsSecrets cfg.nixSigningKey.name [ cfg.nixSigningKey.name ] { inherit owner; }
))
];
templates = {
"taskrc.d/sync" = {
inherit owner;
content = ''
sync.server.url=${config.sops.placeholder.taskwarrior-sync-server-url}
sync.server.client_id=${config.sops.placeholder.taskwarrior-sync-server-client-id}
sync.encryption_secret=${config.sops.placeholder.taskwarrior-sync-encryption-secret}
'';
};
".gitconfig.email" = {
inherit owner;
path = "/home/${cfg.username}/.gitconfig.email";
content = ''
[user]
email = ${config.sops.placeholder.email-personal}
'';
};
".gitconfig.work.email" = {
inherit owner;
path = "/home/${cfg.username}/.gitconfig.work.email";
content = ''
[user]
email = ${config.sops.placeholder.email-work}
'';
};
"opencode/auth.json" = {
inherit owner;
path = "/home/${cfg.username}/.local/share/opencode/auth.json";
content = ''
{
"zai-coding-plan": {
"type": "api",
"key": "${config.sops.placeholder.opencode-api-key}"
}
}
'';
};
};
};
nix.settings.secret-key-files = lib.mkIf cfg.nixSigningKey.enable [
config.sops.secrets.${cfg.nixSigningKey.name}.path
config.sops.secrets."${cfg.nixSigningKey.name}/${cfg.nixSigningKey.name}".path
];
};
}

View File

@@ -0,0 +1,17 @@
{
lib,
config,
...
}:
{
options.tailscale = {
enable = lib.mkEnableOption "tailscale";
};
config = lib.mkIf config.tailscale.enable {
services.tailscale = {
enable = true;
openFirewall = true;
};
};
}

View File

@@ -0,0 +1,24 @@
{ config, myUtils, ... }:
let
inherit (config.secrets) sopsDir username;
owner = config.users.users.${username}.name;
in
{
config.sops = {
secrets = myUtils.mkSopsSecrets sopsDir "taskwarrior" [
"sync-server-url"
"sync-server-client-id"
"sync-encryption-secret"
] { inherit owner; };
templates."taskrc.d/sync" = {
inherit owner;
content = ''
sync.server.url=${config.sops.placeholder."taskwarrior/sync-server-url"}
sync.server.client_id=${config.sops.placeholder."taskwarrior/sync-server-client-id"}
sync.encryption_secret=${config.sops.placeholder."taskwarrior/sync-encryption-secret"}
'';
};
};
}

View File

@@ -11,15 +11,31 @@
else
throw "meta.nix required in ${hostDir}";
mkSopsSecrets =
sopsDir: group: names: extraOpts:
let
file = "${group}.yaml";
in
lib.foldl' lib.mergeAttrs { } (
map (name: {
"${group}/${name}" = {
sopsFile = "${sopsDir}/${file}";
key = name;
}
// extraOpts;
}) names
);
sopsAvailability =
config: osConfig:
let
hmSopsAvailable = config ? sops && config.sops ? secrets;
osSopsAvailable = osConfig != null && osConfig ? sops && osConfig.sops ? secrets;
hmSopsAvailable = config ? sops && config.sops ? secrets;
preferOs = osSopsAvailable;
in
{
available = hmSopsAvailable || osSopsAvailable;
secrets = if hmSopsAvailable then config.sops.secrets else osConfig.sops.secrets;
templates = if hmSopsAvailable then config.sops.templates else osConfig.sops.templates;
available = osSopsAvailable || hmSopsAvailable;
secrets = if preferOs then osConfig.sops.secrets else config.sops.secrets;
templates = if preferOs then osConfig.sops.templates else config.sops.templates;
};
}