Skip to content

Commit

Permalink
chore(just): clean up justfile and add build-commands
Browse files Browse the repository at this point in the history
Signed-off-by: Flokkq <[email protected]>
  • Loading branch information
Flokkq committed Jan 2, 2025
1 parent fb69bbf commit 9f1d512
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 142 deletions.
151 changes: 9 additions & 142 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ set shell := ["nu", "-c"]
default:
@just --list

# Run eval tests
[group('nix')]
test:
nix eval .#evalTests --show-trace --print-build-logs --verbose

# Update all the flake inputs
[group('nix')]
up:
Expand All @@ -32,151 +27,23 @@ up:
upp input:
nix flake update {{input}}

# List all generations of the system profile
[group('nix')]
history:
nix profile history --profile /nix/var/nix/profiles/system

# Open a nix shell with the flake
[group('nix')]
repl:
nix repl -f flake:nixpkgs

# remove all generations older than 7 days
# on darwin, you may need to switch to root user to run this command
[group('nix')]
clean:
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d

# Garbage collect all unused nix store entries
[group('nix')]
gc:
# garbage collect all unused nix store entries(system-wide)
sudo nix-collect-garbage --delete-older-than 7d
# garbage collect all unused nix store entries(for the user - home-manager)
# https://github.com/NixOS/nix/issues/8508
nix-collect-garbage --delete-older-than 7d

# Enter a shell session which has all the necessary tools for this flake
[linux]
[group('nix')]
shell:
nix shell nixpkgs#git nixpkgs#neovim nixpkgs#colmena

# Enter a shell session which has all the necessary tools for this flake
[macos]
[group('nix')]
shell:
nix shell nixpkgs#git nixpkgs#neovim

[group('nix')]
fmt:
# format the nix files in this repo
nix fmt

# Show all the auto gc roots in the nix store
[group('nix')]
gcroot:
ls -al /nix/var/nix/gcroots/auto/

############################################################################
#
# NixOS Desktop related commands
# Build Commands
#
############################################################################

[linux]
[group('desktop')]
hypr mode="default":
#!/usr/bin/env nu
use {{utils_nu}} *;
nixos-switch ai-hyprland {{mode}}

[linux]
[group('desktop')]
s-hypr mode="default":
#!/usr/bin/env nu
use {{utils_nu}} *;
nixos-switch shoukei-hyprland {{mode}}

############################################################################
#
# Darwin related commands
#
############################################################################

[macos]
[group('desktop')]
darwin-set-proxy:
sudo python3 scripts/darwin_set_proxy.py
sleep 1sec

[macos]
[group('desktop')]
darwin-rollback:
#!/usr/bin/env nu
use {{utils_nu}} *;
darwin-rollback

# Reload yabai and skhd(macOS)
[macos]
[group('desktop')]
yabai-reload:
launchctl kickstart -k "gui/502/org.nixos.yabai";
launchctl kickstart -k "gui/502/org.nixos.skhd";

############################################################################
#
# Neovim related commands
#
############################################################################

[group('neovim')]
nvim-test:
rm -rf $"($env.HOME)/.config/nvim"
rsync -avz --copy-links --chmod=D2755,F744 home/base/tui/editors/neovim/nvim/ $"($env.HOME)/.config/nvim/"

[group('neovim')]
nvim-clean:
rm -rf $"($env.HOME)/.config/nvim"

# =================================================
#
# Other useful commands
#
# =================================================

[group('common')]
path:
$env.PATH | split row ":"

[linux]
[group('common')]
penvof pid:
sudo cat $"/proc/($pid)/environ" | tr '\0' '\n'

# Remove all reflog entries and prune unreachable objects
[group('git')]
ggc:
git reflog expire --expire-unreachable=now --all
git gc --prune=now

# Amend the last commit without changing the commit message
[group('git')]
game:
git commit --amend -a --no-edit

# Delete all failed pods
[group('k8s')]
del-failed:
kubectl delete pod --all-namespaces --field-selector="status.phase==Failed"

[linux]
[group('services')]
list-inactive:
systemctl list-units -all --state=inactive
# Build a bootable SD card image for Raspberry Pi
[group('build')]
build-pi:
nix --experimental-features 'nix-command flakes' build './boot/#nixosConfigurations.pi.config.system.build.sdImage'

[linux]
[group('services')]
list-failed:
systemctl list-units -all --state=failed
# Build a bootable raw-efi image for Linux servers
[group('build')]
build-linux:
nix --experimental-features 'nix-command flakes' build './boot/#diskImage'
2 changes: 2 additions & 0 deletions boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Generate bootable images straight to the disk.
- [Post Image-Build](#post-image-build)
- [Todo](#todo)

> [!NOTE]
> **Pro Tipp**: When working in this repository use `just` to run the build commands. This allows to skip the `build` section
## Raspberry Pi 5

Expand Down

0 comments on commit 9f1d512

Please sign in to comment.