- This is my personal dotfiles using nix or nixos.
- This flake depends on other package managers such as homebrews.
- Also, the configuration for each tool use Nix as little as possible.
- This is to facilitate the porting of dotfiles even if I stop using Nix in the future.
- Install NixOS following here. Example installation steps are below.
# create a gpt partition table on the disk
parted /dev/sda -- mklabel gpt
# create a root partition
# it starts from 512MB of the disk and ends at the part excluding 64gb from the end of the disk
parted /dev/sda -- mkpart root ext4 512MB -64GB
# create a swap partition
# it occupies the part of 64gb from the end of the disk
parted /dev/sda -- mkpart swap linux-swap -64GB 100%
# create an esp partition
# it occupies the part from 1MB to 512mb of the disk
parted /dev/sda -- mkpart ESP fat32 1MB 512MB
# set the esp flag on the esp partition
parted /dev/sda -- set 3 esp on
# create an ext4 filesystem on /dev/sda1 and label it as 'nixos'
mkfs.ext4 -L nixos /dev/sda1
# set up a linux swap area on /dev/sda2 and label it as 'swap'
mkswap -L swap /dev/sda2
# create a fat32 filesystem on /dev/sda3 and label it as 'boot'
mkfs.fat -F 32 -n boot /dev/sda3
# mount the 'nixos' partition to the /mnt directory
mount /dev/disk/by-label/nixos /mnt
# create a new directory /mnt/boot and mount the 'boot' partition to the /mnt/boot directory with umask set to 077
mkdir -p /mnt/boot && mount -o umask=077 /dev/disk/by-label/boot /mnt/boot
# enable the swap partition
swapon /dev/sda2
# generate a nixos configuration file for the system
nixos-generate-config --root /mnt
# install NixOS on the system
nixos-install
# reboot the system
reboot
# login as root
# create a new user 'yanosea' with a home directory
useradd -m yanosea
# set or change password for user 'yanosea'
passwd yanosea
# add user 'yanosea' sudoers
visudo
# add below
yanosea ALL=(ALL:ALL) SETENV:ALL
# exit from root and login as yanosea
exit
- First, update the system. (You have to add your user to sodoers.)
# update the system
sudo nix-channel --add https://nixos.org/channels/nixos-24.11 nixos && sudo nix-channel --update && sudo nixos-rebuild switch
# you may have to add your user to sudoers again
- Enter nix-shell with necessary packages.
# enter nix-shell
nix-shell -p cargo cargo-make ghq git home-manager
- Clone this repository and change the directory.
# clone this repository and change the directory
ghq get yanosea/yanoNixFiles && cd ghq/github.com/yanosea/yanoNixFiles
- Execute init task.
# execute init task
cargo make nix.init
- Reboot NixOS.
# reboot nixos
reboot
- Then, you got a new NixOS environment ;)
- Edit your config in yanoNixFiles repository.
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# then, edit config files or pkglist
- Execute install task.
# execute install task
cargo make nix.install
- If there were no issues, commit, push the changes.
- Just execute update task.
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# execute update task
cargo make nix.update
-
Download nixos-wsl.tar.gz from the latest release.
-
Make the directory and move the downloaded file to the directory. Then, change the directory.
#
# on windows
#
# make the directory and move the downloaded file
mkdir -p .\.local\share\wsl\nixos && mv .\Downloads\nixos-wsl.tar.gz .\.local\share\wsl\nixos
- Import the tarball.
#
# on windows
#
# if you already have NixOS WSL env, unregister it
wsl --unregister NixOS
# change directory and import the tarball
cd .local\share\wsl\nixos && wsl --import NixOS . nixos-wsl.tar.gz --version 2
- Start the WSL.
#
# on windows
#
# start the WSL
wsl -d NixOS --cd ~
- First, update the system. Then, add user yanosea.
#
# on nixos
#
# update the system
sudo nix-channel --add https://nixos.org/channels/nixos-24.11 nixos && sudo nix-channel --update && sudo nixos-rebuild switch
# change to root
sudo -i
# add user yanosea and set password
useradd yanosea && passwd yanosea
# edit sodoers
visudo
# add below
yanosea ALL=(ALL:ALL) SETENV:ALL
# create home directory of yanosea and change ownership
mkdir -p /home/yanosea && chown yanosea /home/yanosea && chgrp users /home/yanosea
# switch to yanosea
su - yanosea
- Enter nix-shell with necessary packages.
#
# on nixos
#
# enter nix-shell
nix-shell -p cargo cargo-make ghq git home-manager
- Clone this repository and change the directory.
#
# on nixos
#
# clone this repository and change the directory
ghq get yanosea/yanoNixFiles && cd ghq/github.com/yanosea/yanoNixFiles
- Execute initialize task. After this step, exit from WSL.
#
# on nixos
#
# execute initialize task
cargo make wsl.init
# exit from WSL (you have to type this many times)
exit
- Terminate WSL and restart it.
#
# on windows
#
# terminate the WSL
wsl --terminate NixOS
# start the WSL
wsl -d NixOS --cd ~
- Then, you got a new NixOS WSL environment ;)
- Edit your config in yanoNixFiles repository.
#
# on nixos
#
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# then, edit config files or pkglist
- Execute install task.
#
# on nixos
#
# execute install task
cargo make wsl.install
- If there were no issues, commit, push the changes.
- Just execute update task.
#
# on nixos
#
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# execute update task
cargo make wsl.update
-
Install nix following here.
-
Install nix-darwin following here.
-
Install homebrew following here.
-
First, update the system. (You have to add your user to sodoers.)
# update the system
sudo nix-channel --add https://nixos.org/channels/nixos-24.11 nixos && sudo nix-channel --update && sudo darwin-rebuild switch
- Enter nix-shell with necessary packages.
# enter nix-shell
nix-shell -p cargo cargo-make ghq git home-manager
- Clone this repository and change the directory.
# clone this repository and change the directory
ghq get yanosea/yanoNixFiles && cd ghq/github.com/yanosea/yanoNixFiles
- Execute initialize task.
# execute initialize task
cargo make darwin.init
- Edit /etc/shells and chsh. After this step, exit from the shell.
# edit /etc/shells
vim /etc/shells
# add below
# /Users/yanosea/.nix-profile/bin/zsh
# chsh
chsh -s /Users/yanosea/.nix-profile/bin/zsh
# exit from the shell (you have to type this many times)
exit
- Install command line developer tool.
# install command line developer tool
xcode-select --install
- Then, you got a new Darwin × Nix environment ;)
- Edit your config in yanoNixFiles repository.
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# then, edit config files or pkglist
- Execute install task.
# execute apply task
cargo make darwin.install
- If there were no issues, commit, push the changes.
- Just execute update task.
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# execute update task
cargo make darwin.update
I appreciate a lot to all the following articles and repositories🙏