Howto nixos: Difference between revisions
Mandulete1 (talk | contribs) |
Mandulete1 (talk | contribs) m (Protected "Howto nixos" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
||
(18 intermediate revisions by 2 users not shown) | |||
Line 78: | Line 78: | ||
configure static ip networking: | configure static ip networking: | ||
networking.networkmanager.enable = true; | networking.networkmanager.enable = true; | ||
networking.interfaces. | networking.interfaces.enp1s0.useDHCP = false; | ||
systemd.services.NetworkManager-wait-online.enable = false; | |||
networking.interfaces.enp1s0.ipv4.addresses = [ { | |||
address = "192.168.75.44"; | address = "192.168.75.44"; | ||
prefixLength = 24; | prefixLength = 24; | ||
} ]; | } ]; | ||
networking.defaultGateway = "192.168.75.1"; | networking.defaultGateway = "192.168.75.1"; | ||
networking.nameservers = [ "4.2.2.1" "4.2.2.2" ]; | networking.nameservers = [ "4.2.2.1" "4.2.2.2" ]; | ||
bridge network interface: | bridge network interface: | ||
networking.networkmanager.enable = true; | |||
networking.useDHCP = false; | networking.useDHCP = false; | ||
systemd.services.NetworkManager-wait-online.enable = false; | |||
networking.interfaces.enp1s0.useDHCP = false; | |||
networking.interfaces.br0.useDHCP = false; | |||
networking.bridges = { | networking.bridges = { | ||
"br0" = { | "br0" = { | ||
Line 180: | Line 185: | ||
'';</nowiki> | '';</nowiki> | ||
nvidia gpu drivers: | nvidia gpu drivers: | ||
hardware.opengl = { | |||
enable = true; | |||
driSupport = true; | |||
driSupport32Bit = true; | |||
}; | |||
services.xserver.videoDrivers = ["nvidia"]; | |||
boot.blacklistedKernelModules = [ "nouveau" ]; | |||
hardware.nvidia = { | |||
modesetting.enable = true; | |||
open = true; | |||
nvidiaSettings = true; | |||
package = config.boot.kernelPackages.nvidiaPackages.stable; | |||
}; | |||
for nvidia gpu legacy drivers: | |||
services.xserver.videoDrivers = [ "nvidiaLegacy390" ]; | services.xserver.videoDrivers = [ "nvidiaLegacy390" ]; | ||
services.xserver.videoDrivers = [ "nvidiaLegacy340" ]; | services.xserver.videoDrivers = [ "nvidiaLegacy340" ]; | ||
services.xserver.videoDrivers = [ "nvidiaLegacy304" ]; | services.xserver.videoDrivers = [ "nvidiaLegacy304" ]; | ||
amd gpu drivers: | amd gpu drivers: | ||
services.xserver.videoDrivers = [ "amdgpu | boot.initrd.kernelModules = [ "amdgpu" ]; | ||
services.xserver.videoDrivers = [ "amdgpu" ]; | |||
for laptop touchpads: | for laptop touchpads: | ||
services.xserver.libinput.enable = true; | services.xserver.libinput.enable = true; | ||
Line 253: | Line 270: | ||
rebuild nixos configuration: | rebuild nixos configuration: | ||
nixos-rebuild switch | nixos-rebuild switch | ||
= davinci resolve flatpak = | |||
install following packages: | |||
flatpak-builder | |||
jq | |||
git | |||
install org.freedesktop.sdk with flatpak: | |||
flatpak install org.freedesktop.Sdk/x86_64/22.08 | |||
clone repo: | |||
git clone https://github.com/vidalinux/resolve-flatpak.git | |||
get davindi resolve free available download versions: | |||
curl -o- https://www.blackmagicdesign.com/api/support/nz/downloads.json | | |||
jq -r '.downloads[] | |||
| select(.urls["Linux"] != null) | |||
| select(.urls["Linux"][0]["product"] == "davinci-resolve") | |||
| [.urls["Linux"][0].downloadTitle, .urls["Linux"][0].downloadId] | |||
| @tsv' | |||
get davinci resolve studio available download versions: | |||
curl -o- https://www.blackmagicdesign.com/api/support/nz/downloads.json | | |||
jq -r '.downloads[] | |||
| select(.urls["Linux"] != null) | |||
| select(.urls["Linux"][0]["product"] == "davinci-resolve-studio") | |||
| [.urls["Linux"][0].downloadTitle, .urls["Linux"][0].downloadId] | |||
| @tsv' | |||
edit the following file shell/download-resolve.sh change the davinci resolve version: | |||
_downloadid='34023b93d9f64d03aaf7654e2cbbb727' | |||
build the flatpak for davinci resolve free version: | |||
flatpak-builder --force-clean --repo=repo build-dir com.blackmagic.Resolve.yaml | |||
flatpak build-bundle repo resolve.flatpak com.blackmagic.Resolve | |||
build flatpak for davinci resolve studio version: | |||
flatpak-builder --force-clean --repo=repo build-dir com.blackmagic.ResolveStudio.yaml | |||
flatpak build-bundle repo resolve.flatpak com.blackmagic.ResolveStudio | |||
install davinci resolve flatpak: | |||
flatpak install resolve.flatpak | |||
uninstall davinci resolve free flatpak: | |||
flatpak uninstall com.blackmagic.Resolve | |||
uninstall davinci resolve studio flatpak: | |||
flatpak uninstall com.blackmagic.ResolveStudio | |||
= home-manager = | = home-manager = | ||
install home-manager: | install home-manager: |
Latest revision as of 22:26, 21 July 2023
configure enviroment
download nixos installation iso:
https://channels.nixos.org/nixos-23.05/latest-nixos-minimal-x86_64-linux.iso
create usb to install on physical desktop:
yay -S ventoy-bin
or install nixos on virtual machine:
mkdir /var/lib/libvirt/images/nixos -p qemu-img create -f qcow2 /var/lib/libvirt/images/nixos/nixos_disk1_100G.qcow2 100G
boot with nixos iso and login as root:
sudo su -
configure static ip network:
ip addr add 192.168.75.44/24 dev enp1s0 ip route add default via 192.168.75.1 rm -rf /etc/resolv.conf echo "nameserver 4.2.2.1" > /etc/resolv.conf echo "nameserver 4.2.2.2" >> /etc/resolv.conf
configure wireless network:
systemctl start wpa_supplicant
run wpa_cli:
wpa_cli
configure your access point:
add_network set_network 0 ssid "mywifiname" set_network 0 psk "mypassword" set_network 0 key_mgmt WPA-PSK enable_network 0
leave wpa_cli:
quit
set password to root user:
passwd root
from another machine enter via ssh to nixos installation:
ssh root@192.168.75.44
create partitions:
parted /dev/vda -- mklabel gpt parted /dev/vda -- mkpart ESP fat32 1 1GB parted /dev/vda -- set 1 esp on parted /dev/vda -- mkpart primary linux-swap 1GB 8GB parted /dev/vda -- mkpart primary ext4 8GB 100%
format partitions:
mkfs.fat -F 32 -n boot /dev/vda1 mkswap -L swap /dev/vda2 mkfs.ext4 -L nixos /dev/vda3
installing os
mount root partition on /mnt:
mount /dev/vda3 /mnt
make boot directory and mount boot partition:
mkdir /mnt/boot mount /dev/vda1 /mnt/boot
mount swap partition:
swapon /dev/vda2
generate nixos configuration file:
nixos-generate-config --root /mnt
edit configuration file /mnt/etc/nixos/configuration.nix:
{ config, pkgs, ... }: { imports = ./hardware-configuration.nix ]; boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; time.timeZone = "America/Puerto_Rico"; i18n.defaultLocale = "en_US.UTF-8"; services.xserver.enable = true; services.xserver.layout = "us"; sound.enable = true; hardware.pulseaudio.enable = true; users.users.linux = { isNormalUser = true; extraGroups = [ "wheel" "networkmanager" "virt-manager" "scanner" "lp" ]; packages = with pkgs; [ firefox tree ]; }; services.openssh.enable = true; }
configure static ip networking:
networking.networkmanager.enable = true; networking.interfaces.enp1s0.useDHCP = false; systemd.services.NetworkManager-wait-online.enable = false; networking.interfaces.enp1s0.ipv4.addresses = [ { address = "192.168.75.44"; prefixLength = 24; } ]; networking.defaultGateway = "192.168.75.1"; networking.nameservers = [ "4.2.2.1" "4.2.2.2" ];
bridge network interface:
networking.networkmanager.enable = true; networking.useDHCP = false; systemd.services.NetworkManager-wait-online.enable = false; networking.interfaces.enp1s0.useDHCP = false; networking.interfaces.br0.useDHCP = false; networking.bridges = { "br0" = { interfaces = [ "enp1s0" ]; }; }; networking.interfaces.br0.ipv4.addresses = [ { address = "192.168.75.44"; prefixLength = 24; } ]; networking.defaultGateway = "192.168.75.1"; networking.nameservers = ["4.2.2.1" "4.2.2.2"];
configure wireless network:
networking.wireless.enable = true;
on terminal execute the following command:
wpa_passphrase mywifiname mypassword
add the following configuration to your configuration.nix:
networking.wireless = { enable = true; userControlled.enable = true; networks = { mywifiname = { pskRaw = "46c25aa68ccb90945621c1f1adbe93683f884f5f31c6e2d524eb6b446642762d"; }; }; };
hostname and /etc/hosts:
networking.hostName = "nixos"; networking.extraHosts = '' 127.0.0.1 localhost 192.168.75.44 nixos '';
enable ip forwarding:
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
allow nonfree apps:
nixpkgs.config.allowUnfree = true;
configure desktop gnome:
services.xserver.displayManager.gdm.enable = true; services.xserver.desktopManager.gnome.enable = true; programs.dconf.enable = true; services.udev.packages = with pkgs; [ gnome.gnome-settings-daemon ]; environment.gnome.excludePackages = (with pkgs; [ gnome-photos gnome-tour ]) ++ (with pkgs.gnome; [ gnome-terminal gedit # text editor evince # document viewer gnome-characters ]);
configure fonts:
fonts.fonts = with pkgs; [ noto-fonts noto-fonts-cjk noto-fonts-emoji liberation_ttf fira-code fira-code-symbols mplus-outline-fonts.githubRelease dina-font proggyfonts ];
enable virtualization:
virtualisation.libvirtd.enable = true;
enable flatpak:
services.flatpak.enable = true; xdg.portal.enable = true;
enable cups server for printers:
services.printing.enable = true;
enable scanner:
hardware.sane.enable = true;
enable bluetooth:
hardware.bluetooth.enable = true;
enable podman containers:
virtualisation = { podman.enable = true; oci-containers.backend = "podman"; };
then when system boot configure flatpak repo:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
system packages:
environment.systemPackages = with pkgs; [ wget vim nano zsh file lsof virt-manager ];
intel drivers:
services.xserver.videoDrivers = [ "modesetting" ];
if you experience screen tearing no matter what, this configuration was reported to resolve the issue:
services.xserver.videoDrivers = [ "intel" ]; services.xserver.deviceSection = '' Option "DRI" "2" Option "TearFree" "true" '';
nvidia gpu drivers:
hardware.opengl = { enable = true; driSupport = true; driSupport32Bit = true; }; services.xserver.videoDrivers = ["nvidia"]; boot.blacklistedKernelModules = [ "nouveau" ]; hardware.nvidia = { modesetting.enable = true; open = true; nvidiaSettings = true; package = config.boot.kernelPackages.nvidiaPackages.stable; };
for nvidia gpu legacy drivers:
services.xserver.videoDrivers = [ "nvidiaLegacy390" ]; services.xserver.videoDrivers = [ "nvidiaLegacy340" ]; services.xserver.videoDrivers = [ "nvidiaLegacy304" ];
amd gpu drivers:
boot.initrd.kernelModules = [ "amdgpu" ]; services.xserver.videoDrivers = [ "amdgpu" ];
for laptop touchpads:
services.xserver.libinput.enable = true;
load kernel modules:
boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];
load kernel modules on initrd:
boot.initrd.kernelModules = [ "cifs" ];
firewall is enabled by default, you can open specific tcp ports:
networking.firewall.allowedTCPPorts = [ 22 ];
run the installer:
nixos-install
reboot the system:
reboot
os configuration
add unstable channel:
nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable nix-channel --update
run command without installing the package in your current session:
nix-shell -p git
verify current os configuration:
nix-shell -p nix-info --run "nix-info -m"
list current os generations:
nix-env --list-generations
command output:
1 2023-06-26 11:42:47 2 2023-06-26 11:52:57 3 2023-06-26 11:53:04 4 2023-06-26 11:53:10 5 2023-06-26 11:53:21 6 2023-06-26 11:56:23 7 2023-06-26 11:56:47 8 2023-06-26 12:11:51 9 2023-06-26 12:11:59 (current)
delete os generations:
nix-env --delete-generations 1 2 3 4 5
custom pkgs
clone git repo:
git clone https://github.com/NixOS/nixpkgs.git /usr/local/nixpkgs
edit /etc/nixos/configuration.nix to import custom module:
{ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix (import "/usr/local/nixpkgs/nixos/modules/services/admin/nomachine.nix") ];
disable module on repo:
disabledModules = [ "pkgs/tools/admin/nomachine-client/default.nix" ];
edit /etc/nixos/configuration.nix to import custom package:
nixpkgs.config = { allowUnfree = true; packageOverrides = pkgs: { nomachine = pkgs.callPackage (import "/usr/local/nixpkgs/pkgs/tools/admin/nomachine/default.nix") {}; }; }; services.nxserver.enable = true;
add nomachine to environment.systemPackages:
environment.systemPackages = with pkgs; [ wget vim nano zsh file lsof ncdu zip unzip nomachine git ];
rebuild nixos configuration:
nixos-rebuild switch
davinci resolve flatpak
install following packages:
flatpak-builder jq git
install org.freedesktop.sdk with flatpak:
flatpak install org.freedesktop.Sdk/x86_64/22.08
clone repo:
git clone https://github.com/vidalinux/resolve-flatpak.git
get davindi resolve free available download versions:
curl -o- https://www.blackmagicdesign.com/api/support/nz/downloads.json | jq -r '.downloads[] | select(.urls["Linux"] != null) | select(.urls["Linux"][0]["product"] == "davinci-resolve") | [.urls["Linux"][0].downloadTitle, .urls["Linux"][0].downloadId] | @tsv'
get davinci resolve studio available download versions:
curl -o- https://www.blackmagicdesign.com/api/support/nz/downloads.json | jq -r '.downloads[] | select(.urls["Linux"] != null) | select(.urls["Linux"][0]["product"] == "davinci-resolve-studio") | [.urls["Linux"][0].downloadTitle, .urls["Linux"][0].downloadId] | @tsv'
edit the following file shell/download-resolve.sh change the davinci resolve version:
_downloadid='34023b93d9f64d03aaf7654e2cbbb727'
build the flatpak for davinci resolve free version:
flatpak-builder --force-clean --repo=repo build-dir com.blackmagic.Resolve.yaml flatpak build-bundle repo resolve.flatpak com.blackmagic.Resolve
build flatpak for davinci resolve studio version:
flatpak-builder --force-clean --repo=repo build-dir com.blackmagic.ResolveStudio.yaml flatpak build-bundle repo resolve.flatpak com.blackmagic.ResolveStudio
install davinci resolve flatpak:
flatpak install resolve.flatpak
uninstall davinci resolve free flatpak:
flatpak uninstall com.blackmagic.Resolve
uninstall davinci resolve studio flatpak:
flatpak uninstall com.blackmagic.ResolveStudio
home-manager
install home-manager:
sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager
update channels:
sudo nix-channel --update
add the following line to /etc/nixos/configuration.nix inside the imports []:
<home-manager/nixos>
add the following line:
home-manager.users.linux = { pkgs, ... }: { home.packages = [ pkgs.home-manager ]; home.stateVersion = "23.05"; programs.bash.enable = true; };
apply this configuration with rebuild:
sudo nixos-rebuild switch
create initial configuration:
home-manager init
edit ~/.config/home-manager/home.nix:
{ config, pkgs, ... }: { home.username = "linux"; home.homeDirectory = "/home/linux"; home.stateVersion = "23.05"; home.packages = with pkgs; [htop]; home.sessionVariables = { EDITOR = "nano"; }; programs.home-manager.enable = true; }
save file and execute this command to install packages:
home-manager switch