After you've done basic instalation, mounted the filesystem and logged on, open the /etc/nixos/configuration.nix and add the following piece of code to it:
If you haven't already installed it, follow the NixOS Installation Guide for detailed instructions.
nix.settings.experimental-features = [ "nix-command" "flakes" ];
environment.systemPackages = with pkgs; [
git # To clone this repository
vim # Optional
];Then rebuild your system with sudo nixos-rebuild switch
After rebuild, copy this repository via
git clone https://github.com/necodrre/nix-config.git /home/$USER/Only thing you have to do when installing with script is to run install.sh from the config directory (you can do it from wherever you want).
./install.shScript will ask you for all the required information and install (build) the system for yourself.
Enter cloned directory.
cd /home/$USER/nix-configCreate a new folder in ./hosts named by your host (machine):
mkdir ./hosts/<hostname>Then copy all the files from ./hosts/T460 into your new directory
cp -r ./hosts/T460 ./hosts/<hostname>Replace hardware-configuration.nix with one generated by your nixos installation.
sudo mv /etc/nixos/hardware-configuration.nix ./hosts/<hostname>/
Comment (or simply delete) everything from hardware.graphics = { to services.xserver.videoDriver = [ "modesetting" ] in ./hosts/<hostname>/configuration.nix.
For more reference about setting up 3D graphics (if needed), visit official wiki page.
If you're not using laptop, but use PC, then comment the following line in ./nixos/modules/default.nix since you won't need it:
...
-- ./power-management.nix
++ # ./power-management.nix
...Delete all the files located at /etc/nixos and replace them with a symlink to ./hosts/<hostname>/configuration.nix.
sudo rm -r /etc/nixos/* && sudo ln -s ./hosts/<hostname>/configuration.nix /etc/nixos/configuration.nixSince
configuration.niximports yourhardware-configuration.nixat the top of the file, there is no need to symlinkhardware-configuration.nixtoo.
Finally, change ./flake.nix and ./home-manager/home.nix, if needed.
# flake.nix
...
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
system = "x86_64-linux";
-- homeStateVersion = "25.05";
++ homeStateVersion = "<your-state-version>";
-- user = "rat";
++ user = "<your-username>";
-- name = "lynette";
++ name = "<your-name>";
hosts = [
{ hostname = "T460"; stateVersion = "25.05"; }
++ { hostname = "<your-hostname>"; stateVersion = "<your-state-version>"}
];
...# home-manager/home.nix
...
home.sessionVariables = {
TERMINAL = "kitty";
EDITOR = "hx";
VISUAL = "hx";
-- NH_FLAKE = "${config.home.homeDirectory}/.config/nix-config";
++ NH_FLAKE = "<absolute-path-to-config-root-directory>"
++ # Example: "/home/rat/nix-config" or "{config.home.homeDirectory}/nix-config"
};
...If you don't want to use virtual machine, then comment following lines.
Note: Installing Oracle VirtualBox virtual machine will compile the source code of VirtualBox, which can take some time.
...
-- # Install and configure VirtualBox
-- virtualisation.virtualbox.host.enable = true;
-- virtualisation.virtualbox.host.enableExtensionPack = true; # Install Oracle VirtualBox Extensions.
-- # Unfree software permission is required.
-- users.extraGroups.vboxusers.members = [ user ];
-- virtualisation.virtualbox.host.enableKvm = true; # Enables KVM threading
-- virtualisation.virtualbox.host.addNetworkInterface = false; # Because VirtualBox KVM only supports standard NAT networking for VMs
-- boot.kernelParams = [ "kvm.enable_virt_at_load=0" ]; # Fix the KVM issue
++ # # Install and configure VirtualBox
++ # virtualisation.virtualbox.host.enable = true;
++ # virtualisation.virtualbox.host.enableExtensionPack = true; # Install Oracle VirtualBox Extensions.
++ # # Unfree software permission is required.
++ # users.extraGroups.vboxusers.members = [ user ];
++ # virtualisation.virtualbox.host.enableKvm = true; # Enables KVM threading
++ # virtualisation.virtualbox.host.addNetworkInterface = false; # Because VirtualBox KVM only supports standard NAT networking for VMs
++ # boot.kernelParams = [ "kvm.enable_virt_at_load=0" ]; # Fix the KVM issue
...Finally, declare a variable called NH_FLAKE with an absolute path to this config root directory.
NH_FLAKE=$(pwd)Rebuild your system and reboot.
sudo nixos-rebuild switch --flake .#<hostname> && rebootCreate nixpkgs directory in ~/.config (if it is not present already).
mkdir -p ~/.config/nixpkgsIf it exists, recursively remove its contents with
rm -r ~/.config/nixpkgs/*.
Create a symlink from /home/$USER/nix-config/home-manager/home.nix to /home/$USER/.config/nixpkgs/home.nix
sudo ln -s /home/$USER/nix-config/home-manager/home.nix /home/$USER/.config/nixpkgs/home.nixChange the ./home-manager/modules/git.nix file, if needed:
{
programs.git = {
enable = true;
-- userName = "necodrre";
++ userName = "<username>";
-- userEmail = "necodrre@proton.me";
++ userEmail = "<email>";
extraConfig = {
# "master" by default. You can skip this step and keep it "main" like I do
-- init.defaultBranch = "main";
++ init.defaultBranch = "<desired-default-branch-name>";
};
};
}Switch to your new home-manager configuration with
home-manager switch --flake .#<username>Source the .zshrc file or simply reopen the terminal:
source ~/.zshrcCongratulations! Now you're done!
Take a look at home-manager/modules/zsh.nix. There's a lot of handful aliases to explore. You might want to delete some of them, that's up to you.
Also, consider nixos/modules/nh.nix. You'll may find it handy that you can setup cron to clean up your system regularly.