initial install yggdrasil

This commit is contained in:
Poby 2026-05-20 23:04:42 +09:00
parent 5b3f78c854
commit b538626c12
No known key found for this signature in database
7 changed files with 186 additions and 72 deletions

View file

@ -1,7 +1,7 @@
# NixOS Homelab Install Guide # NixOS Homelab Install Guide
이 문서는 `yggdrasil`, `midgard`를 NixOS installer USB에서 부팅한 뒤 이 문서는 `yggdrasil`, `midgard`를 NixOS installer USB에서 부팅한 뒤 이 repo를
이 repo를 source of truth로 사용해 최초 설치하는 절차를 설명한다. source of truth로 사용해 최초 설치하는 절차를 설명한다.
기본 원칙: 기본 원칙:
@ -85,8 +85,8 @@ installer shell이 뜨면 대상 머신 콘솔에서 root 비밀번호를 임시
sudo passwd root sudo passwd root
``` ```
이 비밀번호는 installer live environment에서만 쓰는 임시 비밀번호다. 이 비밀번호는 installer live environment에서만 쓰는 임시 비밀번호다. 설치 후
설치 후 재부팅하면 최종 NixOS 설정이 적용되고 root SSH login은 비활성화된다. 재부팅하면 최종 NixOS 설정이 적용되고 root SSH login은 비활성화된다.
SSH 서버를 시작한다. SSH 서버를 시작한다.
@ -224,7 +224,8 @@ ssh root@<YGGDRASIL_INSTALLER_IP> \
- `hardware-configuration.nix`는 대상 머신에서 생성한 값을 사용한다. - `hardware-configuration.nix`는 대상 머신에서 생성한 값을 사용한다.
- yggdrasil에서 생성한 파일을 midgard에 재사용하지 않는다. - yggdrasil에서 생성한 파일을 midgard에 재사용하지 않는다.
- disko가 `/``/boot` 파일시스템을 선언하므로 생성된 hardware config를 그대로 믿지 말고 검토한다. - disko가 `/``/boot` 파일시스템을 선언하므로 생성된 hardware config를 그대로
믿지 말고 검토한다.
`hardware-configuration.nix`에는 보통 이런 내용이 남으면 된다. `hardware-configuration.nix`에는 보통 이런 내용이 남으면 된다.
@ -243,8 +244,8 @@ hardware.cpu.intel.updateMicrocode = ...;
hardware.cpu.amd.updateMicrocode = ...; hardware.cpu.amd.updateMicrocode = ...;
``` ```
다음 항목은 `disko.nix`와 중복되거나 installer/live 환경의 값일 수 있으므로 다음 항목은 `disko.nix`와 중복되거나 installer/live 환경의 값일 수 있으므로 특히
특히 확인한다. 확인한다.
```nix ```nix
fileSystems."/" fileSystems."/"
@ -252,9 +253,9 @@ fileSystems."/boot"
swapDevices swapDevices
``` ```
이 repo에서는 `/``/boot``disko.nix`가 담당한다. swap은 `modules/swap.nix` 이 repo에서는 `/``/boot``disko.nix`가 담당한다. swap은
zram swap이 담당한다. 따라서 hardware config에 위 항목이 들어 있다면 왜 필요한지 `modules/swap.nix`zram swap이 담당한다. 따라서 hardware config에 위 항목이
확실할 때만 남긴다. 들어 있다면 왜 필요한지 확실할 때만 남긴다.
## 6. host default.nix imports 활성화 ## 6. host default.nix imports 활성화
@ -321,16 +322,18 @@ nix-instantiate --parse hosts/yggdrasil/hardware-configuration.nix >/dev/null
```bash ```bash
nix run github:nix-community/nixos-anywhere -- \ nix run github:nix-community/nixos-anywhere -- \
--flake .#yggdrasil \ --flake .#yggdrasil \
--build-on-remote \
root@<YGGDRASIL_INSTALLER_IP> root@<YGGDRASIL_INSTALLER_IP>
``` ```
워크스테이션의 Nix에서 flakes가 꺼져 있다는 에러가 나면 같은 명령에 워크스테이션의 Nix에서 flakes가 꺼져 있다는 에러가 나면 같은 명령에 experimental
experimental features를 명시한다. features를 명시한다.
```bash ```bash
nix --extra-experimental-features "nix-command flakes" \ nix --extra-experimental-features "nix-command flakes" \
run github:nix-community/nixos-anywhere -- \ run github:nix-community/nixos-anywhere -- \
--flake .#yggdrasil \ --flake .#yggdrasil \
--build-on-remote \
root@<YGGDRASIL_INSTALLER_IP> root@<YGGDRASIL_INSTALLER_IP>
``` ```
@ -583,7 +586,8 @@ ssh root@midgard
## 15. 롤백 기본 ## 15. 롤백 기본
NixOS 설정 변경 후 문제가 생기면 대상 머신에서 이전 generation으로 되돌릴 수 있다. NixOS 설정 변경 후 문제가 생기면 대상 머신에서 이전 generation으로 되돌릴 수
있다.
```bash ```bash
sudo nixos-rebuild switch --rollback sudo nixos-rebuild switch --rollback

