Nix
Environment Setup
For Fish Shell, get nix.env.fish. However, a faster environment setup exists nix.fish.
Install it by using Fisher.
$ fisher install kidonng/nix.fish
Custom Nix Location
DO NOT SEPARATE THE NIX STORE LOCATION. IT IS BETTER TO MOVE |
Make sure that permissions are kept as is for /nix
.
$ mount --bind /path/to/nix /nix
For permanent solution, update your /etc/fstab
with the following:
/path/to/nix /nix none bind 0 0
Flakes + Home Manager
Installing Home Manager
Get Home Manager installed for non-nixos system.
But the tl;dr is:
$ nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager (1)
$ nix-channel --update
$ nix-shell '<home-manager>' -A install
1 | This is on unstable branch |
Enabling Flakes
Add experimental-features = nix-command flakes
in your /etc/nix/nix.conf
.
build-users-group = nixbld
max-jobs = auto
experimental-features = nix-command flakes
I probably missed some steps but you can look for it somewhere else.
Creating Flake.nix and home.nix
My current directory structure:
. (~/.config/home-manager/) ├── flake.lock ├── flake.nix └── modules └── home.nix
You might want to read about Flakes so that the next steps won’t be confusing. Otherwise, proceed ahead.
{
description = "0x42697262's Home Manager configurations using Flakes";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
homeManager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, homeManager }: {
homeConfigurations = {
"birb@QuarkPenguin" = homeManager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
system = "x86_64-linux";
config.allowUnfree = true;
};
modules = [ ./modules/home.nix ];
};
};
};
}
We want Home Manager get referenced by flakes.
homeManager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
Then configure Home Manager through flakes.
homeConfigurations = {
"birb@QuarkPenguin" = homeManager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
system = "x86_64-linux";
config.allowUnfree = true;
};
modules = [ ./modules/home.nix ];
};
};
After that, we then import our home.nix
module.
modules = [ ./modules/home.nix ];
{ pkgs, ... }: {
programs.home-manager.enable = true; (1)
home = {
homeDirectory = "/home/birb";
username = "birb";
stateVersion = "24.11";
packages = with pkgs; [ antora tree ];
};
}
1 | We need Home Manager installed, don’t forget this line. |