Skip to content

Commit

Permalink
feat(template): improvements for nixos
Browse files Browse the repository at this point in the history
  • Loading branch information
erikreinert committed Nov 30, 2023
1 parent 9f86736 commit a3eb167
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 37 deletions.
64 changes: 35 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Kickstart your Nix environment.
## Table of Contents

- [Prerequisites](#prerequisites)
- [Initial Setup](#initial-setup)
- [Personalizing Your Environment](#personalizing-your-environment)
- [Setup macOS](#setup-macos)
- [Setup NixOS](#setup-nixos)


## Prerequisites
Expand All @@ -16,11 +16,7 @@ Kickstart your Nix environment.
- [GitHub CLI](https://github.com/cli/cli) (`gh`) installed for some commands.


## Initial Setup

Choose the appropriate setup instructions based on your operating system.

### macOS
## Setup macOS

1. Install `nixpkgs` with official script:

Expand Down Expand Up @@ -56,8 +52,8 @@ Would you like to manage <darwin> with nix-channel? [y/n] y
6. Create a new directory for your `flake.nix` configuration:

```bash
mkdir -p ~/Desktop/kickstart.nix
cd ~/Desktop/kickstart.nix
mkdir -p ~/kickstart.nix
cd ~/kickstart.nix
```

7. Using `nix flake init` generate the `kickstart.nix` template locally:
Expand All @@ -70,7 +66,8 @@ nix flake init --template github:ALT-F4-LLC/kickstart.nix#darwin

```nix
let
username = "<insert-username>"; # replace
password = throw "<username>"; # TODO: replace with password and remove throw
username = throw "<username>"; # TODO: replace with user name and remove throw
in
```

Expand All @@ -89,53 +86,62 @@ Be sure to explore the files below to get started customizing:
- `module/configuration.nix` for `Nix` related settings
- `module/home-manager.nix` for `Home Manager` related settings

### NixOS
### Setup NixOS

1. Install NixOS using the [latest ISO image](https://nixos.org/download#nixos-iso).

1. Add the following to `/etc/nixos/configuration.nix` to enable `nix-command` and `flakes` features:
2. Add the following to `/etc/nixos/configuration.nix` to enable `nix-command` and `flakes` features:

```nix
nix.settings.experimental-features = [ "nix-command" "flakes" ];
nix.extraOptions = "experimental-features = nix-command flakes";
```

2. Update you system to reflect the changes:
3. Update you system to reflect the changes:

```bash
nixos-rebuild switch
```

3. Fork this repository to create your own flake kickstart.

> **Note**
> This can be done in the Github UI at: https://github.com/ALT-F4-LLC/kickstart.nix
4. Create a new directory for your `flake.nix` configuration:

```bash
gh repo fork ALT-F4-LLC/kickstart.nix
mkdir -p ~/kickstart.nix
cd ~/kickstart.nix
```

4. Clone your new fork locally to customize:

> **Note**
> If the following command does not work revist steps 1 & 2.
5. Using `nix flake init` generate the `kickstart.nix` template locally:

```bash
nix run nixpkgs#git clone https://github.com/<username>/kickstart.nix
nix flake init --template github:ALT-F4-LLC/kickstart.nix#nixos
```

5. Update the following value(s) in `flake.nix` configuration:
6. Update the following value(s) in `flake.nix` configuration:

> **Important**
> The default user password can be found in `flake.nix`.
```nix
let
username = "<insert-username>"; # replace
password = throw "<username>"; # TODO: replace with password and remove throw
username = throw "<username>"; # TODO: replace with user name and remove throw
in
```

6. Switch to `kickstart.nix` environment for your system with flake configuration:
7. Switch to `kickstart.nix` environment for your system with flake configuration:

```bash
nixos-rebuild switch --flake ".#nixos-aarch64" # for ARM Chipsets
nixos-rebuild switch --flake ".#nixos-x86_64" # for Intel Chipsets
nixos-rebuild switch --flake ".#aarch64" # M Series Chipsets
nixos-rebuild switch --flake ".#x86_64" # Intel Chipsets
```

Congrats! You've setup NixOS with Home Manager!

Be sure to explore the files below to get started customizing:

- `system/hardware-configuration.nix` for `NixOS` hardware related settings
- `system/nixos.nix` for `NixOS` system related settings
- `module/configuration.nix` for more `NixOS` system related settings
- `module/home-manager.nix` for `Home Manager` related settings

## Personalizing Your Environment

Expand Down
4 changes: 2 additions & 2 deletions template/darwin/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
in
{
darwinConfigurations = {
darwin-aarch64 = darwin-system "aarch64-darwin";
darwin-x86_64 = darwin-system "x86_64-darwin";
aarch64 = darwin-system "aarch64-darwin";
x86_64 = darwin-system "x86_64-darwin";
};
};
}
9 changes: 5 additions & 4 deletions template/nixos/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

outputs = inputs@{ self, home-manager, nixpkgs, ... }:
let
username = "<insert username>"; # should match your host username
password = throw "<username>"; # TODO: replace with password and remove throw
username = throw "<username>"; # TODO: replace with user name and remove throw

nixos-system = import ./system/nixos.nix { inherit inputs username; };
nixos-system = import ./system/nixos.nix { inherit inputs password username; };
in
{
nixosConfigurations = {
nixos-aarch64 = nixos-system "aarch64-linux";
nixos-x86_64 = nixos-system "x86_64-linux";
aarch64 = nixos-system "aarch64-linux";
x86_64 = nixos-system "x86_64-linux";
};
};
}
4 changes: 2 additions & 2 deletions template/nixos/system/nixos.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ inputs, username }:
{ inputs, username, password }:

system:

Expand All @@ -23,7 +23,7 @@ inputs.nixpkgs.lib.nixosSystem {
extraGroups = [ "wheel" ];
home = "/home/${username}";
isNormalUser = true;
password = "password";
password = password;
};
system.stateVersion = "23.05";
}
Expand Down

0 comments on commit a3eb167

Please sign in to comment.