2022-10-15 22:10:18 +05:30
|
|
|
in_nix_shell := env_var_or_default("IN_NIX_SHELL", "false")
|
2022-10-01 12:13:38 +05:30
|
|
|
root_dir := justfile_directory()
|
2023-11-25 16:13:20 +05:30
|
|
|
hostname := `scutil --get LocalHostName`
|
2022-10-01 12:13:38 +05:30
|
|
|
|
|
|
|
# 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
|
2022-10-01 12:13:38 +05:30
|
|
|
nix-shell "{{ root_dir }}/shell.nix" --run "just \"{{ root_dir }}/{{ cmd }}\""
|
2022-10-15 22:10:18 +05:30
|
|
|
else
|
|
|
|
just "{{ root_dir }}/{{ cmd }}"
|
2022-10-01 12:13:38 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
_build:
|
2024-08-28 22:02:37 +05:30
|
|
|
nom build {{ root_dir }}#darwinConfigurations.{{ hostname }}.system
|
2022-10-01 12:13:38 +05:30
|
|
|
|
|
|
|
# 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 }}"
|
2022-10-01 12:13:38 +05:30
|
|
|
|
|
|
|
# switch to latest home-manager generation
|
2024-02-06 22:04:23 +05:30
|
|
|
switch: (_run "_switch") && _report-changes
|
2022-10-01 12:13:38 +05:30
|
|
|
|
2024-08-31 10:51:38 +05:30
|
|
|
_update-vscode-extensions:
|
|
|
|
$NIXPKGS_PATH/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh > \
|
2023-11-25 16:13:20 +05:30
|
|
|
{{ root_dir }}/programs/vscode/extensions.nix
|
2022-10-01 12:13:38 +05:30
|
|
|
|
2024-08-31 10:51:38 +05:30
|
|
|
_update: && _update-vscode-extensions _switch _brew-update _report-changes
|
|
|
|
nix flake update --commit-lock-file --flake {{ root_dir }}
|
|
|
|
|
2024-01-31 16:00:03 +05:30
|
|
|
_brew-update:
|
|
|
|
brew update
|
|
|
|
brew upgrade
|
|
|
|
mas upgrade
|
|
|
|
|
2024-02-06 22:04:23 +05:30
|
|
|
_report-changes:
|
|
|
|
#!/bin/bash
|
|
|
|
if [ $(ls -d1v /nix/var/nix/profiles/system-*-link 2>/dev/null | wc -l) -lt 2 ]; then
|
|
|
|
echo "Skipping changes report..."
|
|
|
|
else
|
|
|
|
nvd diff $(/bin/ls -d1v /nix/var/nix/profiles/system-*-link | tail -2)
|
|
|
|
fi
|
|
|
|
|
2022-10-01 12:13:38 +05:30
|
|
|
# update packages and switch
|
|
|
|
update: (_run "_update")
|
|
|
|
|
|
|
|
# clean up nix garbage
|
2024-02-06 22:04:23 +05:30
|
|
|
clean days="7":
|
|
|
|
home-manager expire-generations "-{{days}} days"
|
2024-09-13 14:50:53 +05:30
|
|
|
nix profile wipe-history --older-than "{{days}}d"
|
2024-02-06 22:04:23 +05:30
|
|
|
sudo nix-collect-garbage -d --delete-older-than {{days}}d
|
|
|
|
brew cleanup --prune {{days}}
|