How to start using Nix(OS)

Yes, or rather you don’t need to bother about updating channels yourself, as it is automatically configured via your configuration to point to the same nixpkgs as flake. You can still call <nixpkgs>, and it will just pick the nixpkgs used by flake:

To verify, we can check the path of nixpkgs in the flake:

$ nix repl
Welcome to Nix 2.13.2. Type :? for help.

nix-repl> :lf /etc/nixos
Added 13 variables.

nix-repl> "${inputs.nixpkgs}"  
"/nix/store/ckj6flydv9mmxnr5c8rj0zir5rwakqy7-source"

which is the same path that you find in your NIX_PATH (used to determine the value of a channel):

$ echo "$NIX_PATH"
/home/me/.nix-defexpr/channels:nixpkgs=/nix/store/ckj6flydv9mmxnr5c8rj0zir5rwakqy7-source:self=/nix/store/zj1sa8c6dyaxw44n8chn5yq2zcb5igbj-source

and you can double check, again interactively:

$ nix repl
Welcome to Nix 2.13.2. Type :? for help.

nix-repl> <nixpkgs>
/nix/store/ckj6flydv9mmxnr5c8rj0zir5rwakqy7-source

Yes. Actually, you don’t even need the --flake, it should automatically detect that you use flake since you created a flake.nix file.

Later, the system very busy atm…

But i have to change to /etc/nixos before? And the dot is also not needed?

When you do:

$ cd /etc/nixos
$ nix flake update

it will automatically change the /etc/nixos/flake.lock file in order to point to the latest version of nixpkgs. So you don’t need to change further /etc/nixos/configuration.nix (but you can if you want to also change your configuration): running:

$ nixos-rebuild switch

will then rebuild your configuration with the latest nixpkgs.

No, you can actually run nixos-rebuild switch anywhere in your system: without any other arguments, it will automatically:

  1. go to /etc/nixos
  2. see that a flake.nix is present, so it will switch to flake mode
  3. it will check the current hostname, and use it to build the configuration like with --flake /etc/nixos#yourcurrenthostname.

Great, thanks for your support. Step one - run nix in production can beginn. After the system has finished installing, and a reboot - all applications are there as far as i have seen… Now i have to transfer the setting to my home DELL and restore all data and settings. Most of them are in ~/.config/appname.

That will take some time and the next step is run nixos on an older notebook and at work a thinclient with only 8 GB ssd built in. :slight_smile:

Great! Good luck for your transition! (btw, putting the home in a separate partition often avoids this transfer of data and configuration, and simplifies reinstallation…) And home-manager might be helpful if you want to play with having a more declarative .config, personally I use it to configure stuff like git, gtk theme, zsh/emacs config, etc But that’s maybe more for the fun or if you often go from one laptop to another.

Ohh not so much space here. You might want to use something like a zfs file system (possibly shared between multiple hard drives?) with compression enabled to save space. You can also enable store optimization in nix, either automatically with nix.optimise.automatic = true; (runs like once per day?) or with nix.settings.auto-optimise-store = true; (runs during each build, might be slower), or manually: nix-store --optimise. And garbage collect often or automatically :wink: You can also disable the documentation (like documentation.enable = false;, documentation.doc.enable = false;, documentation.nixos.enable = false;…), or start from a minimalist installation ,see How to have a minimal NixOS? - #4 by rnhmjoj for some advices.

Thats not the case. But i have on my workstations a separate /home partition. The DELL is a newer one and there i start from scratch. So the old system can stay available if something broke while playing around with nixos.

No, but on that system it needs only a browser and the virt-viewer application. The debian on that client runs out of disk one day. Now it is running with voidlinux… But that sometimes freezes. That is HP Hardware with the size of a book…

I see. The basic iso for plasma is like 2.5G so I guess it is doable. The advantage of NixOs is that is is easy to know everything that is installed at time t, so you don’t have the “oh my drive is nearly full, but I don’t remember what I installed recently that I can safely remove”. And it is fairly easy to tweaks packages compilation options if you want to disable some functionalities to save space for instance you can disable the alsa support of ffmpeg with ffmpeg.override {withAlsa=false;}, or disable wayland in firefox with something like wrapFirefox (firefox-unwrapped.override {waylandSupport=false;}) {}. You can also build a configuration on one computer and send it to another computer with nix copy… Many possible options.

