Skip to content

yanosea/yanoNixFiles

Repository files navigation

❄️ yanoNixFiles

dotfile is mine.

⚠️ WARNING

  • 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.

❄️ NixOS

🌠 Initialize

  1. 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
  1. 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
  1. Enter nix-shell with necessary packages.
# enter nix-shell
nix-shell -p cargo cargo-make ghq git home-manager
  1. Clone this repository and change the directory.
# clone this repository and change the directory
ghq get yanosea/yanoNixFiles && cd ghq/github.com/yanosea/yanoNixFiles
  1. Execute init task.
# execute init task
cargo make nix.init
  1. Reboot NixOS.
# reboot nixos
reboot
  1. Then, you got a new NixOS environment ;)

🔧 Edit config and install new packages

  1. Edit your config in yanoNixFiles repository.
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# then, edit config files or pkglist
  1. Execute install task.
# execute install task
cargo make nix.install
  1. If there were no issues, commit, push the changes.

✨ Update

  1. Just execute update task.
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# execute update task
cargo make nix.update

🪟 WSL

🌠 Initialize

  1. Download nixos-wsl.tar.gz from the latest release.

  2. 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
  1. 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
  1. Start the WSL.
#
# on windows
#

# start the WSL
wsl -d NixOS --cd ~
  1. 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
  1. Enter nix-shell with necessary packages.
#
# on nixos
#

# enter nix-shell
nix-shell -p cargo cargo-make ghq git home-manager
  1. 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
  1. 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
  1. Terminate WSL and restart it.
#
# on windows
#
# terminate the WSL
wsl --terminate NixOS
# start the WSL
wsl -d NixOS --cd ~
  1. Then, you got a new NixOS WSL environment ;)

🔧 Edit config and install new packages

  1. Edit your config in yanoNixFiles repository.
#
# on nixos
#

# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# then, edit config files or pkglist
  1. Execute install task.
#
# on nixos
#

# execute install task
cargo make wsl.install
  1. If there were no issues, commit, push the changes.

✨ Update

  1. Just execute update task.
#
# on nixos
#

# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# execute update task
cargo make wsl.update

🍎 Darwin

🌠 Initialize

  1. Install nix following here.

  2. Install nix-darwin following here.

  3. Install homebrew following here.

  4. 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
  1. Enter nix-shell with necessary packages.
# enter nix-shell
nix-shell -p cargo cargo-make ghq git home-manager
  1. Clone this repository and change the directory.
# clone this repository and change the directory
ghq get yanosea/yanoNixFiles && cd ghq/github.com/yanosea/yanoNixFiles
  1. Execute initialize task.
# execute initialize task
cargo make darwin.init
  1. 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
  1. Install command line developer tool.
# install command line developer tool
xcode-select --install
  1. Then, you got a new Darwin × Nix environment ;)

🔧 Edit config and install new packages

  1. Edit your config in yanoNixFiles repository.
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# then, edit config files or pkglist
  1. Execute install task.
# execute apply task
cargo make darwin.install
  1. If there were no issues, commit, push the changes.

✨ Update

  1. Just execute update task.
# change the directory
cd ghq/github.com/yanosea/yanoNixFiles
# execute update task
cargo make darwin.update

📚 Refferences

I appreciate a lot to all the following articles and repositories🙏

❄️ nix

📄 articles

🗂 repos