mirror of
https://github.com/RGBCube/ncc
synced 2025-07-30 19:47:47 +00:00
Rewrite rebuild script in Nu
This commit is contained in:
parent
95d330492f
commit
0f0e233ba4
4 changed files with 115 additions and 18 deletions
14
README.md
14
README.md
|
@ -13,7 +13,7 @@ Here is the script you need to run to get this working:
|
||||||
```sh
|
```sh
|
||||||
nix-shell -p git --command "git clone https://github.com/RGBCube/NixOSConfiguration && cd NixOSConfiguration"
|
nix-shell -p git --command "git clone https://github.com/RGBCube/NixOSConfiguration && cd NixOSConfiguration"
|
||||||
|
|
||||||
./rebuild.sh
|
nix-shell -p nu --command "nu rebuild.nu"
|
||||||
```
|
```
|
||||||
|
|
||||||
`machine-name` is a machine selected from the machines in the `machines` directory.
|
`machine-name` is a machine selected from the machines in the `machines` directory.
|
||||||
|
@ -24,7 +24,7 @@ Lets say you have changed the configuration and want to apply the changes
|
||||||
to your system. You would have to run the rebuild script:
|
to your system. You would have to run the rebuild script:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./rebuild.sh
|
./rebuild.nu
|
||||||
```
|
```
|
||||||
|
|
||||||
This runs the script interactively.
|
This runs the script interactively.
|
||||||
|
@ -38,7 +38,15 @@ You can also check how the script is used:
|
||||||
This outputs:
|
This outputs:
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage: ./rebuild.sh [-h | --help] [machine-name]
|
Usage:
|
||||||
|
> rebuild.nu (machine) ...(arguments)
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
-h, --help - Display the help message for this command
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
machine <string>: The machine to build. (optional, default: '')
|
||||||
|
...arguments <any>: Extra arguments to pass to nixos-rebuild.
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
74
flake.lock
generated
74
flake.lock
generated
|
@ -21,6 +21,24 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1698579227,
|
||||||
|
"narHash": "sha256-KVWjFZky+gRuWennKsbo6cWyo7c/z/VgCte5pR9pEKg=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "f76e870d64779109e41370848074ac4eaa1606ec",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"home-manager": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
@ -88,6 +106,43 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nh": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nix-filter": "nix-filter",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1698826948,
|
||||||
|
"narHash": "sha256-Th05oofIIhsN2bmJNsb0Xev3+RJgtk8stjHZX9EdWA0=",
|
||||||
|
"owner": "viperML",
|
||||||
|
"repo": "nh",
|
||||||
|
"rev": "23d21975231d569afbe3973eb19d955c650f8f08",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "viperML",
|
||||||
|
"repo": "nh",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nix-filter": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1694857738,
|
||||||
|
"narHash": "sha256-bxxNyLHjhu0N8T3REINXQ2ZkJco0ABFPn6PIe2QUfqo=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "nix-filter",
|
||||||
|
"rev": "41fd48e00c22b4ced525af521ead8792402de0ea",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "nix-filter",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1698134075,
|
"lastModified": 1698134075,
|
||||||
|
@ -104,6 +159,24 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "lib",
|
||||||
|
"lastModified": 1696019113,
|
||||||
|
"narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "lib",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699099776,
|
"lastModified": 1699099776,
|
||||||
|
@ -125,6 +198,7 @@
|
||||||
"fenix": "fenix",
|
"fenix": "fenix",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"hyprland": "hyprland",
|
"hyprland": "hyprland",
|
||||||
|
"nh": "nh",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
30
rebuild.nu
Executable file
30
rebuild.nu
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
|
def main [
|
||||||
|
machine: string = "" # The machine to build.
|
||||||
|
...arguments # Extra arguments to pass to nixos-rebuild.
|
||||||
|
] {
|
||||||
|
mut machine_ = $machine
|
||||||
|
|
||||||
|
let valid_machines = ls machines | where type == dir | get name | each { $in | str replace "machines/" "" }
|
||||||
|
|
||||||
|
if ($machine_ | is-empty) {
|
||||||
|
$machine_ = (input $"Select machine to build [($valid_machines | str join ', ')]: ")
|
||||||
|
|
||||||
|
if ($machine_ | is-empty) and ($valid_machines | length) == 1 {
|
||||||
|
$machine_ = ($valid_machines | get 0)
|
||||||
|
} else {
|
||||||
|
main "" ($arguments | str join " ")
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if not ($machine_ in $valid_machines) {
|
||||||
|
main "" ($arguments | str join " ")
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
nix-shell --packages git --command $"sudo nixos-rebuild switch --impure --flake .#($machine) ($arguments | str join ' ')"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
15
rebuild.sh
15
rebuild.sh
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [[ $1 == "-h" || $1 == "--help" ]]; then
|
|
||||||
echo "Usage: $0 [-h | --help] [machine-name]"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
machine=$1
|
|
||||||
|
|
||||||
if [[ $machine == "" ]]; then
|
|
||||||
available_machines=$(ls --format=commas machines)
|
|
||||||
read -p "What machine would you like to build? (Possible options: $available_machines): " machine
|
|
||||||
fi
|
|
||||||
|
|
||||||
nix-shell --packages git --command "sudo nixos-rebuild switch --impure --flake .#$machine"
|
|
Loading…
Add table
Add a link
Reference in a new issue