1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-09-19 08:37:17 +03:00

Merge pull request #676 from carlthome/patch-1

Use LocalHostName in darwin-rebuild with a flake
This commit is contained in:
Michael Hoang 2023-09-23 00:12:26 +01:00 committed by GitHub
commit c286b23c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -86,11 +86,10 @@ If you don't have an existing `configuration.nix`, you can run the following com
mkdir -p ~/.config/nix-darwin
cd ~/.config/nix-darwin
nix flake init -t nix-darwin
sed -i '' "s/simple/$(scutil --get LocalHostName)/" flake.nix
```
Make sure to replace all occurrences of `simple` with your short hostname which you can find by running `hostname -s`.
> NOTE: Make sure to change `nixpkgs.hostPlatform` to `aarch64-darwin` if you are using Apple Silicon.
Make sure to change `nixpkgs.hostPlatform` to `aarch64-darwin` if you are using Apple Silicon.
</details>
@ -118,9 +117,9 @@ Add the following to `flake.nix` in the same folder as `configuration.nix`:
}
```
Make sure to replace `Johns-MacBook` with your short hostname which you can find by running `hostname -s`.
Make sure to replace `Johns-MacBook` with your hostname which you can find by running `scutil --get LocalHostName`.
> NOTE: Make sure to set `nixpkgs.hostPlatform` in your `configuration.nix` to either `x86_64-darwin` (Intel) or `aarch64-darwin` (Apple Silicon).
Make sure to set `nixpkgs.hostPlatform` in your `configuration.nix` to either `x86_64-darwin` (Intel) or `aarch64-darwin` (Apple Silicon).
</details>

View File

@ -132,7 +132,7 @@ if [ -n "$flake" ]; then
flakeAttr=${fragment}
fi
if [ -z "$flakeAttr" ]; then
flakeAttr=$(hostname -s)
flakeAttr=$(scutil --get LocalHostName)
fi
flakeAttr=darwinConfigurations.${flakeAttr}
fi