Until now i have used XFCE4 as desktop for low power systems. Maybe that has a smaller footprint. Btw. i’m building now the home DELL…
I’m running anydesk and rustdesk as remote desktop solution. I hope that nixos has X11 as default, not wayland…?!

Yeah xfce is lightweight, I also really liked lxqt recently that I find more stable and nice looking. Some people also use more minimalist solutions like cage I think when they only want a browser to run, just saw this today Flake-based Web Kiosk Project.

You can choose to run x11 or wayland. I think the default depends on the DE, for instance for kde plasma it is x11 https://github.com/NixOS/nixpkgs/blob/6723fa4e4f1a30d42a633bef5eb01caeb281adc3/nixos/modules/services/x11/desktop-managers/plasma5.nix#L410 To find this file I used search.nixos.org and typed plasma in the Options tab.

OK, tomorrow i will try to import the settings for rustdesk and anydesk

Btw, i copied now the partition from my radio system to the 2nd disk. Tomorrow i will try to boot it…

Good night…

Before booting you will certainly need to regenerate the bootloader to detect the new partition.

OK, good morning… > Bootloader - NixOS Wiki

[wolf@daw:~]$ [ -d /sys/firmware/efi/efivars ] && echo “UEFI” || echo “Legacy”
UEFI
[wolf@daw:~]$ sudo nixos-rebuild boot
[sudo] Passwort für wolf:
building the system configuration…
[wolf@daw:~]$

That has nothing changed. But the hardware bootloader from F12 menu can see the disk but won’t boot. Maybe a have to repair that “disk” first… For example with an boot repair that writes only to the 2nd disk…

It works after changing this: :wink:

Bootloader.
#boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.grub.enable = true;
boot.loader.grub.device = “nodev”;
boot.loader.grub.useOSProber = true;
boot.loader.grub.efiSupport = true;

sudo nixos-switch boot might not regenerate the bootloader, it just means that the new derivation should be used only during the next boot, I think you need sudo nixos-rebuild --install-bootloader boot. But if grub works for you, cool.

yes, that is the known stile, and that is ok. So i can copy with clonezilla every os to a separate partition and it will automaticaly detected… Nice
Btw tobias… where are u from??

France! I guess you are from Germany?

yes, in the north/west on the northsea at the river ems…

Question about Teamviewer. Irt needs to activate the daemon. But i need Teamviewer only once a month.

services.teamviewer.enable

On Debian i could enable and disable a daemon by hand only when i need it. What about Nixos?

The option you show is doing a few things (you can check here):

  • it installs teamviewer
  • it creates a systemd service teamviewerd
    In particular, you can use systemctl status teamviewerd.service to check the status of the daemon, or sudo systemctl {start/stop} teamviewerd to start/stop it as usual:
╰─❯ systemctl status teamviewerd.service                                                                                                                                                                       ─╯
● teamviewerd.service - TeamViewer remote control daemon
     Loaded: loaded (/etc/systemd/system/teamviewerd.service; enabled; preset: enabled)
     Active: active (running) since Sun 2024-01-07 11:34:53 CET; 4 days ago
    Process: 2999 ExecStartPre=/nix/store/s6js9pa8s9absvqzri0lbximxmdki4md-unit-script-teamviewerd-pre-start/bin/teamviewerd-pre-start (code=exited, status=0/SUCCESS)
   Main PID: 3001 (.teamviewerd-wr)
         IP: 0B in, 0B out
         IO: 16.0K read, 1.3M written
      Tasks: 21 (limit: 18952)
     Memory: 3.5M
        CPU: 4min 19.938s
     CGroup: /system.slice/teamviewerd.service
             └─3001 /nix/store/vsvdbxwhb7an69r3h0sw8rr609ws3ywv-teamviewer-15.35.7/bin/teamviewerd -f

