Kickstart your Nix environments.
- Languages
- Systems
- Linux
- macOS
- NixOS
Guide for setting up Nix on non-NixOS based Linux systems.
- Install
nixpkgswith 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- Edit
/etc/nix/nix.confto enable the following settings:
experimental-features = nix-command flakes- Create a new directory for your
flake.nixconfiguration:
mkdir -p ~/kickstart.nix
cd ~/kickstart.nix- Using
nix flake initgenerate thekickstart.nixtemplate locally:
nix flake init -t github:ALT-F4-LLC/kickstart.nix#home-manager- Update following value(s) in
flake.nixconfiguration:
Important
Both homeDirectory and username must be updated with your user home directory and username. Once updated, remove throw 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
};- Run
home-managerfromnixpkgsto build and switch environments:
Important
This template supports the following systems: aarch64-darwin, aarch64-linux, x86_64-darwin and x86_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-linuxCongrats! You've setup Home Manager on your existing operating system!
Be sure to explore the files below to get started customizing:
module/home-manager.nixforHome Managerrelated settingsflake.nixfor flake related settings
Guide for setting up Nix on macOS based systems.
- Install
nixpkgswith official script:
sh <(curl -L https://nixos.org/nix/install)- Install
nix-darwinwith official steps:
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer- Answer the following with
yto edit your defaultconfiguration.nixfile:
Would you like to edit the default configuration.nix before starting? [y/n] y- Add the following to
configuration.nixto enablenix-commandandflakesfeatures:
nix.settings.experimental-features = [ "nix-command" "flakes" ];- Answer the following with
yto setup<darwin>innix-channel(though it won't be used):
Would you like to manage <darwin> with nix-channel? [y/n] y- Create a new directory for your
flake.nixconfiguration:
mkdir -p ~/kickstart.nix
cd ~/kickstart.nix- Using
nix flake initgenerate thekickstart.nixtemplate locally:
nix flake init -t github:ALT-F4-LLC/kickstart.nix#darwin- Update the following value(s) in
flake.nixconfiguration:
Important
The username value must be updated with your system username. Once updated, remove throw to remove error while switching.
let
username = throw "<username>"; # TODO: replace with user name and remove throw
in- Switch to
kickstart.nixenvironment for your system with flake configuration:
darwin-rebuild switch --flake ".#aarch64" # M Series Chipsets
darwin-rebuild switch --flake ".#x86_64" # Intel ChipsetsCongrats! You've setup Nix with Home Manager on macOS!
Be sure to explore the files below to get started customizing:
system/darwin.nixfor allnix-darwinrelated settingsmodule/configuration.nixforNixrelated settingsmodule/home-manager.nixforHome Managerrelated settingsflake.nixfor flake related settings
Guide for setting up NixOS based systems.
-
Install NixOS using the latest ISO image for your system.
-
Add the following to
/etc/nixos/configuration.nixto enablenix-commandandflakesfeatures:
nix.extraOptions = "experimental-features = nix-command flakes";- Update you system to reflect the changes:
sudo nixos-rebuild test
sudo nixos-rebuild switch- Create a new directory for your
flake.nixconfiguration:
mkdir -p ~/kickstart.nix
cd ~/kickstart.nix- Using
nix flake initgenerate thekickstart.nixtemplate 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- Update the following value(s) in
flake.nixconfiguration:
- For
desktopflake template:
Important
Both username and password must be updated with your user username. Once updated, remove throw before each value to remove errors while switching. If you'd rather use a hashed password replace password with hashedPassword 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- For
minimalflake 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- Switch to
kickstart.nixenvironment 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, copy hardware-configuration.nix file locally and replace import in the template see example.
- For
aarch64platforms:
sudo nixos-rebuild test --flake ".#aarch64" --impure # M Series Chipsets
sudo nixos-rebuild switch --flake ".#aarch64" --impure # M Series Chipsets- For
x86_64platforms:
sudo nixos-rebuild test --flake ".#x86_64" --impure # Intel Chipsets
sudo nixos-rebuild switch --flake ".#x86_64" --impure # Intel ChipsetsCongrats! You've setup NixOS with Home Manager!
Be sure to explore the files below to get started customizing:
module/configuration.nixfor moreNixOSsystem related settingsmodule/home-manager.nixforHome Managerrelated settingssystem/nixos.nixforNixOSsystem related settingsflake.nixfor flake related settings
Used for Bash scripts.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#bashUsed for C++ projects using CMake as a build system.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#cpp-cmakeUsed for Dart applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#dartUsed for modern Go apps setup with go.mod system.
Important
Be sure to update go.mod with proper repository after running init command.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#go-modUsed for Haskell applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#haskellUsed 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 the python-app template.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#lua-appUsed for NestJS applications. The template builds using npm.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nestjsTo 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-backendTo 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 a
build script to package.json that calls tsc, and then remove
dontNpmBuild = true; from packages.default in your Flake.
Used for OCaml applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#ocamlUsed for PHP applications
nix flake init -t github:ALT-F4-LLC/kickstart.nix#phpUsed for Powershell applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#powershellUsed 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-appUsed 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-pkgUsed for Rust applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#rustUsed for Swift applications packages with SwiftPM.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#swiftpmTo 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
swiftpm2nixThen 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-reactTo 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#zigUsed for Nim applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nimUsed for Terraform projects.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#tfHome 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-minimalmacOS 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#darwinNixOS 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-desktopNixOS 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