NixOS as a desktop/ja: Difference between revisions

Haruki7049 (talk | contribs)
Created page with "== インストール =="
 
FuzzyBot (talk | contribs)
Updating to match new version of source page
 
Line 1: Line 1:
<languages/>
<languages/>
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
NixOS can be used for many purposes. If you want to use it as a primary desktop operating system for your daily use (either on bare metal or as a [https://twitter.com/mitchellh/status/1346136404682625024 secondary VM]), this page is for you. Even if your ambitions are to use NixOS in the cloud or on specially configured servers, you may want to start with the lessons outlined here in order to get more generally familiar with the Nix ecosystem.
[[NixOS]] is a versatile operating system suitable for a wide range of use cases. This page is intended for users who wish to run NixOS as their primary desktop environment, either on physical hardware or within a virtual machine. Additionally, users planning to deploy NixOS in [[NixOS friendly hosters|cloud]] environments or on specialized server infrastructure may find it helpful to begin with the concepts and practices introduced here, as they provide a useful foundation for working within the broader [[Nix ecosystem]].
</div>
</div>


Line 8: Line 8:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Wiki method ===
Refer to [[NixOS Installation Guide]] to get started. Keep in mind that, for a desktop installation, you will probably want to make sure you start with at least 30 GiB of available disk space to allow for the [[:Category:Desktop environment|desktop environments]], [[:Category:Web Browser|web browsers]], and other [[:Category:Applications|graphical applications]], that would be typical of daily use. 15 GiB might be enough for a fairly bare-bones setup.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
If you prefer reading, see [[NixOS Installation Guide]] to get started. For a well presented video option, see video guide section immediately below. Keep in mind that, for a desktop installation, you will probably want to make sure you start with at least 30 GiB of available disk space to allow for the desktop environments (e.g. GNOME, KDE, or XFCE), browsers (e.g. Firefox), and other graphical applications (e.g. VSCode) that would be typical of daily use. 15 GiB might be enough in a pinch for a fairly bare-bones setup.
== Managing your configuration ==
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
As described in the [[Overview of the NixOS Linux distribution#Declarative Configuration]], NixOS is designed to be configured declaratively. This means the entire system configuration, including installed packages, system services, kernel parameters, and user accounts is defined in configuration files, typically in <code>/etc/nixos/configuration.nix</code>. These settings can then be applied consistently and reproducibly across machines.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
The process for managing your configuration is documented in the {{NixOS Manual|name=NixOS official manual|anchor=#ch-configuration}}.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
=== System Configuration ===
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Video guide ===
{{main|NixOS system configuration}}
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
For a visual guide, see [[Wil T Nix Guides]]. The [[Wil_T_Nix_Guides#NixOS_Installation_Guide|second video]] is a concise installation guide. This 8-part series, produced in early 2021, also covers all the basics of using NixOS as a desktop and configuring it to your liking.
The primary configuration file, <code>/etc/nixos/configuration.nix</code>, defines system-wide settings. This includes options like enabling services, managing system users, setting hardware options, and specifying installed packages. Changes are applied with:
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Managing your configuration ==
<syntaxhighlight lang="console">
# nixos-rebuild switch
</syntaxhighlight>
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
=== User configuration with Home Manager ===
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
For managing per-user configurations such as application preferences, command-line tools, and dotfiles, [[Home Manager]] provides a convenient, declarative approach. It allows users to define which programs should be installed and how they should be configured, without needing to include those settings in the system-wide [https://nixos.org/manual/nixos/stable/#sec-changing-config configuration.nix].
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
Home Manager can be used independently of the system configuration and works with both traditional setups and newer [[Flakes]]-based configurations.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
=== With Flakes ===
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
For users looking for a more streamlined and reproducible way to manage NixOS configurations, the [[Flakes]] feature has been gaining popularity within the community. While Flakes introduce some new concepts compared to traditional workflows, many users find them a convenient and organized approach to managing system and development configurations.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
Refer to [[NixOS system configuration#Defining NixOS as a flake]] for details on getting started.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
== Beyond initial setup ==
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
Once your basic NixOS installation is complete and functional, you can further customize your system with a variety of optional configurations tailored for desktop use. For a list of recommended initial system configurations, see [[NixOS Installation Guide#NixOS configuration]].
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
It is possible to manage your entire configuration using the methods documented in the [https://nixos.org/manual/nixos/stable/index.html NixOS official manual]. However, most community members who use NixOS on the desktop prefer to manage their user configurations (e.g. "dotfiles") using [[Home Manager]] (citation needed). Home Manager is a user oriented tool for declaring what you want installed and how you want it configured, and thus would be used in lieu of most settings you would otherwise put into a [https://nixos.org/manual/nixos/stable/#sec-changing-config configuration.nix] or through [[FAQ#How_can_I_manage_software_with_nix-env_like_with_configuration.nix.3F|nix-env]]
Common configuration areas include:
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Video guide ===
==== Desktop Environments ====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Wil T's guides are about an even mix of:
Install and configure full-featured environments such as [[GNOME]], [[KDE Plasma]], or [[Xfce]].
# Hands-on bootstrapping to get to being able to very capably manage your system using Home Manager, git versioning, and eventually Flakes.
# Conceptual overviews and general exposition of the Nix ecosystem, community, and available resources.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
The [[Wil_T_Nix_Guides#NixOS_Installation_Guide|second video]], starting from about 27 minutes in, is also an introduction to and guide to setting up Home Manager.
See [[:Category:Desktop environment]] for a full list.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Modularizing your configuration ==
==== Window Managers ====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== With NixOS Modules ===
Set up lightweight or tiling window managers like [[i3]], [[Sway]], [[Hyprland]], or [[xmonad]].
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
configuration.nix is an instance of a [[NixOS modules|NixOS module]], which makes it easy to break your configuration into several files. Modules can:
See [[:Category:Window managers]] for a full list.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
* Import other modules
==== Display Managers (Login Managers) ====
* Declare new options
</div>  
* Provide values for options (this is what most of your default configuration.nix does)
 
* Reference option values from other modules (via the <code>config</code> attribute passed to all modules)
<div lang="en" dir="ltr" class="mw-content-ltr">
Configure graphical session managers such as [[Gnome|GDM]], [[KDE|SDDM]], or [[LightDM]].
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
As long as you declare options for any values you want to share between modules, you can divide your configuration however you like into files that get imported, directly or transitively, by your root configuration.nix file. You can also import modules from remote sources, using functions like <code>builtins.fetchTarball</code>. See the [[NixOS modules|wiki page]] or the [https://nixos.org/manual/nixos/stable/#sec-writing-modules NixOS manual] for more information.
==== Audio Setup ====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== With Flakes ===
Enable and configure [[:Category:Audio|audio]] systems like [[PipeWire]], [[PulseAudio]], or [[ALSA]].
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
If you want a more composable<sup>[citation needed]</sup> NixOS configuration setup, the still-experimental [[Flakes]] feature is causing a lot of excitement in the community. Managing flakes requires a good basic understanding and some existing hands on experience with the Nix ecosystem.
==== Network Management ====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
==== Video guide ====
Use tools such as [[NetworkManager]] or [[systemd-networkd]] for managing [[Networking|network]] connections.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Videos [[Wil_T_Nix_Guides#Intro_to_Flakes|seven]] and [[Wil_T_Nix_Guides#Moving_NixOS_System_Configuration_into_a_Flake|eight]] of Wil T's original 8-part series are a good overview of what Flakes enable and how to get started with them.
==== Bluetooth Support ====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Beyond initial setup ==
Set up [[Bluetooth]] with blueman or other management tools.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
After you are familiar with the Nix ecosystem and have a functional desktop install of NixOS, you will likely be interested in customizations and more detailed setup.
==== Power Management ====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Learn by example ===
Configure [[laptop]] [[Power Management|battery management]], suspend, and hibernation with tools like [[Laptop#tlp|tlp]] or [[systemd]] services.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
If you are comfortable managing your system through a git repo using flakes, then there are many repositories you can learn from now!
==== Printing and Scanning ====
</div>  
</div>  


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Check out [[Comparison of NixOS setups]] for a table comparing some popular choices.
Enable [[Cups]] for printer support and tools like Sane for [[Scanners|scanning]] devices.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
See [[Configuration Collection]] for a long list within the wiki.
== Tips and tricks ==
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Additionally, the following topic searches on Github should uncover many useful examples.
=== Modularizing your configuration with modules ===
* [https://github.com/topics/nix-flake nix-flake]
* [https://github.com/topics/nixos-configuration nixos-configuration]
* [https://github.com/topics/nixos-dotfiles nixos-dotfiles]
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
{{main|NixOS system configuration#Modularizing your configuration with modules}}
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
== See also ==
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
* [[Overview of the NixOS Linux distribution]]
* [[Comparison of NixOS setups]] for a table comparing some popular choices.
* [[Configuration Collection]] for a long list within the wiki.
* [https://github.com/topics/nix-flake nix-flake], [https://github.com/topics/nixos-configuration nixos-configuration], [https://github.com/topics/nixos-dotfiles nixos-dotfiles] Github topics
* [[Wil T Nix Guides]] Youtube video format guide
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
[[Category:Desktop]]
[[Category:Desktop]]
[[Category:Guide]]
[[Category:Guide]]
[[Category:NixOS]]
</div>