Compare commits

...

2 Commits

Author SHA1 Message Date
yukkop 557b6e9ef0 fix: migrator 2026-07-24 15:21:19 +04:00
yukkop e49f497045 fix: aga 2026-07-24 15:21:11 +04:00
5 changed files with 64 additions and 63 deletions
+4 -29
View File
@@ -1,4 +1,5 @@
{ {
flake,
pkgs, pkgs,
lib, lib,
... ...
@@ -42,6 +43,9 @@ in {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup"; home-manager.backupFileExtension = "backup";
home-manager.sharedModules = [
(flake + "/home/module/program/tmux.nix")
];
home-manager.users.${name} = { home-manager.users.${name} = {
home.stateVersion = "25.11"; home.stateVersion = "25.11";
@@ -84,35 +88,6 @@ in {
''; '';
}; };
programs.tmux = {
enable = true;
plugins = with pkgs.tmuxPlugins; [ resurrect continuum ];
keyMode = "vi";
escapeTime = 500;
historyLimit = 50000;
newSession = true;
extraConfig = ''
# resurrect
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-capture-pane-contents 'on'
resurrect_dir="$HOME/.tmux/resurrect"
set -g @resurrect-dir $resurrect_dir
set -g @resurrect-hook-post-save-all 'target=$(readlink -f $resurrect_dir/last); sed "s| --cmd .*-vim-pack-dir||g; s|/etc/profiles/per-user/$USER/bin/||g; s|/home/$USER/.nix-profile/bin/||g" $target | sponge $target'
# continuum
set -g @continuum-restore 'on'
set -g @continuum-boot 'on'
set -g @continuum-save-interval '10'
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key O select-pane -t :.-
'';
};
xdg.configFile."aerospace/aerospace.toml".text = '' xdg.configFile."aerospace/aerospace.toml".text = ''
start-at-login = false start-at-login = false
+30
View File
@@ -0,0 +1,30 @@
{ pkgs, ... }: {
programs.tmux = {
enable = true;
plugins = with pkgs.tmuxPlugins; [ resurrect continuum ];
keyMode = "vi";
escapeTime = 500;
historyLimit = 50000;
newSession = true;
extraConfig = ''
# resurrect
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-capture-pane-contents 'on'
resurrect_dir="$HOME/.tmux/resurrect"
set -g @resurrect-dir $resurrect_dir
set -g @resurrect-hook-post-save-all 'target=$(readlink -f $resurrect_dir/last); sed "s| --cmd .*-vim-pack-dir||g; s|/etc/profiles/per-user/$USER/bin/||g; s|/home/$USER/.nix-profile/bin/||g" $target | sponge $target'
# continuum
set -g @continuum-restore 'on'
set -g @continuum-boot 'on'
set -g @continuum-save-interval '10'
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key O select-pane -t :.-
'';
};
}
+1 -30
View File
@@ -25,36 +25,7 @@ in {
programs.bash.shellAliases.tmux = "tmux a"; programs.bash.shellAliases.tmux = "tmux a";
home-manager.sharedModules = [ home-manager.sharedModules = [
{ (flake + "/home/module/program/tmux.nix")
programs.tmux = {
enable = true;
plugins = with pkgs.tmuxPlugins; [ resurrect continuum ];
keyMode = "vi";
escapeTime = 500;
historyLimit = 50000;
newSession = true;
extraConfig = ''
# resurrect
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-capture-pane-contents 'on'
resurrect_dir="$HOME/.tmux/resurrect"
set -g @resurrect-dir $resurrect_dir
set -g @resurrect-hook-post-save-all 'target=$(readlink -f $resurrect_dir/last); sed "s| --cmd .*-vim-pack-dir||g; s|/etc/profiles/per-user/$USER/bin/||g; s|/home/$USER/.nix-profile/bin/||g" $target | sponge $target'
# continuum
set -g @continuum-restore 'on'
set -g @continuum-boot 'on'
set -g @continuum-save-interval '10'
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key O select-pane -t :.-
'';
};
}
]; ];
home-manager.users.root.home.stateVersion = lib.mkDefault "25.05"; home-manager.users.root.home.stateVersion = lib.mkDefault "25.05";
+21 -4
View File
@@ -434,6 +434,8 @@ migrate_down() {
target_migration=$(printf '%s' "$fs_migrations" | sed -n "${target_line}p") target_migration=$(printf '%s' "$fs_migrations" | sed -n "${target_line}p")
printf '%s' "$target_migration" printf '%s' "$target_migration"
fi fi
return 0
} }
migrate_up() { migrate_up() {
@@ -488,6 +490,7 @@ migrate_up() {
fi fi
printf '%s' "$target_migration" printf '%s' "$target_migration"
return 0
} }
migrate_to() { migrate_to() {
@@ -518,6 +521,8 @@ migrate_to() {
printf '%s' "$migration_name" printf '%s' "$migration_name"
;; ;;
esac esac
return 0
} }
migration_list() { migration_list() {
@@ -566,7 +571,10 @@ index_of() {
# no subshell, no pipeline # no subshell, no pipeline
while IFS= read -r m; do while IFS= read -r m; do
[ "$m" = "$name" ] && { printf '%s\n' "$i"; return 0; } if [ "$m" = "$name" ]; then
printf '%s\n' "$i"
return 0
fi
i=$((i+1)) i=$((i+1))
done <<EOF done <<EOF
$list $list
@@ -697,14 +705,20 @@ migrate() {
log info "Migration history validation: ${GREEN}OK${NC} (${WHITE}$i${NC} migrations match)" log info "Migration history validation: ${GREEN}OK${NC} (${WHITE}$i${NC} migrations match)"
eval "set -- $MIGRATOR_REMAINING_ARS" eval "set -- $MIGRATOR_REMAINING_ARS"
target_migration="$("migrate_$MIGRATE_SUBCOMMAND" "$@")" if ! target_migration="$("migrate_$MIGRATE_SUBCOMMAND" "$@")"; then
log error "failed to resolve migration target for ${WHITE}migrate $MIGRATE_SUBCOMMAND${NC}"
exit 1
fi
if [ -z "$db_migrations" ]; then if [ -z "$db_migrations" ]; then
log info "starting from clean migration state" log info "starting from clean migration state"
current_idx=0 current_idx=0
else else
current_migration=$(printf '%s\n' "$db_migrations" | tail -n1) current_migration=$(printf '%s\n' "$db_migrations" | tail -n1)
current_idx=$(index_of "$fs_migrations" "$current_migration") if ! current_idx=$(index_of "$fs_migrations" "$current_migration"); then
log error "current database migration is missing from filesystem: ${WHITE}$current_migration${NC}"
exit 2
fi
fi fi
log debug "filesystem migrations: ${WHITE}$fs_migrations${NC}" log debug "filesystem migrations: ${WHITE}$fs_migrations${NC}"
@@ -713,7 +727,10 @@ migrate() {
if [ -z "$target_migration" ]; then if [ -z "$target_migration" ]; then
target_idx=0 target_idx=0
else else
target_idx=$(index_of "$fs_migrations" "$target_migration") if ! target_idx=$(index_of "$fs_migrations" "$target_migration"); then
log error "target migration is missing from filesystem: ${WHITE}$target_migration${NC}"
exit 2
fi
fi fi
log debug "migration indexes: current=${WHITE}$current_idx${NC} target=${WHITE}$target_idx${NC}" log debug "migration indexes: current=${WHITE}$current_idx${NC} target=${WHITE}$target_idx${NC}"
@@ -24,6 +24,14 @@ if [ "$answer" -ne 4 ]; then
exit 1 exit 1
fi fi
log notice "test case: ${WHITE}unguarded assignment under errexit"
answer=$(index_of "$array" 'item4')
if [ "$answer" -ne 4 ]; then
log error "test failed: ${WHITE}wrong answer from unguarded assignment"
exit 1
fi
log notice "test case: ${WHITE}error: item not found" log notice "test case: ${WHITE}error: item not found"
if answer=$(index_of "$array" 'item10'); then if answer=$(index_of "$array" 'item10'); then
log error "test failed: ${WHITE} must return an error" log error "test failed: ${WHITE} must return an error"