### Build NixOS ISO from NixOS in one line : ```shell= nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=iso.nix ``` -A is the action, we're telling it to build the iso -I is the configuration file for it (capital eye -> I) ### Virtual Box NixOS iso : nixos-gnome-23.05.2084.08700de174b-x86_64-linux 200GB of Storage 6000MB of RAM ```shell= [ganitak@nixos:/]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 150G 0 disk ├─sda1 │ 8:1 0 512M 0 part /boot ├─sda2 │ 8:2 0 140.7G 0 part /nix/store │ / └─sda3 8:3 0 8.8G 0 part [SWAP] sr0 11:0 1 2.3G 0 rom /run/media/ganitak/nixos-gnome-23.05-x86_64 [ganitak@nixos:/]$ nix-shell -p [ganitak@nixos:/]$ nix-shell -p [nix-shell:/]$ ll total 56 drwxr-xr-x 2 root root 4096 Jul 30 19:36 bin drwxr-xr-x 4 root root 4096 Jan 1 1970 boot drwxr-xr-x 19 root root 3380 Jul 30 19:51 dev drwxr-xr-x 28 root root 4096 Jul 30 19:36 etc drwxr-xr-x 3 root root 4096 Jul 30 19:12 home drwx------ 2 root root 16384 Jul 30 18:34 lost+found drwxr-xr-x 4 root root 4096 Jul 30 18:36 nix dr-xr-xr-x 205 root root 0 Jul 30 19:36 proc drwx------ 4 root root 4096 Jul 30 19:37 root drwxr-xr-x 24 root root 620 Jul 30 19:51 run drwxr-xr-x 2 root root 4096 Jul 30 19:12 srv dr-xr-xr-x 13 root root 0 Jul 30 19:36 sys drwxrwxrwt 12 root root 4096 Jul 30 20:09 tmp drwxr-xr-x 3 root root 4096 Jul 30 19:12 usr drwxr-xr-x 9 root root 4096 Jul 30 19:36 var ``` Flatpak has been mainly driven by Alex Larsson, with some help from Matthias Clasen, David King, and others. https://www.socallinuxexpo.org/sites/default/files/presentations/Flatpak-Scale-15x.pdf 2017 ### Linux systemd is the “init” process of the system (i.e. PID 1) **To reboot the system, run** ``` $ reboot ``` which is equivalent to systemctl reboot. Alternatively, you can quickly reboot the system using **kexec** - which bypasses the BIOS by directly loading the new kernel into memory: Alternitively you can use **systemctl kexec** ### Control Groups To keep track of the processes in a running system, systemd uses control groups (**cgroups**). A control group is a set of processes - **used to allocate resources** such as **CPU, memory** or **I/O bandwidth**. There can be multiple control group hierarchies, allowing each kind of resource to be managed independently. The command **systemd-cgls** lists all control groups in the systemd hierarchy, which is what systemd uses to keep track of the processes belonging to each service or user session: ``` $ systemd-cgls ``` Install Home Manager in /etc/nixos/configuration.nix ```bash nixpkgs.config.packageOverrides = pkgs: { home-manager = pkgs.home-manager.override { enable = true; }; }; ``` #### Update your Nix package definitions by running the following command: ```bash sudo nix-channel --update ``` Install Vim using the Nix package manager with the following command: ```bash nix-env -iA nixpkgs.vim ``` error: attribute 'nixpkgs' in selection path 'nixpkgs.vim' not found To use Nixpkgs repositories effectively on NixOS, you mainly need a good understanding of Nix and NixOS concepts. Here are the prerequisites: Nix Package Manager: Ensure you have Nix installed on your NixOS system. Nix is the package manager used to manage and install packages from Nixpkgs. To install Nix on NixOS, it typically comes pre-installed. However, if you need to install it manually, you can run: bash sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos sudo nix-channel --update Note: You may choose a different channel, depending on your stability preferences. Understanding Nix Concepts: Familiarize yourself with the core concepts of Nix, such as derivations, store paths, expressions, and how the Nix store works. Understanding these concepts will help you work with Nixpkgs and write Nix expressions more effectively. Nixpkgs Repository: The Nixpkgs repository contains a vast collection of packages and configuration files for NixOS. On NixOS, the Nixpkgs repository is typically located at /nix/var/nix/profiles/per-user/root/channels/nixos. Nix Channels: NixOS has the nixos channel enabled by default, which provides the stable version of Nixpkgs. You can also enable other channels (e.g., nixpkgs-unstable for more recent packages) by modifying your /etc/nixos/configuration.nix file. Channels are used to access predefined sets of packages maintained by the Nix community. NixOS Configuration: On NixOS, you manage system configurations using the /etc/nixos/configuration.nix file. It is essential to have a basic understanding of NixOS configuration options and how to modify them to customize your system. NixOS Command-Line Tools: Familiarize yourself with NixOS command-line tools like nixos-rebuild, which is used to build and switch system configurations. By having these prerequisites in place, you can effectively use Nixpkgs repositories on NixOS to manage packages and configurations on your system. You can refer to the official Nix documentation and NixOS documentation for more detailed information and guides on how to use Nix and Nixpkgs effectively on NixOS.