mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
installer: move creating default configuration to README
This commit is contained in:
parent
5cc3c00f9b
commit
9a1bea70d5
4 changed files with 19 additions and 56 deletions
20
.github/workflows/test.yml
vendored
20
.github/workflows/test.yml
vendored
|
@ -49,17 +49,15 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
export NIX_PATH=$HOME/.nix-defexpr/channels
|
export NIX_PATH=$HOME/.nix-defexpr/channels
|
||||||
|
|
||||||
# We run nix-darwin twice to test that it can create darwin-configuration correctly for us
|
mkdir -p ~/.config/nix-darwin
|
||||||
# but we expect it to fail setting up /etc/nix/nix.conf
|
cp modules/examples/simple.nix ~/.config/nix-darwin/configuration.nix
|
||||||
nix-shell -A installer || true
|
|
||||||
|
|
||||||
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
|
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
|
||||||
/usr/bin/sed -i.bak \
|
/usr/bin/sed -i.bak \
|
||||||
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
|
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
|
||||||
~/.nixpkgs/darwin-configuration.nix
|
~/.config/nix-darwin/configuration.nix
|
||||||
|
|
||||||
nix-shell -A installer
|
nix-shell -A installer -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
|
||||||
nix-shell -A installer.check
|
|
||||||
- name: Build and activate default derivation
|
- name: Build and activate default derivation
|
||||||
run: |
|
run: |
|
||||||
. /etc/static/bashrc
|
. /etc/static/bashrc
|
||||||
|
@ -97,17 +95,15 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
export NIX_PATH=$HOME/.nix-defexpr/channels
|
export NIX_PATH=$HOME/.nix-defexpr/channels
|
||||||
|
|
||||||
# We run nix-darwin twice to test that it can create darwin-configuration correctly for us
|
mkdir -p ~/.config/nix-darwin
|
||||||
# but we expect it to fail setting up /etc/nix/nix.conf
|
cp modules/examples/simple.nix ~/.config/nix-darwin/configuration.nix
|
||||||
nix-shell -A installer || true
|
|
||||||
|
|
||||||
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
|
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
|
||||||
/usr/bin/sed -i.bak \
|
/usr/bin/sed -i.bak \
|
||||||
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
|
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
|
||||||
~/.nixpkgs/darwin-configuration.nix
|
~/.config/nix-darwin/configuration.nix
|
||||||
|
|
||||||
nix-shell -A installer
|
nix-shell -A installer -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
|
||||||
nix-shell -A installer.check
|
|
||||||
- name: Build and activate default derivation
|
- name: Build and activate default derivation
|
||||||
run: |
|
run: |
|
||||||
. /etc/static/bashrc
|
. /etc/static/bashrc
|
||||||
|
|
25
README.md
25
README.md
|
@ -115,14 +115,18 @@ nix-darwin.lib.darwinSystem {
|
||||||
<details>
|
<details>
|
||||||
<summary>Channels</summary>
|
<summary>Channels</summary>
|
||||||
|
|
||||||
### Installing
|
### Step 1. Creating `configuration.nix`
|
||||||
|
|
||||||
|
Copy the [simple](./modules/examples/simple.nix) example to `~/.config/nix-darwin/configuration.nix`.
|
||||||
|
|
||||||
|
### Step 2. Installing `nix-darwin`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
|
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
|
||||||
./result/bin/darwin-installer
|
./result/bin/darwin-installer
|
||||||
```
|
```
|
||||||
|
|
||||||
### Updating
|
### Step 3. Updating `nix-darwin`
|
||||||
|
|
||||||
The installer will configure a channel for this repository.
|
The installer will configure a channel for this repository.
|
||||||
|
|
||||||
|
@ -133,23 +137,6 @@ darwin-rebuild changelog
|
||||||
|
|
||||||
> NOTE: If you are using Nix as a daemon service the channel for that will be owned by root.
|
> NOTE: If you are using Nix as a daemon service the channel for that will be owned by root.
|
||||||
> Use `sudo -i nix-channel --update darwin` instead.
|
> Use `sudo -i nix-channel --update darwin` instead.
|
||||||
|
|
||||||
### Example configuration
|
|
||||||
|
|
||||||
Configuration lives in `~/.nixpkgs/darwin-configuration.nix`. Check out
|
|
||||||
[modules/examples](https://github.com/LnL7/nix-darwin/tree/master/modules/examples) for some example configurations.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
# List packages installed in system profile. To search by name, run:
|
|
||||||
# $ nix-env -qaP | grep wget
|
|
||||||
environment.systemPackages =
|
|
||||||
[ pkgs.vim
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
[ pkgs.vim
|
[ pkgs.vim
|
||||||
];
|
];
|
||||||
|
|
||||||
# Use a custom configuration.nix location.
|
# Use custom location for configuration.nix.
|
||||||
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
|
environment.darwinConfig = "$HOME/.config/nix-darwin/configuration.nix";
|
||||||
# environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
|
|
||||||
|
|
||||||
# Enable alternative shell support in nix-darwin.
|
# Enable alternative shell support in nix-darwin.
|
||||||
# programs.fish.enable = true;
|
# programs.fish.enable = true;
|
||||||
|
|
|
@ -47,25 +47,6 @@ stdenv.mkDerivation {
|
||||||
echo >&2 "Installing nix-darwin..."
|
echo >&2 "Installing nix-darwin..."
|
||||||
echo >&2
|
echo >&2
|
||||||
|
|
||||||
config="$HOME/.nixpkgs/darwin-configuration.nix"
|
|
||||||
if ! test -f "$config"; then
|
|
||||||
echo "copying example configuration.nix" >&2
|
|
||||||
mkdir -p "$HOME/.nixpkgs"
|
|
||||||
cp "${../../modules/examples/simple.nix}" "$config"
|
|
||||||
chmod u+w "$config"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Skip when stdin is not a tty, eg.
|
|
||||||
# $ yes | darwin-installer
|
|
||||||
if test -t 0; then
|
|
||||||
read -p "Would you like to edit the default configuration.nix before starting? [y/N] " i
|
|
||||||
case "$i" in
|
|
||||||
y|Y)
|
|
||||||
PATH=$_PATH ''${EDITOR:-nano} "$config"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
i=y
|
i=y
|
||||||
darwinPath=$(NIX_PATH=$HOME/.nix-defexpr/channels nix-instantiate --eval -E '<darwin>' 2> /dev/null) || true
|
darwinPath=$(NIX_PATH=$HOME/.nix-defexpr/channels nix-instantiate --eval -E '<darwin>' 2> /dev/null) || true
|
||||||
if ! test -e "$darwinPath"; then
|
if ! test -e "$darwinPath"; then
|
||||||
|
@ -81,13 +62,13 @@ stdenv.mkDerivation {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export NIX_PATH=${nixPath}
|
export NIX_PATH=${nixPath}
|
||||||
system=$(nix-build '<darwin>' -I "darwin-config=$config" -A system --no-out-link --show-trace)
|
system=$(nix-build '<darwin>' -A system --no-out-link --show-trace)
|
||||||
|
|
||||||
export PATH=$system/sw/bin:$PATH
|
export PATH=$system/sw/bin:$PATH
|
||||||
darwin-rebuild "$action" -I "darwin-config=$config"
|
darwin-rebuild "$action"
|
||||||
|
|
||||||
echo >&2
|
echo >&2
|
||||||
echo >&2 " Open '$config' to get started."
|
echo >&2 " Installation complete."
|
||||||
echo >&2 " See the README for more information: [0;34mhttps://github.com/LnL7/nix-darwin/blob/master/README.md[0m"
|
echo >&2 " See the README for more information: [0;34mhttps://github.com/LnL7/nix-darwin/blob/master/README.md[0m"
|
||||||
echo >&2
|
echo >&2
|
||||||
echo >&2 " Please log out and log in again to make sure nix-darwin is properly loaded."
|
echo >&2 " Please log out and log in again to make sure nix-darwin is properly loaded."
|
||||||
|
|
Loading…
Reference in a new issue