Skip to content

Commit 9ae26a0

Browse files
authored
Improve vscode launcher script (#9948)
2 parents 9ef32ba + 7b14f8a commit 9ae26a0

11 files changed

Lines changed: 652 additions & 132 deletions

File tree

.envrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
use nix
2-
layout python
3-
1+
use flake

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ clean.sh
3333
.vscode
3434
core
3535
.env
36+
environment.txt
37+
history.mp4

flake.lock

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
description = "Run QGIS with extra Python packages";
3+
4+
inputs.geospatial.url = "github:imincik/geospatial-nix.repo";
5+
inputs.nixpkgs.follows = "geospatial/nixpkgs";
6+
7+
outputs = { self, geospatial, nixpkgs }:
8+
let
9+
system = "x86_64-linux";
10+
pkgs = import nixpkgs {
11+
inherit system;
12+
config = { allowUnfree = true; };
13+
};
14+
extraPythonPackages = ps: [
15+
ps.pyqtwebengine
16+
ps.jsonschema
17+
ps.debugpy
18+
ps.future
19+
ps.psutil
20+
];
21+
qgisWithExtras = geospatial.packages.${system}.qgis.override {
22+
inherit extraPythonPackages;
23+
};
24+
qgisLtrWithExtras = geospatial.packages.${system}.qgis-ltr.override {
25+
inherit extraPythonPackages;
26+
};
27+
in {
28+
packages.${system} = {
29+
default = qgisWithExtras;
30+
qgis-ltr = qgisLtrWithExtras;
31+
};
32+
33+
devShells.${system}.default = pkgs.mkShell {
34+
packages = [
35+
pkgs.gum
36+
pkgs.gource
37+
pkgs.ffmpeg
38+
pkgs.chafa
39+
pkgs.pre-commit
40+
pkgs.nixfmt-rfc-style
41+
(pkgs.python3.withPackages (ps: [
42+
ps.pip
43+
ps.setuptools
44+
ps.sphinx
45+
ps.sphinx_rtd_theme
46+
ps.recommonmark
47+
ps.myst-parser
48+
ps.sphinx-autobuild
49+
ps.docutils
50+
ps.rstcheck
51+
ps.sphinxext-rediraffe
52+
ps.sphinx-togglebutton
53+
ps.sphinx-copybutton
54+
]))
55+
pkgs.vscode
56+
pkgs.transifex-cli
57+
pkgs.texlive.combined.scheme-full
58+
];
59+
shellHook = ''
60+
61+
#source ${./scripts/shell-hook.sh}
62+
'';
63+
};
64+
};
65+
}
66+

scripts/qgis-icon-128x128.png

10.5 KB
Loading

