1つのリポジトリで、以下3ターゲットを管理する統合Nix flakeです。
nixosConfigurations.desktop(NixOSデスクトップ)nixosConfigurations.wsl(NixOS-WSL)homeConfigurations.darwin(macOS向けHome Manager)
- Git と Nix がインストール済みであること
- Flakes が有効であること(
nix-commandとflakes) - Linuxターゲットでは root/sudo 権限があること
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- 別マシンへ導入する場合は、ハードウェア設定を更新します。
sudo nixos-generate-config --show-hardware-config > /etc/nixos/hardware-configuration.nix-
必要に応じて
hosts/desktop/default.nixのユーザー情報を変更します。home-manager.users.see2ethome.usernamehome.homeDirectory
-
対象ユーザーのローカルパスワードを事前に設定します(未設定のままGDM再起動が発生するとログイン不能になる可能性があります)。
sudo passwd see2et- 安全な順序で検証・反映します。
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-
先に NixOS-WSL のベースイメージを導入します。
-
必要に応じて
hosts/wsl/default.nixのユーザー情報を変更します。home-manager.users.nixoshome.usernamehome.homeDirectory
-
対象ユーザーのローカルパスワードを事前に設定します(sudoやログイン復旧のため)。
sudo passwd nixos- 検証・反映を実行します。
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-
flake.nixのhomeConfigurations.darwinでユーザー情報を変更します。home.usernamehome.homeDirectory
-
Home Manager を適用します。
cd /etc/nixos
nix flake check --show-trace
home-manager switch --flake .#darwinhome-manager コマンドが未導入の場合:
nix run github:nix-community/home-manager -- switch --flake .#darwincd /etc/nixos
nix build .#nixosConfigurations.desktop.config.system.build.toplevel
nix build .#nixosConfigurations.wsl.config.system.build.toplevel注: Darwin のビルド確認は実機の aarch64-darwin 環境で実施してください。
cd /etc/nixos
git pull --rebase
nix flake check --show-trace
sudo nixos-rebuild switch --flake /etc/nixos#desktop # または #wslsudo nixos-rebuild switch --profile /nix/var/nix/profiles/system --rollback