nix-managed-macbook/justfile
Abhinav Sarkar 3860b368d2 flake.lock: Update
Flake lock file updates:

• Updated input 'home-manager':
    'github:nix-community/home-manager/0f5908daf890c3d7e7052bef1d6deb0f2710aaa1' (2025-04-04)
  → 'github:nix-community/home-manager/e43c6bcb101ba3301522439c459288c4a248f624' (2025-04-11)
• Updated input 'nix-darwin':
    'github:LnL7/nix-darwin/73d59580d01e9b9f957ba749f336a272869c42dd' (2025-04-01)
  → 'github:LnL7/nix-darwin/113883e37d985d26ecb65282766e5719f2539103' (2025-04-09)
• Updated input 'nix-index-database':
    'github:nix-community/nix-index-database/b3696bfb6c24aa61428839a99e8b40c53ac3a82d' (2025-03-30)
  → 'github:nix-community/nix-index-database/a36f6a7148aec2c77d78e4466215cceb2f5f4bfb' (2025-04-06)
• Updated input 'nix-vscode-extensions':
    'github:nix-community/nix-vscode-extensions/2a7a2b80740dd1dbb8b4e1d5b2ae6ad9b7fbd5e3' (2025-04-05)
  → 'github:nix-community/nix-vscode-extensions/f0555ec37883d2bddca658cad7bfe995bc195217' (2025-04-11)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/2bfc080955153be0be56724be6fa5477b4eefabb' (2025-04-03)
  → 'github:nixos/nixpkgs/d19cf9dfc633816a437204555afeb9e722386b76' (2025-04-10)
• Updated input 'nixpkgs-stable':
    'github:nixos/nixpkgs/5051ae6744b993fcfab221e8bd38f8bc26f88393' (2025-04-02)
  → 'github:nixos/nixpkgs/cd4d63bf9485ba66a1f5d036118b053289b153e4' (2025-04-10)
2025-04-11 22:20:25 +05:30

58 lines
1.5 KiB
Makefile

in_nix_shell := env_var_or_default("IN_NIX_SHELL", "false")
root_dir := justfile_directory()
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
if [ "{{ in_nix_shell }}" = "false" ]; then
nix-shell "{{ root_dir }}/shell.nix" --run "just \"{{ root_dir }}/{{ cmd }}\""
else
just "{{ root_dir }}/{{ cmd }}"
fi
_build:
nom build --show-trace {{ root_dir }}#darwinConfigurations.{{ hostname }}.system
# build nix-darwin system
build: (_run "_build")
_switch: _build
./result/sw/bin/darwin-rebuild -v switch --flake "{{ root_dir }}"
# build nix-darwin system and switch to it
switch: (_run "_switch") && _report-changes
_update: && _switch _brew-update _report-changes
nix flake update --commit-lock-file --flake {{ root_dir }}
_brew-update:
brew update
brew upgrade
mas upgrade
_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
# update packages and switch
update: (_run "_update")
# clean up garbage
clean days="7":
home-manager expire-generations "-{{days}} days"
nix profile wipe-history --older-than "{{days}}d"
sudo nix-collect-garbage -d --delete-older-than {{days}}d
brew cleanup --prune {{days}}