Kickstart your Nix environments.
Guide for setting up Nix on non-NixOS based Linux systems.
nixpkgs
with official script:[!NOTE] The offical docs suggest using
daemon
mode to install with this approach. Nix currently does not support SELINUX enabled.
sh <(curl -L https://nixos.org/nix/install) --daemon
/etc/nix/nix.conf
to enable the following settings:experimental-features = nix-command flakes
flake.nix
configuration:mkdir -p ~/kickstart.nix
cd ~/kickstart.nix
nix flake init
generate the kickstart.nix
template locally:nix flake init -t github:ALT-F4-LLC/kickstart.nix#home-manager
flake.nix
configuration:[!IMPORTANT] Both
homeDirectory
andusername
must be updated with your user home directory and username. Once updated, removethrow
before each value to remove errors while switching.
homeManagerModule = import ./module/home-manager.nix {
homeDirectory = throw "<enter homeDirectory in flake.nix>"; # TODO: home directory of the user
username = throw "<enter username in flake.nix>"; # TODO: username of the user
};
home-manager
from nixpkgs
to build and switch environments:[!IMPORTANT] This template supports the following systems:
aarch64-darwin
,aarch64-linux
,x86_64-darwin
andx86_64-linux
.
# for ARM systems running macOS
nix run nixpkgs#home-manager -- build --flake .#aarch64-darwin
nix run nixpkgs#home-manager -- switch --flake .#aarch64-darwin
# for ARM systems running Linux
nix run nixpkgs#home-manager -- build --flake .#aarch64-linux
nix run nixpkgs#home-manager -- switch --flake .#aarch64-linux
# for Intel systems running macOS
nix run nixpkgs#home-manager -- build --flake .#x86_64-darwin
nix run nixpkgs#home-manager -- switch --flake .#x86_64-darwin
# for Intel systems running Linux
nix run nixpkgs#home-manager -- build --flake .#x86_64-linux
nix run nixpkgs#home-manager -- switch --flake .#x86_64-linux
Congrats! You've setup Home Manager on your existing operating system!
Be sure to explore the files below to get started customizing:
module/home-manager.nix
for Home Manager
related settingsflake.nix
for flake related settingsGuide for setting up Nix on macOS based systems.
nixpkgs
with official script:sh <(curl -L https://nixos.org/nix/install)
nix-darwin
with official steps:nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer
y
to edit your default configuration.nix
file:Would you like to edit the default configuration.nix before starting? [y/n] y
configuration.nix
to enable nix-command
and flakes
features:nix.settings.experimental-features = [ "nix-command" "flakes" ];
y
to setup <darwin>
in nix-channel
(though it won't be used):Would you like to manage <darwin> with nix-channel? [y/n] y
flake.nix
configuration:mkdir -p ~/kickstart.nix
cd ~/kickstart.nix
nix flake init
generate the kickstart.nix
template locally:nix flake init -t github:ALT-F4-LLC/kickstart.nix#darwin
flake.nix
configuration:[!IMPORTANT] The
username
value must be updated with your system username. Once updated, removethrow
to remove error while switching.
let
username = throw "<username>"; # TODO: replace with user name and remove throw
in
kickstart.nix
environment for your system with flake configuration:darwin-rebuild switch --flake ".#aarch64" # M Series Chipsets
darwin-rebuild switch --flake ".#x86_64" # Intel Chipsets
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 settingsmodule/configuration.nix
for Nix
related settingsmodule/home-manager.nix
for Home Manager
related settingsflake.nix
for flake related settingsGuide for setting up NixOS based systems.
Install NixOS using the latest ISO image for your system.
Add the following to /etc/nixos/configuration.nix
to enable nix-command
and flakes
features:
nix.extraOptions = "experimental-features = nix-command flakes";
sudo nixos-rebuild test
sudo nixos-rebuild switch
flake.nix
configuration:mkdir -p ~/kickstart.nix
cd ~/kickstart.nix
nix flake init
generate the kickstart.nix
template of your choice locally:nix flake init -t github:ALT-F4-LLC/kickstart.nix#nixos-desktop
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nixos-minimal
flake.nix
configuration:desktop
flake template:[!IMPORTANT] Both
username
andpassword
must be updated with your user username. Once updated, removethrow
before each value to remove errors while switching. If you'd rather use a hashed password replacepassword
withhashedPassword
with your password hash.
let
nixos-system = import ./system/nixos.nix {
inherit inputs;
username = throw "<username>"; # REQUIRED: replace with user name and remove throw
password = throw "<password>"; # REQUIRED: replace with password and remove throw
desktop = "gnome"; # optional: "gnome" by default, or "plasma5" for KDE Plasma
};
in
minimal
flake template:let
nixos-system = import ./system/nixos.nix {
inherit inputs;
username = throw "<username>"; # REQUIRED: replace with user name and remove throw
password = throw "<password>"; # REQUIRED: replace with password and remove throw
};
in
kickstart.nix
environment for your system with flake configuration:[!IMPORTANT] We use
--impure
due to how/etc/nixos/hardware-configuration.nix
is generated and stored on the system after installation. To avoid using this flag, copyhardware-configuration.nix
file locally and replace import in the template see example.
aarch64
platforms:sudo nixos-rebuild test --flake ".#aarch64" --impure # M Series Chipsets
sudo nixos-rebuild switch --flake ".#aarch64" --impure # M Series Chipsets
x86_64
platforms:sudo nixos-rebuild test --flake ".#x86_64" --impure # Intel Chipsets
sudo nixos-rebuild switch --flake ".#x86_64" --impure # Intel Chipsets
Congrats! You've setup NixOS with Home Manager!
Be sure to explore the files below to get started customizing:
module/configuration.nix
for more NixOS
system related settingsmodule/home-manager.nix
for Home Manager
related settingssystem/nixos.nix
for NixOS
system related settingsflake.nix
for flake related settingsUsed for Bash scripts.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#bash
Used for C++ projects using CMake as a build system.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#cpp-cmake
Used for Dart applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#dart
Used for modern Go apps setup with go.mod
system. To build legacy Go apps, use go-pkg
template.
[!IMPORTANT] Be sure to update
go.mod
with proper repository after runninginit
command.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#go-mod
Used for legacy Go apps not setup with go.mod
system. To build modern Go apps, use go-mod
template.
[!IMPORTANT] Be sure to update
deps.nix
with vendor dependencies after runninginit
command (read more).
nix flake init -t github:ALT-F4-LLC/kickstart.nix#go-pkg
Used for Haskell applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#haskell
Used for Lua script applications. This template creates a shell script wrapper which executes your Lua code. See flake.nix
for more.
[!NOTE] We wrap Lua because we are using an interpreted language which requires both binary and code to run. This is similar to
console scripts
in thepython-app
template.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#lua-app
Used for NestJS applications. The template builds using npm
.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nestjs
To update your dependencies, install/upgrade them as normal via NPM, then use
the prefetch-npm-deps
package from nixpkgs
to generate a new npmDepsHash
value for packages.default
in the Flake.
$ nix shell 'nixpkgs#prefetch-npm-deps' -c prefetch-npm-deps package-lock.json
...
sha256-nTTzkQEdnwWEQ/3uy8hUbPsRvzM53xuoJHoQhR3E/zk=
Used for Node.js backend applications. The template builds using npm
, and does
not assume you use TypeScript.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nodejs-backend
To update your dependencies, install/upgrade them as normal via NPM, then use
the prefetch-npm-deps
package from nixpkgs
to generate a new npmDepsHash
value for packages.default
in the Flake.
$ nix shell 'nixpkgs#prefetch-npm-deps' -c prefetch-npm-deps package-lock.json
...
sha256-nTTzkQEdnwWEQ/3uy8hUbPsRvzM53xuoJHoQhR3E/zk=
[!TIP] To add TypeScript, install it with
npm install --save-dev typescript
, add abuild
script topackage.json
that callstsc
, and then removedontNpmBuild = true;
frompackages.default
in your Flake.
Used for OCaml applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#ocaml
Used for PHP applications
nix flake init -t github:ALT-F4-LLC/kickstart.nix#php
Used for Powershell applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#powershell
Used for runnable Python apps setup with setup.py
and includes wrapped console scripts that can be executed from CLI. To build re-useable Python packages, use python-pkg
template.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#python-app
Used for Python packages setup with setup.py
that can be re-used within other Nix-built applications or packages. To build runnable Python apps, use python-app
template.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#python-pkg
Used for Rust applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#rust
Used for Swift applications packages with SwiftPM.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#swiftpm
To update your dependencies, while in the direnv dev shell, run:
# Update current dependency lockfile (Package.resolved)
swift package resolve
# Update Nix bindings for dependency set
swiftpm2nix
Then build again.
Used for React-based frontends built with Vite. The template builds using npm
.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#vite-react
To update your dependencies, install/upgrade them as normal via NPM, then use
the prefetch-npm-deps
package from nixpkgs
to generate a new npmDepsHash
value for packages.default
in the Flake. This
is included in the development shell provided by the flake.
$ prefetch-npm-deps package-lock.json
...
sha256-nTTzkQEdnwWEQ/3uy8hUbPsRvzM53xuoJHoQhR3E/zk=
Used for Zig applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#zig
Home Manager template allows you to run Nix with Home Manager on non-NixOS based Linux systems.
[!TIP] This setup is ideal for developers interested in running Linux distros other than NixOS.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nixos-minimal
macOS template allows you to run Nix tools on native Apple hardware.
[!TIP] This setup is ideal for developers already using macOS.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#darwin
NixOS desktop template includes base operating system with GNOME (default) windows manager included. You can also use plasma5
by changing desktop
value in flake.nix
file.
[!TIP] This setup is ideal for getting started moving to NixOS as your main desktop.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nixos-desktop
NixOS headless (minimal) template includes base operating system without any windows manager.
[!TIP] This setup is ideal for servers and other headless tasks.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nixos-minimal