-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from DeterminateSystems/resolve-build
Add apply command
- Loading branch information
Showing
23 changed files
with
779 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "fh" | ||
version = "0.1.13" | ||
version = "0.1.14" | ||
authors = ["Determinate Systems <[email protected]>"] | ||
edition = "2021" | ||
license = "Apache 2.0" | ||
|
@@ -22,10 +22,11 @@ color-eyre = { version = "0.6.2", default-features = false, features = [ | |
"issue-url", | ||
] } | ||
csv = "1.3.0" | ||
gethostname = "0.4.3" | ||
gethostname = { version = "0.4.3", default-features = false } | ||
handlebars = "4.4.0" | ||
indicatif = { version = "0.17.6", default-features = false } | ||
inquire = "0.6.2" | ||
nix = { version = "0.29.0", default-features = false, features = ["user"] } | ||
nix-config-parser = "0.2.0" | ||
nixel = "5.2.0" | ||
once_cell = "1.18.0" | ||
|
@@ -39,6 +40,7 @@ semver = { version = "1.0.18", default-features = false, features = ["serde"] } | |
serde = { version = "1.0.188", default-features = false, features = ["derive"] } | ||
serde_json = "1.0.105" | ||
tabled = { version = "0.14.0", features = ["color"] } | ||
tempfile = "3.10.1" | ||
thiserror = { version = "1.0.44", default-features = false } | ||
tokio = { version = "1.30.0", default-features = false, features = ["full"] } | ||
tracing = "0.1.37" | ||
|
@@ -50,6 +52,7 @@ tracing-subscriber = { version = "0.3.17", default-features = false, features = | |
] } | ||
url = { version = "2.4.0", default-features = false, features = ["serde"] } | ||
urlencoding = "2.1.3" | ||
whoami = { version = "1.5.1", default-features = false } | ||
xdg = "2.5.2" | ||
|
||
[dev-dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,6 +151,76 @@ nix build \ | |
/nix/var/nix/profiles/system/bin/switch-to-configuration switch | ||
``` | ||
|
||
### Apply configurations to the current system | ||
|
||
The `fh apply` command enables you to apply a configuration for one of the following systems to the current host: | ||
|
||
- [NixOS](#nixos) | ||
- [Home Manager](#home-manager) | ||
- [nix-darwin](#nix-darwin) | ||
|
||
For all three systems, you only need to supply a flake output reference for the configuration and `fh` does the rest. | ||
|
||
#### NixOS | ||
|
||
On a [NixOS] system, you can use `fh apply nixos` to apply a configuration from an output path: | ||
|
||
```shell | ||
fh apply nixos "my-org/system-configs/0.1#nixosConfigurations.staging-box" | ||
``` | ||
|
||
If you don't specify a flake output path, `fh apply nixos` defaults to `nixosConfigurations.$(hostname)`. | ||
These two commands are thus equivalent: | ||
|
||
```shell | ||
fh apply nixos "my-org/system-configs/0.1#nixosConfigurations.$(hostname)" | ||
fh apply nixos "my-org/system-configs/0.1" | ||
``` | ||
|
||
`fh apply nixos` first resolves the supplied output reference to a store path, builds the `switch-to-configuration` script for that path, and then runs `switch-to-configuration switch` by default. | ||
You can also supply a different command from `switch` (`boot`, `test`, or `dry-activate`). | ||
Here's an example: | ||
|
||
```shell | ||
fh apply nixos "my-org/system-configs/0.1" boot | ||
``` | ||
|
||
#### Home Manager | ||
|
||
If you're on a system that uses [Home Manager][hm], you can use `fh apply home-manager` to apply a configuration from an output path: | ||
|
||
```shell | ||
fh apply home-manager "my-org/home-configs/0.1#homeConfigurations.standard-home-config" | ||
``` | ||
|
||
If you don't specify a flake output path, `fh apply home-manager` defaults to `homeConfigurations.$(whoami)`. | ||
These two commands are thus equivalent: | ||
|
||
```shell | ||
fh apply home-manager "my-org/home-configs/0.1#homeConfigurations.$(whoami)" | ||
fh apply home-manager "my-org/home-configs/0.1" | ||
``` | ||
|
||
`fh apply home-manager` first resolves the supplied output reference to a store path, builds the `activate` script for that path, and then runs it. | ||
|
||
#### nix-darwin | ||
|
||
If you're on a macOS system that uses [nix-darwin], you can use `fh apply nix-darwin` to apply a configuration from an output path: | ||
|
||
```shell | ||
fh apply nix-darwin "my-org/macos-configs/0.1#darwinConfigurations.justme-aarch64-darwin" | ||
``` | ||
|
||
If you don't specify a flake output path, `fh apply nix-darwin` defaults to `darwinConfigurations.${devicename}.system`, where `devicename` is the output of `scutil --get LocalHostName`. | ||
These two commands are thus equivalent: | ||
|
||
```shell | ||
fh apply nix-darwin "my-org/macos-configs/0.1#darwinConfigurations.$(scutil --get LocalHostName)" | ||
fh apply nix-darwin "my-org/macos-configs/0.1" | ||
``` | ||
|
||
`fh apply nix-darwin` first resolves the supplied output reference to a store path, builds the `darwin-rebuild` script for that path, and then runs `darwin-rebuild activate`. | ||
|
||
### Searching published flakes | ||
|
||
You can search publicly listed flakes using the `fh search` command and passing in a search query. | ||
|
@@ -336,9 +406,11 @@ For support, email [email protected] or [join our Discord](https://discord.gg | |
[flakehub-push-params]: https://github.com/determinateSystems/flakehub-push?tab=readme-ov-file#available-parameters | ||
[flakes]: https://flakehub.com/flakes | ||
[go]: https://golang.org | ||
[hm]: https://github.com/nix-community/home-manager | ||
[inputs]: https://zero-to-nix.com/concepts/flakes#inputs | ||
[java]: https://java.com | ||
[javascript]: https://javascript.info | ||
[nix-darwin]: https://github.com/LnL7/nix-darwin | ||
[nix-flakes]: https://zero-to-nix.com/concepts/flakes | ||
[nixos]: https://zero-to-nix.com/concepts/nixos | ||
[nixpkgs]: https://zero-to-nix.com/concepts/nixpkgs | ||
|
Oops, something went wrong.