mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-01 15:13:09 +02:00
feat: replace Makefile with Justfile
This commit is contained in:
166
Justfile
Normal file
166
Justfile
Normal file
@@ -0,0 +1,166 @@
|
||||
# just is a command runner, Justfile is very similar to Makefile, but simpler.
|
||||
|
||||
# use nushell for shell commands
|
||||
set shell := ["nu", "-c"]
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Nix commands related to the local machine
|
||||
#
|
||||
############################################################################
|
||||
|
||||
nixos-switch := "nixos-rebuild switch --use-remote-sudo --flake"
|
||||
debug-args := "--show-trace --verbose"
|
||||
|
||||
i3:
|
||||
{{nixos-switch}} .#ai_i3
|
||||
|
||||
hypr:
|
||||
{{nixos-switch}} .#ai_hyprland
|
||||
|
||||
s-i3:
|
||||
{{nixos-switch}} .#shoukei_i3
|
||||
|
||||
s-hypr:
|
||||
{{nixos-switch}} .#shoukei_hyprland
|
||||
|
||||
i3-debug:
|
||||
{{nixos-switch}} .#ai_i3 {{debug-args}}
|
||||
|
||||
hypr-debug:
|
||||
{{nixos-switch}} .#ai_hyprland {{debug-args}}
|
||||
|
||||
up:
|
||||
nix flake update
|
||||
|
||||
# Update specific input
|
||||
# Usage: just upp nixpkgs
|
||||
upp input:
|
||||
nix flake lock --update-input {{input}}
|
||||
|
||||
history:
|
||||
nix profile history --profile /nix/var/nix/profiles/system
|
||||
|
||||
repl:
|
||||
nix repl -f flake:nixpkgs
|
||||
|
||||
clean:
|
||||
# remove all generations older than 7 days
|
||||
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d
|
||||
|
||||
gc:
|
||||
# garbage collect all unused nix store entries
|
||||
sudo nix store gc --debug
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Darwin related commands, harmonica is my macbook pro's hostname
|
||||
#
|
||||
############################################################################
|
||||
|
||||
darwin-prefix := "./result/sw/bin/darwin-rebuild"
|
||||
darwin-switch := "{{darwin-prefix}} switch --flake"
|
||||
|
||||
darwin-set-proxy:
|
||||
sudo python3 scripts/darwin_set_proxy.py
|
||||
sleep 1
|
||||
|
||||
darwin-rollback:
|
||||
{{darwin-prefix}} rollback
|
||||
|
||||
ha: darwin-set-proxy
|
||||
nix build .#darwinConfigurations.harmonica.system
|
||||
{{darwin-switch}} .#harmonica
|
||||
|
||||
ha-debug: darwin-set-proxy
|
||||
nom build .#darwinConfigurations.harmonica.system {{debug-args}}
|
||||
{{darwin-switch}} .#harmonica {{debug-args}}
|
||||
|
||||
fe: darwin-set-proxy
|
||||
nix build .#darwinConfigurations.fern.system
|
||||
{{darwin-switch}} .#fern
|
||||
|
||||
fe-debug: darwin-set-proxy
|
||||
nom build .#darwinConfigurations.fern.system {{debug-args}}
|
||||
{{darwin-switch}} .#fern {{debug-args}}
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Idols, Commands related to my remote distributed building cluster
|
||||
#
|
||||
############################################################################
|
||||
|
||||
idols-ssh-key:
|
||||
ssh-add ~/.ssh/ai-idols
|
||||
|
||||
idols: idols-ssh-key
|
||||
colmena apply --on '@dist-build'
|
||||
|
||||
aqua:
|
||||
colmena apply --on '@aqua'
|
||||
|
||||
ruby:
|
||||
colmena apply --on '@ruby'
|
||||
|
||||
kana:
|
||||
colmena apply --on '@kana'
|
||||
|
||||
idols-debug: idols-ssh-key
|
||||
colmena apply --on '@dist-build' --verbose --show-trace
|
||||
|
||||
# only used once to setup the virtual machines
|
||||
idols-image:
|
||||
# take image for idols, and upload the image to proxmox nodes.
|
||||
nom build .#aquamarine
|
||||
scp result root@gtr5:/var/lib/vz/dump/vzdump-qemu-aquamarine.vma.zst
|
||||
|
||||
nom build .#ruby
|
||||
scp result root@s500plus:/var/lib/vz/dump/vzdump-qemu-ruby.vma.zst
|
||||
|
||||
nom build .#kana
|
||||
scp result root@um560:/var/lib/vz/dump/vzdump-qemu-kana.vma.zst
|
||||
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# RISC-V related commands
|
||||
#
|
||||
############################################################################
|
||||
|
||||
roll: idols-ssh-key
|
||||
colmena apply --on '@riscv'
|
||||
|
||||
roll-debug: idols-ssh-key
|
||||
colmena apply --on '@dist-build' --verbose --show-trace
|
||||
|
||||
nozomi:
|
||||
colmena apply --on '@nozomi'
|
||||
|
||||
yukina:
|
||||
colmena apply --on '@yukina'
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Aarch64 related commands
|
||||
#
|
||||
############################################################################
|
||||
|
||||
aarch:
|
||||
colmena apply --on '@aarch'
|
||||
|
||||
suzu:
|
||||
colmena apply --on '@suzu'
|
||||
|
||||
suzu-debug:
|
||||
colmena apply --on '@suzu' --verbose --show-trace
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Misc, other useful commands
|
||||
#
|
||||
############################################################################
|
||||
|
||||
fmt:
|
||||
# format the nix files in this repo
|
||||
nix fmt
|
||||
|
||||
161
Makefile
161
Makefile
@@ -1,161 +0,0 @@
|
||||
#
|
||||
# NOTE: Makefile's target name should not be the same as one of the file or directory in the current directory,
|
||||
# otherwise the target will not be executed!
|
||||
#
|
||||
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Nix commands related to the local machine
|
||||
#
|
||||
############################################################################
|
||||
|
||||
i3:
|
||||
nixos-rebuild switch --flake .#ai_i3 --use-remote-sudo
|
||||
|
||||
s-i3:
|
||||
nixos-rebuild switch --flake .#shoukei_i3 --use-remote-sudo
|
||||
|
||||
hypr:
|
||||
nixos-rebuild switch --flake .#ai_hyprland --use-remote-sudo
|
||||
|
||||
s-hypr:
|
||||
nixos-rebuild switch --flake .#shoukei_hyprland --use-remote-sudo
|
||||
|
||||
i3-debug:
|
||||
nixos-rebuild switch --flake .#ai_i3 --use-remote-sudo --show-trace --verbose
|
||||
|
||||
hypr-debug:
|
||||
nixos-rebuild switch --flake .#ai_hyprland --use-remote-sudo --show-trace --verbose
|
||||
|
||||
up:
|
||||
nix flake update
|
||||
|
||||
# Update specific input
|
||||
# usage: make upp i=wallpapers
|
||||
upp:
|
||||
nix flake lock --update-input $(i)
|
||||
|
||||
history:
|
||||
nix profile history --profile /nix/var/nix/profiles/system
|
||||
|
||||
repl:
|
||||
nix repl -f flake:nixpkgs
|
||||
|
||||
gc:
|
||||
# remove all generations older than 7 days
|
||||
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d
|
||||
|
||||
# garbage collect all unused nix store entries
|
||||
# sudo nix store gc --debug
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Darwin related commands, harmonica is my macbook pro's hostname
|
||||
#
|
||||
############################################################################
|
||||
|
||||
darwin-set-proxy:
|
||||
sudo python3 scripts/darwin_set_proxy.py
|
||||
sleep 1
|
||||
|
||||
darwin-rollback:
|
||||
./result/sw/bin/darwin-rebuild rollback
|
||||
|
||||
ha: darwin-set-proxy
|
||||
nix build .#darwinConfigurations.harmonica.system
|
||||
./result/sw/bin/darwin-rebuild switch --flake .#harmonica
|
||||
|
||||
ha-debug: darwin-set-proxy
|
||||
nom build .#darwinConfigurations.harmonica.system --show-trace --verbose
|
||||
./result/sw/bin/darwin-rebuild switch --flake .#harmonica --show-trace --verbose
|
||||
|
||||
fe: darwin-set-proxy
|
||||
nix build .#darwinConfigurations.fern.system
|
||||
./result/sw/bin/darwin-rebuild switch --flake .#fern
|
||||
|
||||
fe-debug: darwin-set-proxy
|
||||
nom build .#darwinConfigurations.fern.system --show-trace --verbose
|
||||
./result/sw/bin/darwin-rebuild switch --flake .#fern --show-trace --verbose
|
||||
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Idols, Commands related to my remote distributed building cluster
|
||||
#
|
||||
############################################################################
|
||||
|
||||
add-idols-ssh-key:
|
||||
ssh-add ~/.ssh/ai-idols
|
||||
|
||||
idols: add-idols-ssh-key
|
||||
colmena apply --on '@dist-build'
|
||||
|
||||
aqua:
|
||||
colmena apply --on '@aqua'
|
||||
|
||||
ruby:
|
||||
colmena apply --on '@ruby'
|
||||
|
||||
kana:
|
||||
colmena apply --on '@kana'
|
||||
|
||||
idols-debug: add-idols-ssh-key
|
||||
colmena apply --on '@dist-build' --verbose --show-trace
|
||||
|
||||
# only used once to setup the virtual machines
|
||||
idols-image:
|
||||
# take image for idols, and upload the image to proxmox nodes.
|
||||
nom build .#aquamarine
|
||||
scp result root@gtr5:/var/lib/vz/dump/vzdump-qemu-aquamarine.vma.zst
|
||||
|
||||
nom build .#ruby
|
||||
scp result root@s500plus:/var/lib/vz/dump/vzdump-qemu-ruby.vma.zst
|
||||
|
||||
nom build .#kana
|
||||
scp result root@um560:/var/lib/vz/dump/vzdump-qemu-kana.vma.zst
|
||||
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# RISC-V related commands
|
||||
#
|
||||
############################################################################
|
||||
|
||||
roll: add-idols-ssh-key
|
||||
colmena apply --on '@riscv'
|
||||
|
||||
roll-debug: add-idols-ssh-key
|
||||
colmena apply --on '@dist-build' --verbose --show-trace
|
||||
|
||||
nozomi:
|
||||
colmena apply --on '@nozomi'
|
||||
|
||||
yukina:
|
||||
colmena apply --on '@yukina'
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Aarch64 related commands
|
||||
#
|
||||
############################################################################
|
||||
|
||||
aarch:
|
||||
colmena apply --on '@aarch'
|
||||
|
||||
suzu:
|
||||
colmena apply --on '@suzu'
|
||||
|
||||
suzu-debug:
|
||||
colmena apply --on '@suzu' --verbose --show-trace
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Misc, other useful commands
|
||||
#
|
||||
############################################################################
|
||||
|
||||
fmt:
|
||||
# format the nix files in this repo
|
||||
nix fmt
|
||||
|
||||
20
README.md
20
README.md
@@ -18,7 +18,7 @@ This repository is home to the nix code that builds my systems.
|
||||
|
||||
## Why NixOS & Flakes?
|
||||
|
||||
Nix allows for easy-to-manage, collaborative, reproducible deployments. This means that once something is setup and configured once, it works (almost) forever. If someone else shares their configuration, anyone can make use of it(if you really understand what you're copying/refering now).
|
||||
Nix allows for easy-to-manage, collaborative, reproducible deployments. This means that once something is setup and configured once, it works (almost) forever. If someone else shares their configuration, anyone can just use of it(if you really understand what you're copying/refering now).
|
||||
|
||||
As for Flakes, refer to [Introduction to Flakes - NixOS & Nix Flakes Book](https://nixos-and-flakes.thiscute.world/nixos-with-flakes/introduction-to-flakes)
|
||||
|
||||
@@ -92,27 +92,27 @@ For NixOS:
|
||||
sudo nixos-rebuild switch --flake .#ai_i3
|
||||
# sudo nixos-rebuild switch --flake .#ai_hyprland
|
||||
|
||||
# we can also deploy using `make`, which is defined in Makefile
|
||||
make i3 # deploy my pc with i3 window manager
|
||||
# make hypr # deploy my pc with hyprland compositor
|
||||
# deploy via `just`(a command runner with similar syntax to make) & Justfile
|
||||
just i3 # deploy my pc with i3 window manager
|
||||
# just hypr # deploy my pc with hyprland compositor
|
||||
|
||||
# or we can deploy with details
|
||||
make i3-debug
|
||||
# make hypr-debug
|
||||
just i3-debug
|
||||
# just hypr-debug
|
||||
```
|
||||
|
||||
For macOS:
|
||||
|
||||
```bash
|
||||
# deploy harmonicia's configuration(macOS Intel)
|
||||
make ha
|
||||
just ha
|
||||
|
||||
# deploy fern's configuration(Apple Silicon)
|
||||
make fe
|
||||
just fe
|
||||
|
||||
# deploy with details
|
||||
make ha-debug
|
||||
# make fe
|
||||
just ha-debug
|
||||
# just fe
|
||||
```
|
||||
|
||||
> [What y'all will need when Nix drives you to drink.](https://www.youtube.com/watch?v=Eni9PPPPBpg) (copy from hlissner's dotfiles, it really matches my feelings when I first started using NixOS...)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [
|
||||
neofetch
|
||||
ranger # terminal file manager(batteries included, with image preview support)
|
||||
|
||||
# archives
|
||||
zip
|
||||
@@ -23,6 +22,8 @@
|
||||
# Docs: https://github.com/learnbyexample/Command-line-text-processing
|
||||
gnugrep # GNU grep, provides `grep`/`egrep`/`fgrep`
|
||||
gnused # GNU sed, very powerful(mainly for replacing text in files)
|
||||
gnumake
|
||||
just # a command runner like make, but simpler
|
||||
gawk # GNU awk, a pattern scanning and processing language
|
||||
(ripgrep.override {withPCRE2 = true;}) # recursively searches directories for a regex pattern
|
||||
sad # CLI search and replace, with diff preview, really useful!!!
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
git
|
||||
gnumake
|
||||
wget
|
||||
just # a command runner(replacement of gnumake in some cases)
|
||||
curl
|
||||
nix-output-monitor
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user