Skip to content

See2et/nixos-rice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

135 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nixos-rice

1つのリポジトリで、以下3ターゲットを管理する統合Nix flakeです。

  • nixosConfigurations.desktop(NixOSデスクトップ)
  • nixosConfigurations.wsl(NixOS-WSL)
  • homeConfigurations.darwin(macOS向けHome Manager)

Screenshots

image image

1) 事前準備

  • Git と Nix がインストール済みであること
  • Flakes が有効であること(nix-commandflakes
  • Linuxターゲットでは root/sudo 権限があること

2) /etc/nixos にクローン

sudo mv /etc/nixos "/etc/nixos.backup.$(date +%Y%m%d-%H%M%S)"
sudo git clone https://github.com/See2et/nixos-rice.git /etc/nixos
cd /etc/nixos

3) ターゲット別の導入手順

Desktop(NixOS)

  1. 別マシンへ導入する場合は、ハードウェア設定を更新します。
sudo nixos-generate-config --show-hardware-config > /etc/nixos/hardware-configuration.nix
  1. 必要に応じて hosts/desktop/default.nix のユーザー情報を変更します。

    • home-manager.users.see2et
    • home.username
    • home.homeDirectory
  2. 対象ユーザーのローカルパスワードを事前に設定します(未設定のままGDM再起動が発生するとログイン不能になる可能性があります)。

sudo passwd see2et
  1. 安全な順序で検証・反映します。
nix flake check --show-trace
sudo nixos-rebuild dry-activate --flake /etc/nixos#desktop
sudo nixos-rebuild test --flake /etc/nixos#desktop
sudo nixos-rebuild switch --flake /etc/nixos#desktop

WSL(NixOS-WSL)

  1. 先に NixOS-WSL のベースイメージを導入します。

  2. 必要に応じて hosts/wsl/default.nix のユーザー情報を変更します。

    • home-manager.users.nixos
    • home.username
    • home.homeDirectory
  3. 対象ユーザーのローカルパスワードを事前に設定します(sudoやログイン復旧のため)。

sudo passwd nixos
  1. 検証・反映を実行します。
nix flake check --show-trace
sudo nixos-rebuild dry-activate --flake /etc/nixos#wsl
sudo nixos-rebuild test --flake /etc/nixos#wsl
sudo nixos-rebuild switch --flake /etc/nixos#wsl

Darwin(macOS, Home Managerのみ)

  1. flake.nixhomeConfigurations.darwin でユーザー情報を変更します。

    • home.username
    • home.homeDirectory
  2. Home Manager を適用します。

cd /etc/nixos
nix flake check --show-trace
home-manager switch --flake .#darwin

home-manager コマンドが未導入の場合:

nix run github:nix-community/home-manager -- switch --flake .#darwin

4) ビルド確認(任意だが推奨)

cd /etc/nixos
nix build .#nixosConfigurations.desktop.config.system.build.toplevel
nix build .#nixosConfigurations.wsl.config.system.build.toplevel

注: Darwin のビルド確認は実機の aarch64-darwin 環境で実施してください。

5) 日常の更新フロー

cd /etc/nixos
git pull --rebase
nix flake check --show-trace
sudo nixos-rebuild switch --flake /etc/nixos#desktop   # または #wsl

6) ロールバック(NixOS)

sudo nixos-rebuild switch --profile /nix/var/nix/profiles/system --rollback

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published