janv. 07 11:34:53 bestos systemd[1]: Starting TeamViewer remote control daemon...
janv. 07 11:34:53 bestos systemd[1]: Started TeamViewer remote control daemon.


╭─    ~ ······································································································································································· 4 ✘  5s   15:25:56  ─╮
╰─❯ sudo systemctl stop teamviewerd.service                                                                                                                                                                    ─╯
[sudo] Mot de passe de leo : 

╭─    ~ ········································································································································································· ✔  5s   15:26:03  ─╮
╰─❯ systemctl status teamviewerd.service                                                                                                                                                                       ─╯
○ teamviewerd.service - TeamViewer remote control daemon
     Loaded: loaded (/etc/systemd/system/teamviewerd.service; enabled; preset: enabled)
     Active: inactive (dead) since Thu 2024-01-11 15:26:03 CET; 2s ago
   Duration: 4d 3h 51min 9.926s
    Process: 2999 ExecStartPre=/nix/store/s6js9pa8s9absvqzri0lbximxmdki4md-unit-script-teamviewerd-pre-start/bin/teamviewerd-pre-start (code=exited, status=0/SUCCESS)
    Process: 3001 ExecStart=/nix/store/vsvdbxwhb7an69r3h0sw8rr609ws3ywv-teamviewer-15.35.7/bin/teamviewerd -f (code=exited, status=0/SUCCESS)
   Main PID: 3001 (code=exited, status=0/SUCCESS)
         IP: 0B in, 0B out
         IO: 16.0K read, 1.3M written
        CPU: 4min 20.151s

janv. 07 11:34:53 bestos systemd[1]: Starting TeamViewer remote control daemon...
janv. 07 11:34:53 bestos systemd[1]: Started TeamViewer remote control daemon.
janv. 11 15:26:03 bestos systemd[1]: Stopping TeamViewer remote control daemon...
janv. 11 15:26:03 bestos systemd[1]: teamviewerd.service: Deactivated successfully.
janv. 11 15:26:03 bestos systemd[1]: Stopped TeamViewer remote control daemon.
janv. 11 15:26:03 bestos systemd[1]: teamviewerd.service: Consumed 4min 20.151s CPU time, read 16.0K from disk, written 1.3M to disk, no IP traffic.

╭─    ~ ·············································································································································································· 3 ✘  15:26:06  ─╮
╰─❯ sudo systemctl start teamviewerd.service                                                                                                                                                                   ─╯

╭─    ~ ················································································································································································ ✔  15:26:11  ─╮
╰─❯ systemctl status teamviewerd.service                                                                                                                                                                       ─╯
● teamviewerd.service - TeamViewer remote control daemon
     Loaded: loaded (/etc/systemd/system/teamviewerd.service; enabled; preset: enabled)
     Active: active (running) since Thu 2024-01-11 15:26:11 CET; 2s ago
    Process: 2395199 ExecStartPre=/nix/store/s6js9pa8s9absvqzri0lbximxmdki4md-unit-script-teamviewerd-pre-start/bin/teamviewerd-pre-start (code=exited, status=0/SUCCESS)
   Main PID: 2395202 (.teamviewerd-wr)
         IP: 0B in, 0B out
         IO: 0B read, 0B written
      Tasks: 21 (limit: 18952)
     Memory: 8.1M
        CPU: 174ms
     CGroup: /system.slice/teamviewerd.service
             └─2395202 /nix/store/vsvdbxwhb7an69r3h0sw8rr609ws3ywv-teamviewer-15.35.7/bin/teamviewerd -f

janv. 11 15:26:11 bestos systemd[1]: Starting TeamViewer remote control daemon...
janv. 11 15:26:11 bestos systemd[1]: Started TeamViewer remote control daemon.

You can also just set services.teamviewer.enable = false; when you don’t need teamviewer, and services.teamviewer.enable = true; when you need it, especially if you use teamviewer very rarely it makes sense.

But that needs a reboot then.? Or when it is set to false, i can enable it only for that session with?