mirror of
https://github.com/0x1d/nix.git
synced 2025-12-14 14:01:29 +01:00
refactor ctl.sh
This commit is contained in:
22
README.md
22
README.md
@@ -9,20 +9,24 @@ Run `ctl.sh` to see the list of commands to manage the system.
|
||||
```bash
|
||||
./ctl.sh
|
||||
|
||||
~> OS
|
||||
Usage: ctl.sh <command> <subcommand>
|
||||
|
||||
os-test Rebuild and test OS without creating a new generation
|
||||
os-rebuild Rebuild OS and create new generation
|
||||
os-upgrade Upgrade channels and rebuild OS
|
||||
~> os
|
||||
|
||||
test Rebuild and test OS without new generation
|
||||
rebuild Rebuild OS and create new generation
|
||||
upgrade Upgrade channels and rebuild OS
|
||||
changes Show changes between generations
|
||||
gc Garbage collect old generations
|
||||
vm Build and run as VM
|
||||
|
||||
~> Store
|
||||
~> store
|
||||
|
||||
store-gc Collecting garbage in nix-store
|
||||
store-optimise Optimise nix-store
|
||||
gc Collecting garbage in nix-store
|
||||
optimise Optimise nix-store
|
||||
search PACKAGE Search for package
|
||||
|
||||
~> Shell
|
||||
~> shell
|
||||
|
||||
shell NAME Run a nix-shell from ./shell/
|
||||
run NAME Run a nix-shell from ./shell/
|
||||
```
|
||||
|
||||
67
ctl.sh
67
ctl.sh
@@ -1,8 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##
|
||||
## ~> OS
|
||||
##Usage: ctl.sh <command> <subcommand>
|
||||
##
|
||||
## ~> os
|
||||
##
|
||||
## test Rebuild and test OS without new generation
|
||||
## rebuild Rebuild OS and create new generation
|
||||
## upgrade Upgrade channels and rebuild OS
|
||||
## changes Show changes between generations
|
||||
## gc Garbage collect old generations
|
||||
## vm Build and run as VM
|
||||
##
|
||||
## ~> store
|
||||
##
|
||||
## gc Collecting garbage in nix-store
|
||||
## optimise Optimise nix-store
|
||||
## search PACKAGE Search for package
|
||||
##
|
||||
## ~> shell
|
||||
##
|
||||
## run NAME Run a nix-shell from ./shell/
|
||||
|
||||
function info {
|
||||
clear
|
||||
@@ -11,58 +29,53 @@ function info {
|
||||
sed -n 's/^##//p' ctl.sh
|
||||
}
|
||||
|
||||
## os-test Rebuild and test OS without creating a new generation
|
||||
function os-test {
|
||||
function os {
|
||||
function test {
|
||||
sudo nixos-rebuild --flake ./os#nixos test
|
||||
}
|
||||
|
||||
## os-rebuild Rebuild OS and create new generation
|
||||
function os-rebuild {
|
||||
function rebuild {
|
||||
echo "Rebuild OS"
|
||||
sudo nixos-rebuild --flake ./os#nixos switch
|
||||
}
|
||||
|
||||
## os-upgrade Upgrade channels and rebuild OS
|
||||
function os-upgrade {
|
||||
function upgrade {
|
||||
echo "Upgrade channels and rebuild OS"
|
||||
sudo nixos-rebuild --upgrade --flake ./os#nixos switch
|
||||
}
|
||||
|
||||
## vm Build and run as VM
|
||||
function changes {
|
||||
nix profile diff-closures --profile /nix/var/nix/profiles/system
|
||||
}
|
||||
function gc {
|
||||
sudo nix-collect-garbage -d
|
||||
sudo nixos-rebuild switch
|
||||
}
|
||||
function vm {
|
||||
echo "Build and run configuration as VM"
|
||||
rm *.qcow2
|
||||
nixos-rebuild build-vm --flake ./os#nixos && result/bin/run-*-vm
|
||||
}
|
||||
${@}
|
||||
}
|
||||
|
||||
##
|
||||
## ~> Store
|
||||
##
|
||||
|
||||
## store-gc Collecting garbage in nix-store
|
||||
function store-gc {
|
||||
function store {
|
||||
function gc {
|
||||
echo "Collecting garbage"
|
||||
nix-store --gc --print-roots | egrep -v "^(/nix/var|/run/\w+-system|\{memory|/proc)"
|
||||
}
|
||||
|
||||
## store-optimise Optimise nix-store
|
||||
function store-optimise {
|
||||
function optimise {
|
||||
echo "Optimizing nix-store. This may take a moment..."
|
||||
nix-store --optimise
|
||||
}
|
||||
|
||||
## search PACKAGE Search for package
|
||||
function search {
|
||||
nix search nixpkgs $1
|
||||
}
|
||||
${@}
|
||||
}
|
||||
|
||||
##
|
||||
## ~> Shell
|
||||
##
|
||||
|
||||
## shell NAME Run a nix-shell from ./shell/
|
||||
function shell {
|
||||
function run {
|
||||
nix-shell ./shell/$1.nix
|
||||
}
|
||||
${@}
|
||||
}
|
||||
|
||||
${@:-info}
|
||||
|
||||
Reference in New Issue
Block a user