Skip to content

Commit 0b6cdd7

Browse files
committed
chore: better support for both versions, symlink default to v3 on new image
1 parent 899c235 commit 0b6cdd7

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

ansible/tasks/setup-wal-g.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
- name: Create symlink for wal-g from Nix profile to /usr/local/bin
3737
ansible.builtin.file:
3838
src: /home/wal-g/.nix-profile/bin/wal-g-2
39-
dest: /usr/local/bin/wal-g
39+
dest: /usr/local/bin/wal-g-v2
4040
state: link
4141
force: yes # This will replace existing file/symlink if it exists
4242
become: yes # Need sudo to write to /usr/local/bin
@@ -51,6 +51,15 @@
5151
become: yes # Need sudo to write to /usr/local/bin
5252
when: stage2_nix
5353

54+
- name: Create symlink to make wal-g-v3 the default wal-g
55+
ansible.builtin.file:
56+
src: /usr/local/bin/wal-g-v3
57+
dest: /usr/local/bin/wal-g
58+
state: link
59+
force: yes
60+
become: yes
61+
when: stage2_nix
62+
5463
- name: Create /etc/wal-g/config.json
5564
file:
5665
path: /etc/wal-g/config.json

nix/wal-g.nix

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,22 @@ let
4444
];
4545

4646
postInstall = ''
47-
mv $out/bin/pg $out/bin/wal-g
48-
installShellCompletion --cmd wal-g \
49-
--bash <($out/bin/wal-g completion bash) \
50-
--zsh <($out/bin/wal-g completion zsh)
47+
mv $out/bin/pg $out/bin/wal-g-${majorVersion}
48+
49+
# Create version-specific completions
50+
mkdir -p $out/share/bash-completion/completions
51+
$out/bin/wal-g-${majorVersion} completion bash > $out/share/bash-completion/completions/wal-g-${majorVersion}
52+
53+
mkdir -p $out/share/zsh/site-functions
54+
$out/bin/wal-g-${majorVersion} completion zsh > $out/share/zsh/site-functions/_wal-g-${majorVersion}
55+
5156
'';
5257

5358
meta = with lib; {
5459
homepage = "https://github.com/wal-g/wal-g";
5560
license = licenses.asl20;
5661
description = "Archival restoration tool for PostgreSQL";
57-
mainProgram = "wal-g";
62+
mainProgram = "wal-g-${majorVersion}";
5863
maintainers = [ samrose ];
5964
};
6065
};
@@ -75,4 +80,4 @@ in
7580
vendorHash = "sha256-YDLAmRfDl9TgbabXj/1rxVQ052NZDg3IagXVTe5i9dw=";
7681
majorVersion = "3";
7782
};
78-
}
83+
}

0 commit comments

Comments
 (0)