diff --git a/README.md b/README.md index 721f3fc..45ab746 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: @@ -53,106 +49,96 @@ nix.settings.experimental-features = [ "nix-command" "flakes" ]; Would you like to manage 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//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 = ""; # replace + password = throw ""; # TODO: replace with password and remove throw + username = throw ""; # 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//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 = ""; # replace + password = throw ""; # TODO: replace with password and remove throw + username = throw ""; # 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 diff --git a/flake.lock b/flake.lock index 966bacb..5999137 100644 --- a/flake.lock +++ b/flake.lock @@ -1,69 +1,6 @@ { "nodes": { - "darwin": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1691275315, - "narHash": "sha256-9WN0IA0vNZSNxKHpy/bYvPnCw4VH/nr5iBv7c+7KUts=", - "owner": "lnl7", - "repo": "nix-darwin", - "rev": "829041cf10c4f6751a53c0a11ca2fd22ff0918d6", - "type": "github" - }, - "original": { - "owner": "lnl7", - "repo": "nix-darwin", - "type": "github" - } - }, - "home-manager": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1687871164, - "narHash": "sha256-bBFlPthuYX322xOlpJvkjUBz0C+MOBjZdDOOJJ+G2jU=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "07c347bb50994691d7b0095f45ebd8838cf6bc38", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "release-23.05", - "repo": "home-manager", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1691252436, - "narHash": "sha256-SKKPKYOnFcwqECehxoFBMLv29CZXC5qCDuETSuXd82g=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "9607b9149c9d81fdf3dc4f3bcc278da146ffbd77", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "darwin": "darwin", - "home-manager": "home-manager", - "nixpkgs": "nixpkgs" - } - } + "root": {} }, "root": "root", "version": 7 diff --git a/flake.nix b/flake.nix index 2ee4da7..2425b42 100644 --- a/flake.nix +++ b/flake.nix @@ -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 = ""; # 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; }; }; + }; } diff --git a/template/darwin/flake.nix b/template/darwin/flake.nix new file mode 100644 index 0000000..6d91f9b --- /dev/null +++ b/template/darwin/flake.nix @@ -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 ""; # 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"; + }; + }; +} diff --git a/template/darwin/module/configuration.nix b/template/darwin/module/configuration.nix new file mode 100644 index 0000000..9c05d8b --- /dev/null +++ b/template/darwin/module/configuration.nix @@ -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; +} diff --git a/module/home-manager.nix b/template/darwin/module/home-manager.nix similarity index 100% rename from module/home-manager.nix rename to template/darwin/module/home-manager.nix diff --git a/system/darwin.nix b/template/darwin/system/darwin.nix similarity index 100% rename from system/darwin.nix rename to template/darwin/system/darwin.nix diff --git a/template/go/flake.lock b/template/go/flake.lock new file mode 100644 index 0000000..29b0d80 --- /dev/null +++ b/template/go/flake.lock @@ -0,0 +1,63 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1698882062, + "narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8c9fa2545007b49a5db5f650ae91f227672c3877", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1700612854, + "narHash": "sha256-yrQ8osMD+vDLGFX7pcwsY/Qr5PUd6OmDMYJZzZi0+zc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "19cbff58383a4ae384dea4d1d0c823d72b49d614", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1698611440, + "narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/template/nixos/flake.nix b/template/nixos/flake.nix new file mode 100644 index 0000000..69ce262 --- /dev/null +++ b/template/nixos/flake.nix @@ -0,0 +1,23 @@ +{ + description = "Example kickstart Nix development setup."; + + inputs = { + 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, home-manager, nixpkgs, ... }: + let + password = throw ""; # TODO: replace with password and remove throw + username = throw ""; # TODO: replace with user name and remove throw + + nixos-system = import ./system/nixos.nix { inherit inputs password username; }; + in + { + nixosConfigurations = { + aarch64 = nixos-system "aarch64-linux"; + x86_64 = nixos-system "x86_64-linux"; + }; + }; +} diff --git a/module/configuration.nix b/template/nixos/module/configuration.nix similarity index 100% rename from module/configuration.nix rename to template/nixos/module/configuration.nix diff --git a/template/nixos/module/home-manager.nix b/template/nixos/module/home-manager.nix new file mode 100644 index 0000000..5a20c9f --- /dev/null +++ b/template/nixos/module/home-manager.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + # add home-manager user settings here + home.packages = with pkgs; [ git neovim ]; + home.stateVersion = "23.05"; +} diff --git a/system/nixos-hardware-configuration.nix b/template/nixos/system/hardware-configuration.nix similarity index 100% rename from system/nixos-hardware-configuration.nix rename to template/nixos/system/hardware-configuration.nix diff --git a/system/nixos.nix b/template/nixos/system/nixos.nix similarity index 86% rename from system/nixos.nix rename to template/nixos/system/nixos.nix index 188aa4e..a448ad1 100644 --- a/system/nixos.nix +++ b/template/nixos/system/nixos.nix @@ -1,9 +1,9 @@ -{ inputs, username }: +{ inputs, username, password }: system: let - hardware-configuration = import ./nixos-hardware-configuration.nix; + hardware-configuration = import ./hardware-configuration.nix; configuration = import ../module/configuration.nix; in inputs.nixpkgs.lib.nixosSystem { @@ -23,7 +23,7 @@ inputs.nixpkgs.lib.nixosSystem { extraGroups = [ "wheel" ]; home = "/home/${username}"; isNormalUser = true; - password = "password"; + password = password; }; system.stateVersion = "23.05"; }