mirror of
https://github.com/ryan4yin/nixos-and-flakes-book.git
synced 2025-08-19 00:45:58 +02:00
feat: minor updates
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
# Simplifying NixOS-Related Commands
|
||||
|
||||
To simplify NixOS-related commands, I utilize a Makefile, which proves to be very convenient. Alternatively, you can also use similar tools like [just](https://github.com/casey/just) and [cargo-make](https://github.com/sagiegurari/cargo-make) for this purpose. Here, I will provide my approach as a reference.
|
||||
To simplify NixOS-related commands, I utilize a Makefile, which proves to be very convenient.
|
||||
|
||||
Alternatively, you can also use similar tools like [just](https://github.com/casey/just) and [cargo-make](https://github.com/sagiegurari/cargo-make) for this purpose. Here, I will provide my approach as a reference.
|
||||
|
||||
Below is an example of how my Makefile looks:
|
||||
|
||||
>**NOTE**: The target names in the Makefile should not conflict with any file or directory names in the current directory. Otherwise, the targets will not execute.
|
||||
|
||||
```makefile
|
||||
#
|
||||
# NOTE: The target names in the Makefile should not conflict with any file or directory names in the current directory.
|
||||
# Otherwise, the targets will not execute.
|
||||
#
|
||||
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Nix commands related to the local machine
|
||||
@@ -57,17 +55,11 @@ ruby: add-idols-ssh-key
|
||||
ruby-debug: add-idols-ssh-key
|
||||
nixos-rebuild --flake .#ruby --target-host ruby --build-host ruby switch --use-remote-sudo --show-trace --verbose
|
||||
|
||||
kana: add-idols-ssh-key
|
||||
nixos-rebuild --flake .#kana --target-host kana --build-host kana switch --use-remote-sudo
|
||||
idols: aqua ruby
|
||||
|
||||
kana-debug: add-idols-ssh-key
|
||||
nixos-rebuild --flake .#kana --target-host kana --build-host kana switch --use-remote-sudo --show-trace --verbose
|
||||
|
||||
idols: aqua ruby kana
|
||||
|
||||
idols-debug: aqua-debug ruby-debug kana-debug
|
||||
idols-debug: aqua-debug ruby-debug
|
||||
```
|
||||
|
||||
Save the above Makefile to the root directory of your Nix flake. Then, you can use `make deploy` to deploy the configuration to your local machine and `make aqua` to deploy the configuration to all your remote servers.
|
||||
By Save the above Makefile to the root directory of your Nix flake. Then, I can use `make deploy` to deploy the configuration to my local machine, and `make idols` to deploy the configuration to all my remote servers.
|
||||
|
||||
This approach simplifies the execution of NixOS commands by abstracting them behind target names in the Makefile, providing a more user-friendly and convenient experience.
|
Reference in New Issue
Block a user