91
flake.lock generated Normal file
View file

@ -0,0 +1,91 @@
{
"nodes": {
"disko": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1779226674,
"narHash": "sha256-wuOkjI6pRiN4sEn/EPBRnNW5cmcpvd7xtIM8y5LooAs=",
"owner": "nix-community",
"repo": "disko",
"rev": "65fb947964bd44fc0008faf77d1fcb7a9f40bb32",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1778905220,
"narHash": "sha256-ox/5IHc8uwy6UTw6N7Shp6uCHIgu/S2PsWeuXsOHSo8=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "d1686dc7d36cbd1234cb226ad6ef97e882716acb",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-25.11",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1779102034,
"narHash": "sha256-vZJZjLo513IeI8hjzHFc6TDezUd4uCE2Eq4SNO3DNNg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "687f05a9184cad4eaf905c48b63649e3a86f5433",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"disko": "disko",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"sops-nix": "sops-nix"
}
},
"sops-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1777944972,
"narHash": "sha256-VfGRo1qTBKOe3s2gOv8LSoA6Fk19PvBlwQ1ECN0Evn8=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "c591bf665727040c6cc5cb409079acb22dcce33c",
"type": "github"
},
"original": {
"owner": "Mic92",
"repo": "sops-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -20,19 +20,16 @@
}; };
}; };
outputs = outputs = inputs @ {
inputs@{
nixpkgs, nixpkgs,
disko, disko,
home-manager, home-manager,
sops-nix, sops-nix,
... ...
}: }: let
let
system = "x86_64-linux"; system = "x86_64-linux";
mkHost = mkHost = hostModule:
hostModule:
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
inherit system; inherit system;
specialArgs = { specialArgs = {
@ -60,8 +57,7 @@
hostModule hostModule
]; ];
}; };
in in {
{
nixosConfigurations = { nixosConfigurations = {
yggdrasil = mkHost ./hosts/yggdrasil; yggdrasil = mkHost ./hosts/yggdrasil;
midgard = mkHost ./hosts/midgard; midgard = mkHost ./hosts/midgard;

View file

@ -10,5 +10,11 @@
networking.hostName = "midgard"; networking.hostName = "midgard";
services.logind.settings.Login = {
HandleLidSwitch = "ignore";
HandleLidSwitchExternalPower = "ignore";
HandleLidSwitchDocked = "ignore";
};
system.stateVersion = "25.11"; system.stateVersion = "25.11";
} }

View file

@ -1,14 +1,16 @@
{ ... }: {...}: {
imports = [
{ ./hardware-configuration.nix
# Enable these imports after collecting disk IDs and generated hardware config ./disko.nix
# during the NixOS installer phase. ];
# imports = [
# ./hardware-configuration.nix
# ./disko.nix
# ];
networking.hostName = "yggdrasil"; networking.hostName = "yggdrasil";
services.logind.settings.Login = {
HandleLidSwitch = "ignore";
HandleLidSwitchExternalPower = "ignore";
HandleLidSwitchDocked = "ignore";
};
system.stateVersion = "25.11"; system.stateVersion = "25.11";
} }

View file

@ -1,10 +1,8 @@
{ ... }: {...}: {
{
disko.devices = { disko.devices = {
disk.main = { disk.main = {
type = "disk"; type = "disk";
device = "/dev/disk/by-id/REPLACE_WITH_YGGDRASIL_DISK_ID"; device = "/dev/disk/by-id/ata-SAMSUNG_MZNLN128HCGR-000_S200NYAG700346";
content = { content = {
type = "gpt"; type = "gpt";

View file

@ -1,5 +1,22 @@
{ ... }: # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ {
# TODO: Replace with generated yggdrasil hardware configuration. config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = ["ahci" "xhci_pci" "usb_storage" "sd_mod" "sdhci_pci" "rtsx_usb_sdmmc"];
boot.initrd.kernelModules = ["dm-snapshot"];
boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }