nix-managed-macbook/justfile

51 lines
1.3 KiB
Makefile
Raw Normal View History

2022-10-15 22:10:18 +05:30
in_nix_shell := env_var_or_default("IN_NIX_SHELL", "false")
root_dir := justfile_directory()
2023-11-25 16:13:20 +05:30
hostname := `scutil --get LocalHostName`
# choose a just command to run
default:
@just --choose
# show available just commands
help:
@just --list --unsorted --list-heading $'Available commands:\n'
_run cmd:
#!/usr/bin/env -S sh -eu
2022-10-15 22:10:18 +05:30
if [ "{{ in_nix_shell }}" = "false" ]; then
nix-shell "{{ root_dir }}/shell.nix" --run "just \"{{ root_dir }}/{{ cmd }}\""
2022-10-15 22:10:18 +05:30
else
just "{{ root_dir }}/{{ cmd }}"
fi
_build:
2023-11-25 16:13:20 +05:30
nix build {{ root_dir }}#darwinConfigurations.{{ hostname }}.system
# build latest home-manager generation
build: (_run "_build")
2023-11-25 16:13:20 +05:30
_switch: _build
./result/sw/bin/darwin-rebuild -v switch --flake "{{ root_dir }}"
# switch to latest home-manager generation
switch: (_run "_switch")
2024-01-31 16:00:03 +05:30
_update: && _switch _brew-update
nix flake update --commit-lock-file "{{ root_dir }}"
2023-11-25 16:13:20 +05:30
$NIXPKGS_PATH/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh > \
{{ root_dir }}/programs/vscode/extensions.nix
2024-01-31 16:00:03 +05:30
_brew-update:
brew update
brew upgrade
mas upgrade
# update packages and switch
update: (_run "_update")
# clean up nix garbage
clean:
2023-08-27 11:40:27 +05:30
home-manager expire-generations "-7 days"
2024-01-31 16:00:03 +05:30
sudo nix-collect-garbage -d --delete-older-than 7d
brew cleanup --prune 7