NixOS beginner guide

Vimjoyer
1 Jul 202307:37

Summary

TLDRこのビデオスクリプトでは、最近人気急上昇しているNix OSというディストリビューションを紹介しています。Nix OSは「新しいArch Linux」と呼ばれているほどの注目を集めており、宣言型、不変性、再現性、そして壊れないという利点を持ちます。ビデオでは、Nix OSの特徴を初心者にも理解しやすく解説し、システム設定の変更方法やインストールプロセスを紹介しています。また、Nix OSのパッケージ管理システムと言語の特徴も触れ、80,000以上のパッケージが利用可能であることや、Nix flakesを使ったより高度な設定方法についても言及しています。

Takeaways

  • 🌟 NixOSは最近人気を集めているディストリビューションで、Arch Linuxと比較されることもある。
  • 🔄 NixOSの利点として宣言性、不変性、再現性、壊れにくい性質が挙げられる。
  • 📝 宣言性は、システム設定をコマンドを一つずつ打つのではなく、設定ファイルを編集することで実現する。
  • 🖥️ NixOSでは、システム全体の設定を一つの設定ファイルに記述し、システムを再構築する。
  • 🔄 再現性により、同じ設定ファイルを別のコンピュータに適用して同じ環境を再現できる。
  • 🔧 システムの壊れを心配せずに、いつでも新しいビルドを適用できる。
  • 🛠️ システムの設定は簡単に変更でき、設定ファイルの変更は他のディストリビューションと比べて簡単。
  • 🔄 NixOSのインストールプロセスはcalamarisを使用し、デスクトップ環境やキーボードレイアウト、パーティションの場所を選択する。
  • 🛑 システムの更新後も、設定が壊れる心配がないため、安心して仕事に使用できる。
  • 🔍 NixOSのパッケージはsearch.nixsource.orgで検索でき、80,000以上のパッケージが利用可能。
  • 🔄 チャンネルの更新が必要で、それ以外は宣言的な方法で管理することができる。

Q & A

  • NixOSとはどのようなディストリビューションですか?

    -NixOSは、宣言型、不変性、再現性、そして壊れない性という特徴を持つLinuxディストリビューションです。

  • NixOSの「宣言型」とは何を意味しますか?

    -「宣言型」とは、システムの設定を命令的に変更するのではなく、設定ファイルを直接編集し、システム全体を再構築することでシステムを設定するというアプローチです。

  • NixOSにおける「不変性」とはどのような概念ですか?

    -「不変性」とは、システムの変更が永続的に保存されるため、古いバージョンのシステムをいつでも復元できるという特徴です。

  • NixOSの「再現性」とは何を意味していますか?

    -「再現性」とは、同じ設定ファイルを使って同じシステムを再構築できるという性質です。これにより、環境の再現が容易になります。

  • NixOSの「壊れない性」とはどのような利点がありますか?

    -「壊れない性」とは、システムの更新や再構築が失敗しても、古いバージョンのシステムに戻ることができるため、ダウンタイムが発生しないという利点があります。

  • NixOSでシステム設定を変更するにはどうすればよいですか?

    -NixOSでは、設定ファイル`/etc/nixos/configuration.nix`を編集し、変更を適用するために`sudo nixos-rebuild switch`コマンドを使用します。

  • NixOSのインストールプロセスで何が行われますか?

    -NixOSのインストールでは、カラマリ(Calamaris)を使用してデスクトップ環境、キーボードレイアウト、パーティションの場所を選択し、ネットワーク接続が必要です。

  • NixOSでパッケージを管理する方法は何ですか?

    -NixOSでは、`nix-env`コマンドを使用してパッケージを管理しますが、通常は設定ファイルにパッケージを定義し、システムの再構築で変更が適用されます。

  • NixOSの設定ファイルはどのような形式で記述されていますか?

    -NixOSの設定ファイルは`.nix`という拡張子の持つファイルで、JSONに似た形式で記述されていますが、関数などの追加要素も含まれています。

  • NixOSのチャンネルとは何で、どのように更新しますか?

    -NixOSのチャンネルは、システムとパッケージのバージョンを管理するもので、`nix-channel --update`コマンドを使用して更新します。

  • NixOSの設定を変更した後、すぐに反映されるのでしょうか?

    -設定を変更後、`sudo nixos-rebuild switch`コマンドを実行することで、新しい設定が適用されシステムが再構築されますが、パッケージのバージョンはチャンネルが更新されるまで変わりません。

Outlines

00:00

🌟 NixOSの特長と導入の理由

