Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create templates for flakes #14

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 46 additions & 60 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 @@ -53,106 +49,96 @@ nix.settings.experimental-features = [ "nix-command" "flakes" ];
Would you like to manage <darwin> with nix-channel? [y/n] y
```

6. 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
6. 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
```

7. Clone your new fork locally to customize:

> **Note**
> If the following command does not work revist steps 1 & 2.
7. 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#darwin
```

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

```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
```

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

```bash
darwin-rebuild switch --flake ".#darwin-aarch64" # for M1/M2 Chipsets
darwin-rebuild switch --flake ".#darwin-x86_64" # for Intel Chipsets
darwin-rebuild switch --flake ".#aarch64" # M Series Chipsets
darwin-rebuild switch --flake ".#x86_64" # Intel Chipsets
```

### NixOS
Congrats! You've setup Nix with Home Manager on macOS!

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

- `system/darwin.nix` for all `nix-darwin` related settings
- `module/configuration.nix` for `Nix` related settings
- `module/home-manager.nix` for `Home Manager` related settings

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

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

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!

## Personalizing Your Environment

You can further tailor your Nix environment through configurations.

### Darwin

- `nix-darwin` system options exist in `./system/darwin.nix`
- `home-manager` system options exist in `./system/darwin.nix`

### NixOS

> **Important**
> The default user password can be found and updated in `./system/nixos.nix`.

- `nixos` system hardware options exist in `./system/nixos-hardware-configuration.nix`
- `nixos` system options exist in `./system/nixos.nix`
- `home-manager` system options exist in `./module/home-manager.nix`

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

- `nix` system options exist in `./module/configuration.nix`
- `home-manager` user options exist in `./module/home-manager.nix`
- `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
65 changes: 1 addition & 64 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 13 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,43 +1,22 @@
{
description = "Example kickstart Nix development setup.";
description = "Minimal templates to get started with Nix.";

inputs = {
darwin.inputs.nixpkgs.follows = "nixpkgs";
darwin.url = "github:lnl7/nix-darwin";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/release-23.05";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
};

outputs = inputs@{ self, darwin, home-manager, nixpkgs, ... }:
let
### START OPTIONS ###
username = "<insert username>"; # should match your host username
### END OPTIONS ###

### START SYSTEMS ###
darwin-system = import ./system/darwin.nix { inherit inputs username; };
nixos-system = import ./system/nixos.nix { inherit inputs username; };
### END SYSTEMS ###
in
{
darwinConfigurations = {
darwin-aarch64 = darwin-system "aarch64-darwin";
darwin-x86_64 = darwin-system "x86_64-darwin";
outputs = inputs: {
templates = {
darwin = {
description = "A minimal Darwin development environment flake.";
path = ./template/darwin;
};

nixosConfigurations = {
nixos-aarch64 = nixos-system "aarch64-linux";
nixos-x86_64 = nixos-system "x86_64-linux";
go = {
description = "A minimal Go language flake.";
path = ./template/go;
};

templates = {
go = {
path = ./template/go;
description = ''
A minimal Go flake using flake-parts.
'';
};
nixos = {
description = "A minimal NixOS development environment flake.";
path = ./template/nixos;
};
};
};
}
23 changes: 23 additions & 0 deletions template/darwin/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
description = "Example kickstart Nix development setup.";

inputs = {
darwin.inputs.nixpkgs.follows = "nixpkgs";
darwin.url = "github:lnl7/nix-darwin";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/release-23.05";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
};

outputs = inputs@{ self, darwin, home-manager, nixpkgs, ... }:
let
username = throw "<username>"; # TODO: replace with user name and remove throw
darwin-system = import ./system/darwin.nix { inherit inputs username; };
in
{
darwinConfigurations = {
aarch64 = darwin-system "aarch64-darwin";
x86_64 = darwin-system "x86_64-darwin";
};
};
}
17 changes: 17 additions & 0 deletions template/darwin/module/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
# add more system settings here
nix = {
settings = {
auto-optimise-store = true;
builders-use-substitutes = true;
experimental-features = [ "flakes" "nix-command" ];
substituters = [ "https://nix-community.cachix.org" ];
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
trusted-users = [ "@wheel" ];
warn-dirty = false;
};
};
programs.zsh.enable = true;
}
File renamed without changes.
File renamed without changes.
Loading