scripts/shell-hook.sh

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
function dev-help {
6+
echo "USAGE:"
7+
echo
8+
echo "nix develop"
9+
}
10+
11+
function setup_gum {
12+
# Choose
13+
export GUM_CHOOSE_CURSOR_FOREGROUND=" #F1C069"
14+
export GUM_CHOOSE_HEADER_FOREGROUND="#F1C069"
15+
export GUM_CHOOSE_ITEM_FOREGROUND="#F1C069"
16+
export GUM_CHOOSE_SELECTED_FOREGROUND="#F1C069"
17+
export GUM_CHOOSE_HEIGHT=20
18+
export GUM_CHOOSE_CURSOR="👉️"
19+
export GUM_CHOOSE_HEADER="Choose one:"
20+
export GUM_CHOOSE_CURSOR_PREFIX="❓️"
21+
export GUM_CHOOSE_SELECTED_PREFIX="👍️"
22+
export GUM_CHOOSE_UNSELECTED_PREFIX="⛔️"
23+
export GUM_CHOOSE_SELECTED=""
24+
export GUM_CHOOSE_TIMEOUT=30
25+
# Style
26+
export FOREGROUND="#F1C069"
27+
export BACKGROUND="#1F1F1F"
28+
export BORDER="rounded"
29+
export BORDER_BACKGROUND="#1F1F1F"
30+
export BORDER_FOREGROUND="#F1C069"
31+
export HEIGHT=3
32+
export WIDTH=80
33+
export MARGIN=1
34+
export PADDING=2
35+
# Confirm
36+
export GUM_CONFIRM_PROMPT_FOREGROUND="#F1C069"
37+
export GUM_CONFIRM_SELECTED_FOREGROUND="#F1C069"
38+
export GUM_CONFIRM_UNSELECTED_FOREGROUND="#F1C069"
39+
export GUM_CONFIRM_TIMEOUT=30s
40+
# Input
41+
export GUM_INPUT_PLACEHOLDER="-----------"
42+
export GUM_INPUT_PROMPT=">"
43+
export GUM_INPUT_CURSOR_MODE="blink"
44+
export GUM_INPUT_WIDTH=40
45+
export GUM_INPUT_HEADER="💬"
46+
export GUM_INPUT_TIMEOUT=30s
47+
export GUM_INPUT_PROMPT_FOREGROUND="#F1C069"
48+
export GUM_INPUT_CURSOR_FOREGROUND="#F1C069"
49+
export GUM_INPUT_HEADER_FOREGROUND="#F1C069"
50+
# Spin
51+
export GUM_SPIN_SPINNER_FOREGROUND="#F1C069"
52+
export GUM_SPIN_TITLE_FOREGROUND="#F1C069"
53+
# Table
54+
export GUM_TABLE_BORDER_FOREGROUND="#F1C069"
55+
export GUM_TABLE_CELL_FOREGROUND="#F1C069"
56+
export GUM_TABLE_HEADER_FOREGROUND="#F1C069"
57+
export GUM_TABLE_SELECTED_FOREGROUND="#F1C069"
58+
# Filter
59+
export GUM_FILTER_INDICATOR="👉️"
60+
export GUM_FILTER_SELECTED_PREFIX="💎"
61+
export GUM_FILTER_UNSELECTED_PREFIX=""
62+
export GUM_FILTER_HEADER="Chooser"
63+
export GUM_FILTER_PLACEHOLDER="."
64+
export GUM_FILTER_PROMPT="Select an option:"
65+
export GUM_FILTER_TIMEOUT=30s
66+
export GUM_FILTER_INDICATOR_FOREGROUND="#F1C069"
67+
export GUM_FILTER_SELECTED_PREFIX_FOREGROUND="#F1C069"
68+
export GUM_FILTER_UNSELECTED_PREFIX_FOREGROUND="#F8E3BD"
69+
export GUM_FILTER_HEADER_FOREGROUND="#F1C069"
70+
export GUM_FILTER_TEXT_FOREGROUND="#F1C069"
71+
export GUM_FILTER_CURSOR_TEXT_FOREGROUND="#F1C069"
72+
export GUM_FILTER_MATCH_FOREGROUND="#F1C069"
73+
export GUM_FILTER_PROMPT_FOREGROUND="#F1C069"
74+
}
75+
76+
function prompt_to_continue {
77+
echo ""
78+
echo "Press any key to continue..."
79+
read -n 1 -s -r keystroke
80+
echo "$keystroke Continuing..."
81+
clear
82+
}
83+
84+
function main_menu {
85+
gum style "🏠️ QGIS NixOS :: Main Menu"
86+
choice=$(
87+
gum choose \
88+
"🐚 Bash shell" \
89+
"🐠 Fish shell" \
90+
"📃 VSCode IDE" \
91+
"🎬️ Make history video" \
92+
"💡 About" \
93+
"🛑 Exit"
94+
)
95+
96+
case $choice in
97+
"🐚 Bash shell")
98+
echo "Dropping you to a bash shell, you can return to this menu at any time by typing:"
99+
echo ""
100+
echo "exit"
101+
echo ""
102+
dev-help
103+
/usr/bin/env bash
104+
main_menu
105+
;;
106+
"🐠 Fish shell")
107+
echo "Dropping you to a fish shell, you can return to this menu at any time by typing:"
108+
echo ""
109+
echo "exit"
110+
echo ""
111+
dev-help
112+
/usr/bin/env fish
113+
main_menu
114+
;;
115+
"📃 VSCode IDE")
116+
echo "Opening a VSCode session.:"
117+
echo ""
118+
119+
if [ -f REQUIREMENTS.txt ]; then
120+
if [ ! -d .venv ]; then
121+
python -m venv .venv
122+
fi
123+
.venv/bin/activate
124+
pip install --upgrade pip
125+
pip install -r REQUIREMENTS.txt
126+
fi
127+
./flake/vscode.sh &
128+
main_menu
129+
;;
130+
"🎬️ Make history video")
131+
echo "🎬️ Making a video of your history."
132+
gource --seconds-per-day 0.1 --time-scale 4 --auto-skip-seconds 1 \
133+
--key --file-idle-time 0 --max-files 0 --max-file-lag 0.1 \
134+
--title "Project History" --bloom-multiplier 0.5 --bloom-intensity 0.5 \
135+
--background 000000 --hide filenames,mouse,progress \
136+
--output-ppm-stream - \
137+
| ffmpeg -probesize 50M -analyzeduration 100M -y -r 60 -f image2pipe -vcodec ppm -i - \
138+
-vf scale=1280:-1 -vcodec libx264 -preset fast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 history.mp4
139+
# Convert to animated gif
140+
ffmpeg -i history.mp4 -vf "fps=10,scale=1280:-1:flags=lanczos" -loop 0 img/history.gif
141+
prompt_to_continue
142+
main_menu
143+
;;
144+
"💡 About")
145+
# Convert the image to ASCII and pass it directly to gum
146+
# Generate ASCII art
147+
chafa ./scripts/qgis-icon-128x128.png --size=10x10
148+
149+
# Display ASCII art and message using gum
150+
$(echo "$QGIS_ASCII")
151+
echo "QGIS System Administration scripts"
152+
echo "(c) QGIS.org, 2024, 2025"
153+
echo "Credits: Lova Andriarimalala, Ivan Mincik, Tim Sutton"
154+
prompt_to_continue
155+
main_menu
156+
;;
157+
"🛑 Exit")
158+
echo " Exiting, you can return to this menu at any time by typing:"
159+
echo ""
160+
echo "nix develop"
161+
prompt_to_continue
162+
exit 1
163+
;;
164+
*) echo "Invalid choice. Please select again." ;;
165+
esac
166+
}
167+
168+
setup_gum
169+
main_menu

scripts/start_qgis.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
echo "🪛 Running QGIS with the default profile:"
3+
echo "--------------------------------"
4+
5+
# This is the flake approach, using Ivan Mincis nix spatial project and a flake
6+
# see flake.nix for implementation details
7+
GEEST_LOG=${GEEST_LOG} \
8+
RUNNING_ON_LOCAL=1 \
9+
nix run .#default -- qgis --profile QGIS

scripts/start_qgis_ltr.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
echo "🪛 Running QGIS with the default profile:"
3+
echo "--------------------------------"
4+
5+
# This is the flake approach, using Ivan Mincis nix spatial project and a flake
6+
# see flake.nix for implementation details
7+
GEEST_LOG=${GEEST_LOG} \
8+
RUNNING_ON_LOCAL=1 \
9+
nix run .#qgis-ltr -- qgis --profile QGIS

0 commit comments

Comments
 (0)