NixOSは最近注目を集めたディストリビューションで、新しいArch Linuxと呼ばれることもあります。NixOSは他のディストリビューションとの違いは何でしょうか?また、NixOSに切り替えることのメリットは何でしょうか?この段落では、NixOS初心者が始める前に知っておくべきいくつかの用語について説明します。NixOSの特徴として宣言性、不変性、再現性、壊れない性があります。特に宣言性は、通常のデスクトップOSとは異なり、システム全体の設定を一つの設定ファイルで宣言することで、変更履歴を追う必要がなく、システムの再現性や管理が容易になります。また、NixOSではシステムの壊れに悩む必要がなく、いつでも前のバージョンに戻すことができます。

05:00

🛠️ NixOSのインストールと設定の変更

この段落では、NixOSのインストールプロセスと設定の変更方法について説明しています。インストールにはcalamarisを使用してデスクトップ環境、キーボードレイアウト、パーティションの場所を選択しますが、これらの設定は後から変更可能です。また、swapファイルの有効化やフリーソフトウェアの選択も重要です。インストールにはネットワーク接続が必要です。設定の変更はターミナルから行い、'/etc/nixos'ディレクトリにある設定ファイルを編集します。NixOSはパッケージマネージャーであり、プログラミング言語でもあります。設定ファイルはJSONに似た形式で、関数などの機能も持っています。設定を変更後、'sudo nixos-rebuild switch'コマンドで新しい設定を適用します。また、NixOSには8万以上のパッケージが利用可能で、バージョン管理もされていますが、チャンネルの更新が必要になります。

Mindmap

Keywords

💡NixOS

NixOSは、LinuxベースのUnix-likeのオペレーティングシステムです。このシステムは、宣言型の設定管理とソフトウェアのバージョン管理を特徴としており、安定性と再現性を提供します。ビデオでは、NixOSの利点を紹介し、特にデスクトップ環境での使いやすさを強調しています。例えば、ビデオではNixOSの設定ファイルを変更することで、システム全体の設定を簡単に変更できるという利点が説明されています。

💡宣言型(Declarative)

宣言型とは、システムの最終的な状態を指定するプログラミングパラダイムです。NixOSでは、設定ファイルにシステムの望ましい状態を記述し、システムはそれに従って自動的に設定を適用します。ビデオでは、これによりユーザーは変更履歴を追う必要がなく、システムの再現性や管理が容易になるという利点が強調されています。

💡不変性(Immutability)

不変性は、オブジェクトが変更されない性質を指します。NixOSでは、ソフトウェアのバージョンが不変であるため、特定のバージョンのソフトウェアを壊れない状態で維持できます。ビデオでは、システムの再ビルド時に古いバージョンのソフトウェアが維持される様子が説明されており、これによりシステムの安定性が確保されます。

💡再現性(Reproducibility)

再現性とは、同じ手順を実行することで同じ結果を得られる性質です。NixOSでは、設定ファイルを使えば同じシステムを再構築できるため、再現性が高くなります。ビデオでは、NixOSのこの特性が強調されており、ユーザーは同じ設定を別のコンピュータに適用して同じ環境を簡単に構築できると説明されています。

💡アンブレイク性(Unbreakability)

アンブレイク性は、システムが壊れることのない性質を指します。NixOSでは、システムの変更が宣言型であるため、壊れた状態にならないことが保証されています。ビデオでは、この特性が挙げられており、システムの安定性と信頼性を高めるためにNixOSを選択する理由として紹介されています。

💡Calamaris

Calamarisは、NixOSのインストールプロセスを簡素化するツールです。ビデオでは、Calamarisを使ってデスクトップ環境、キーボードレイアウト、パーティションの場所を選択する様子が紹介されています。これはNixOSのインストールを容易にし、ユーザーフレンドリーな環境を提供するものです。

💡スワップファイル(Swap File)

スワップファイルは、物理メモリが不足したときに仮想メモリとして使用される特別なファイルです。ビデオでは、NixOSのインストール時にスワップファイルを有効にすることを提案しています。これはシステムの柔軟性を高め、メモリの管理を容易にするものです。

💡nixos-rebuild

nixos-rebuildは、NixOSのシステムを再ビルドするためのコマンドです。ビデオでは、設定ファイルに加えた変更を適用するためにこのコマンドを使用する様子が説明されています。これにより、システムの更新やパッケージのインストールを簡単に行うことができます。

💡search.nixsource.org

search.nixsource.orgは、NixOSで使用可能なパッケージを検索するウェブサイトです。ビデオでは、このサイトを使用してNixOSで利用可能な8万以上のパッケージを探索することができると紹介されています。これはユーザーが必要なソフトウェアを見つけるのを助ける有用なリソースです。

💡Nix Flakes

