Skip to content

Commit

Permalink
feat: command-not-found hook
Browse files Browse the repository at this point in the history
Automatically install packages from the `command_not_found_handler` zsh hook.
  • Loading branch information
raphaelcoeffic committed Dec 22, 2024
1 parent 795b4ac commit 5de8d51
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 93 deletions.
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/target
/base
/ofs
nix
image_builder/base.tar.xz
base.tar.xz
base.sha256
/nix
base.*
src/assets/programs.*
51 changes: 31 additions & 20 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ anstream = { version = "0.6.18", default-features = false, features = ["auto"] }
anyhow = "1.0.93"
base64 = "0.22.1"
clap = { version = "4.5.21", features = ["derive", "env"] }
console = "0.15.10"
csv = "1.3.1"
dirs = "5.0"
env_logger = "0.11.5"
exitcode = "1.1.2"
Expand Down
48 changes: 36 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,52 @@ endif

cargo_build = cargo build --profile $(cargo_profile) --target $(cargo_target)

.PHONY: clean dist-clean base-image pkg-bin $(pkg_bin)
# programs index
nix_channel ?= unstable
nix_channels_url = https://nixos.org/channels/nixos-$(nix_channel)
dl_prog_index = curl -sL -o - $(nix_channels_url)/nixexprs.tar.xz

assets = src/assets
prog_index_sqlite = $(assets)/programs.sqlite
unpack_prog_index = tar xJ -C $(assets) --strip-components=1 --wildcards '*/programs.sqlite'

prog_index_csv = src/assets/programs.csv

.PHONY: clean dist-clean clean-assets base-image pkg-bin $(pkg_bin)

base_files = base.sha256 base.tar base.tar.xz

clean:
@echo "Removing base files"
@echo "* Removing base files"
@rm -f $(base_files)
@echo "Removing nix directory"
@echo "* Removing nix directory"
@chmod -R +w nix/* 2>/dev/null ; rm -rf ./nix

dist-clean: clean
@echo "Removing rust builds"
dist-clean: clean clean-assets
@echo "* Removing rust builds"
@rm -rf target

clean-assets:
@echo "* Removing assets"
@rm -rf $(assets)

base-image: pkg-bin
@echo "Building base image"
$(build_img) $(build_img_args)
@echo "* Building base image"
@$(build_img) $(build_img_args)

pkg-bin: $(pkg_bin)

$(pkg_bin):
@echo "Building pkg tool"
$(cargo_build) --bin pkg
@echo "Stripping debug info"
strip $@
$(pkg_bin): $(prog_index_csv)
@echo "* Building pkg tool"
@$(cargo_build) --bin pkg
@echo "* Stripping debug info"
@strip $@

$(prog_index_sqlite):
@echo "* Downloading $@"
@mkdir -p $(assets)
@$(dl_prog_index) | $(unpack_prog_index)

$(prog_index_csv): $(prog_index_sqlite)
@echo "* Converting $< to $@"
@./tools/convert-program-index.sh $(prog_index_sqlite) $(build_arch) > $@
Loading

0 comments on commit 5de8d51

Please sign in to comment.