Nix Flakesは、NixOSにおける新しい機能で、宣言型の設定管理をさらに強化するものです。ビデオでは、Nix FlakesがNixOSの宣言型方式の欠点を補完し、より高度な設定管理を実現することができると触れています。これはNixOSの高度なユーザーにとって興味深いトピックです。

Highlights

Mixers is a distribution that has gained a lot of traction recently.

Referred to as a 'golden' new Arch Linux.

Benefits of switching to Mixers include declarativity, immutability, reproducibility, and unbreakability.

NixOS is mind-blowing and offers a different approach to desktop operating systems.

Declarative approach means configuring the system in a way similar to dot files but applied to the whole system.

You declare packages, system services, hardware settings, and drivers directly in the configuration file.

NixOS allows you to rebuild the system without remembering the changes made.

Configuration can be easily pulled onto another computer for a consistent system.

NixOS managed systems ensure the same version of software across multiple computers.

System updates in NixOS do not break the system, providing a fresh build with only declared packages.

Previous builds can be accessed in GRUB or system boot, allowing rollback if needed.

NixOS is suitable for a work machine due to its reliability and lack of system failure.

Calamaris is used for initial setup including desktop environment, keyboard layout, and partition locations.

NixOS allows easy switching between different desktop environments without conflicts.

NixOS configuration can be modified by editing the 'configuration.nix' file.

Packages are defined in the configuration file rather than installed using package managers like Pacman.

NixOS rebuild and switch commands apply new configurations to the system.

Over 80,000 packages are available for NixOS through search.nixsource.org.

NixOS channels need to be updated separately to get the latest package versions.

NixOS flakes are a feature that addresses the issue of updating channels separately.

NixOS is an amazing distribution with many advantages not fully covered in the video.

Transcripts

play00:00

mixers is a distribution that has gained

play00:02

a lot of traction recently you might

play00:05

have even heard of it referred to as a

play00:07

golden quote new Arch Linux but how is

play00:10

it different from any other distro what

play00:12

benefits do I get from switching to it

play00:14

you might ask

play00:15

I'm going to answer these and other

play00:17

questions that a Nix OS beginner should

play00:19

know before getting started I've been

play00:21

using this Beast for around half a year

play00:23

now and I must say that it is absolutely

play00:25

mind-blowing

play00:27

here I have compiled a small list of

play00:29

terms that you might want to know about

play00:31

NYX OS so you can justify your mindless

play00:33

distro hoping but in all honesty those

play00:36

are some pretty good reasons to switch

play00:38

they include declarativity immutability

play00:41

reproducibility and unbreakability we

play00:45

are going to talk about them now

play00:47

my favorite out of all of them is

play00:49

declarativity usually when you use any

play00:52

desktop operating system you configure

play00:54

it in an imperative way this means that

play00:56

you slowly change your system

play00:58

chaotically until you are satisfied with

play01:00

the result nixos takes an approach more

play01:03

similar to your dot files but applies it

play01:05

to whole system you declare packages

play01:07

system disservices Hardware settings and

play01:10

drivers directly in the configuration

play01:12

file and then rebuild the system this

play01:15

means that you don't have to remember

play01:16

what changes you did and Globe other

play01:18

people on the forums about your broken

play01:19

desktop declarative approach also means

play01:22

that you can easily pull your

play01:24

configuration on another computer and

play01:26

practically get the same system wherever

play01:28

you go with some minor tweaks and

play01:30

adjustments you can even manage a whole

play01:31

Fleet of systems without worrying that

play01:33

one will lag behind however for a Linux

play01:36

desktop enthusiasts like me it means

play01:38

that my whole two computers will have

play01:40

the same version of veeam

play01:42

because of how Nexus is managed no

play01:44

longer you need to worry about your

play01:46

system breaking each time you rebuild

play01:47

you get a fresh new build with only the

play01:50

stuff you declared all other system

play01:52

versions stay on your drive until you

play01:54

explicitly removed and can be accessed

play01:56

while your computer is loading in grub

play01:58

or system debut

play02:02

what this means is if you were to

play02:04

accidentally remove some important stuff

play02:06

from your configuration or just leave

play02:09

new version of packages are incompatible

play02:11

with your Hardware you can go back to

play02:13

previous build until the problem gets

play02:15

resolved on its own or if you fix it for

play02:18

me it was a breath of fresh air as my

play02:20

previous Arch Linux system although

play02:22

being quite stable it sometimes cause

play02:24

inconveniences after updates with Nexus

play02:27

I'm not afraid to put it on my work

play02:29

machine because I know that it will

play02:31

never fail me

play02:33

now in the background you can see an

play02:34

Express installation process here the

play02:37

calamaris is used for selecting your

play02:39

preferred desktop environment keyboard

play02:40

layout and partition locations but keep

play02:43

in mind that all of this is very trivial

play02:45

to change later in configuration file

play02:47

unlike other distros you can go between

play02:49

KD and genome every 5 minutes if you

play02:51

like and you will not suffer from both

play02:53

de trying to override each other's

play02:55

settings

play02:56

also make sure to enable swap file and

play02:59

pick the unfree software option

play03:00

installation requires network connection

play03:03

so also keep that in mind and during the

play03:05

final step it might get stuck on exactly

play03:07

46 like I've had here but it's nothing

play03:10

to worry about just wait

play03:40

so now I am going to show you how do you

play03:43

actually modify your Nix osc

play03:45

for this you're gonna open a terminal

play03:49

this virtual machine has gnome so I'm

play03:51

going to open the node terminal

play03:54

and you have to navigate into slash Etsy

play03:57

slash NYX OS with following command

play04:01

and if we write LS as you can see there

play04:03

are two files configuration.nics and

play04:05

Hardware configuration.nix

play04:07

NYX is a package manager operating

play04:09

system and also a language so this is

play04:13

pretty weird but for purposes of this

play04:15

video you can just think of dot Nix

play04:17

extension as a Json file with some minor

play04:19

additions like functions

play04:21

so if we open it with sudo edit

play04:24

because it is located in Etsy

play04:29

we are gonna see that we have Nano by

play04:31

default and this here is parameters for

play04:35

our operating system you do not have to

play04:37

think much of them and down here is the

play04:40

operating system configuration itself

play04:43

here you can see time zone that we

play04:44

defined in the beginning with calamaris

play04:46

and if we scroll down

play04:49

X server is here here

play04:52

services.printing.enable enables the

play04:54

cops service pretty good also sound so

play04:58

everything that you would need on a

play05:00

standard desktop operating system you

play05:01

already have defined here but what we

play05:04

want to check right now is here

play05:07

environment.system packages

play05:09

unlike Ubuntu or Arch Linux you do not

play05:12

have to use opt for Pacman to install

play05:14

packages you just Define them here so

play05:18

for example for me I want to uncomment

play05:20

this theme here you're also gonna have

play05:22

it here the developers put it there and

play05:25

also I added here before LF so those two

play05:29

packages that I want to install I'm

play05:31

going to click Ctrl o to write

play05:34

and then Ctrl X to exit

play05:37

now with sudo NYX OS

play05:40

rebuild

play05:41

switch

play05:45

I'm going to apply the new configuration

play05:47

of the system

play05:54

here as you can see it was successfully

play05:56

replaced

play05:57

and if I write

play05:59

beam

play06:01

as you can see everything works I'm

play06:03

actually in the Vim text editor and if

play06:06

we were to check LF as you can see it

play06:07

also works so everything is perfect

play06:10

everything is fine the system is updated

play06:11

to the newest version and now in our

play06:14

bootloader we are gonna see a new entry

play06:17

appeared which is the new version of the

play06:19

system before we head first one now we

play06:22

will have two of them and you are gonna

play06:23

automatically switch to the second one

play06:25

after reloading with switch

play06:29

to find out which packages are actually

play06:31

available for nixos navigate to this

play06:33

amazing site right here

play06:35

search.nixsource.org the link is going

play06:37

to be in the description and as you can

play06:39

see there are over 80 000 packages

play06:40

available for Linux some even for Mac OS

play06:43

Darvin

play06:44

keep in mind that even after rebuilding

play06:47

your system your packages will not

play06:49

update their versions because they are

play06:51

actually tied to a channel and channel

play06:53

needs to be updated separately

play06:55

updating channels separately kind of

play06:58

goes against Nexus declarative way so if

play07:01

you want to go and dive deep into the

play07:03

Nexus Rabbit Hole I advise you to sooner

play07:06

or later check NYX flakes which fix this

play07:09

problem the command that updates your

play07:11

dick's Channel version is going to be in

play07:13

the description as well as the link to

play07:15

this website

play07:16

now to sum up I think Nexus is an

play07:19

amazing distribution and we have not

play07:20

even covered a fraction of its

play07:22

advantages

play07:23

if you want to see a video about going

play07:25

deeper into configuring it about Nick's

play07:27

flakes or even making a declarative

play07:29

programming environments let me know so

play07:32

like And subscribe to the channel and

play07:33

maybe I will not abandon it for another

play07:35

year

Rate This

5.0 / 5 (0 votes)

Related Tags
NixOSLinux初心者向け設定宣言型不変性再現性アンブレイク性カスタマイズソフトウェア管理
Do you need a summary in English?