### Create Zim Plugin Installation Example Source: https://wiki.nixos.org/wiki/Special%3AContributions/Tomodachi94 This is an example of how to install a plugin for Zim, a desktop wiki. It demonstrates the command-line usage for adding a plugin. ```bash zim --version # 0.73.1 # Install a plugin # Example: Install the "open-with" plugin # You can find plugins in the Zim wiki: https://github.com/zim-desktop-wiki/zim-wiki/wiki/Plugins # Install the plugin zim --install-plugin open-with # Check if the plugin is installed zim --list-plugins ``` -------------------------------- ### CUDA Driver Installation Example Source: https://wiki.nixos.org/wiki/Special%3AContributions/Smudgebun Example of how to configure CUDA driver installation. This is relevant for users who may be unsure about separate CUDA configuration. ```nix hardware.nvidia.modesetting.enable = true; hardware.nvidia.powerManagement.enable = false; hardware.nvidia.open = false; hardware.nvidia.nvidiaSettings = true; services.xserver.enable = true; services.xserver.displayManager.lightdm.enable = true; services.xserver.displayManager.lightdm.greeters.slick.enable = true; services.xserver.desktopManager.gnome.enable = true; services.xserver.displayManager.lightdm.enable = true; services.xserver.displayManager.lightdm.greeters.slick.enable = true; services.xserver.desktopManager.gnome.enable = true; programs.xwayland.enable = true; ``` -------------------------------- ### Launch Polybar with Example Configuration Source: https://wiki.nixos.org/wiki/Polybar Copy the example configuration file and launch Polybar using it. Ensure the 'siji' icon font is installed. ```bash polybar -c ~/.config/polybar/config.ini example ``` -------------------------------- ### Using the Generic Installation Template Source: https://wiki.nixos.org/wiki/Template%3AARM/installation_allwinner This is an example of how to use the ARM/installation allwinner template with specific variant and u-boot parameters. ```Nix {{ARM/installation allwinner|variant=EXAMPLE|u-boot=EXAMPLE-u-boot-sunxi-with-spl.bin}} ``` -------------------------------- ### Manual LUKS Partitioning and Setup Source: https://wiki.nixos.org/wiki/Full_Disk_Encryption Steps for manually formatting and opening a LUKS encrypted partition, then creating a filesystem and mounting it. This is part of a manual installation process. ```bash # format the partition with the luks structure cryptsetup luksFormat /dev/sda4 # open the encrypted partition and map it to /dev/mapper/cryptroot cryptsetup luksOpen /dev/sda4 cryptroot # format as usual mkfs.ext4 -L nixos /dev/mapper/cryptroot # mount mount /dev/disk/by-label/nixos /mnt mkdir /mnt/boot mount /dev/sda1 /mnt/boot ``` -------------------------------- ### NixOS Configuration Example Source: https://wiki.nixos.org/wiki/Install_NixOS_on_a_Server_With_a_Different_Filesystem A sample configuration.nix file for a NixOS server installation, including bootloader, networking, SSH, and ZFS settings. ```nix { config, pkgs, ... }: { imports = [ ./hardware-configuration.nix ]; boot.loader.grub.enable = true; boot.loader.grub.version = 2; boot.kernelParams = [ "net.ifnames=0" ]; boot.zfs.devNodes = "/dev"; boot.loader.grub.device = "/dev/vda"; networking = { hostName = "foobar"; hostId = "12345678"; defaultGateway = "x.x.x.x"; nameservers = [ "8.8.8.8" ]; interfaces.eth0 = { ipAddress = "y.y.y.y"; prefixLength = z; }; }; services.openssh.enable = true; users.users.root.openssh.authorizedKeys.keys = [ "ssh-rsa ..." ]; system.stateVersion = "18.03"; # Did you read the comment? } ``` -------------------------------- ### Example flake.nix packaging a shell script Source: https://wiki.nixos.org/wiki/Flake_Compat This example demonstrates a basic flake.nix setup that packages a simple shell script using flake-compat. It defines a package 'hello' and sets it as the default package for the x86_64-linux system. ```nix { description = "A very basic flake"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; flake-compat.url = "github:edolstra/flake-compat"; }; outputs = { self, nixpkgs, flake-compat }: let system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; }; in { packages.x86_64-linux.hello = pkgs.stdenv.mkDerivation { pname = "hello"; version = "1.0"; src = ./hello.sh; unpackPhase = "true"; installPhase = '' mkdir -p $out/bin cp $src $out/bin/hello chmod +x $out/bin/hello ''; }; packages.x86_64-linux.default = self.packages.x86_64-linux.hello; }; } ``` -------------------------------- ### Basic Sonarr Service Installation Source: https://wiki.nixos.org/wiki/Sonarr Enables the Sonarr service and opens the firewall port. Use this for a straightforward setup. ```nix services.sonarr = { enable = true; openFirewall = true; }; ``` -------------------------------- ### Basic NixOS System Configuration Example Source: https://wiki.nixos.org/wiki/NixOS_system_configuration A simple example of a NixOS system configuration file (`configuration.nix`). It includes importing other modules, setting the hostname, time zone, keyboard layout, defining user accounts, installing packages, and enabling services like OpenSSH. ```nix { config, pkgs, ... }: { # Import other configuration modules # (hardware-configuration.nix is autogenerated upon installation) # paths in nix expressions are always relative the file which defines them imports = [ ./hardware-configuration.nix ./my-dev-tools.nix ./my-desktop-env.nix ./etc.nix ]; # Name your host machine networking.hostName = "mymachine"; # Set your time zone. time.timeZone = "Europe/Utrecht"; # Enter keyboard layout services.xserver.layout = "us"; services.xserver.xkbVariant = "altgr-intl"; # Define user accounts users.users.myuser = { extraGroups = [ "wheel" "networkmanager" ]; isNormalUser = true; }; # Install some packages environment.systemPackages = with pkgs; [ ddate testdisk ]; # Enable the OpenSSH daemon services.openssh.enable = true; } ``` -------------------------------- ### Standard Application Section Structure Example Source: https://wiki.nixos.org/wiki/Manual_of_Style Outlines a typical section structure for application-related articles on the wiki, covering installation, configuration, tips, troubleshooting, and references. ```wiki (Introduction) == Installation == ==== Shell ==== ==== System setup ==== == Configuration == ==== Basic ==== ==== Advanced ==== == Tips and tricks == == Troubleshooting == == See also == == References == ``` -------------------------------- ### NixOS Installation Guide - Stage 1 Error Source: https://wiki.nixos.org/wiki/Special%3ASearch/%241 This message indicates an error occurred in stage 1 of the NixOS boot process and suggests starting an interactive shell. ```text An error occurred in stage 1 of the boot process, which must f) to start an interactive shell having pid 1 ``` -------------------------------- ### Set up CMake Project and Build Source: https://wiki.nixos.org/wiki/C%2B%2B Configure CMAKE_PREFIX_PATH, create a CMakeLists.txt, a source file, and run cmake to build the project. ```bash $ nix-shell [nix-shell:~] $ echo $CMAKE_PREFIX_PATH /nix/store/lw4xr0x2p6xyfgbk961lxh8vnnx7vn2r-cmake-3.12.1:/nix/store/j4x44bjjgwy7hm7lazj8xnr9mnlfiksh-patchelf-0.9:/nix/store/isg8rxaxkijl9x3hr2gzsf8pqfnqxg3k-gcc-wrapper-7.4.0:/nix/store/lwdkm354f3zzsvkf7pqmnc8w6r164b42-binutils-wrapper-2.30:/nix/store/biz7v9g4g6yrnp2h8wfn01d6pk3bj2m1-zeromq-4.3.0:/nix/store/lw4xr0x2p6xyfgbk961lxh8vnnx7vn2r-cmake-3.12.1:/nix/store/j4x44bjjgwy7hm7lazj8xnr9mnlfiksh-patchelf-0.9:/nix/store/isg8rxaxkijl9x3hr2gzsf8pqfnqxg3k-gcc-wrapper-7.4.0:/nix/store/lwdkm354f3zzsvkf7pqmnc8w6r164b42-binutils-wrapper-2.30:/nix/store/biz7v9g4g6yrnp2h8wfn01d6pk3bj2m1-zeromq-4.3.0 [nix-shell:~] $ cat >CMakeLists.txt < hello.c [nix-shell:~] $ cmake . ``` -------------------------------- ### Make 'ADB setup' section independent of OS and installation method Source: https://wiki.nixos.org/wiki/Special%3AContributions/Axka This edit makes the 'ADB setup' section independent of the operating system and installation method. ```Nix Android Make "ADB setup" section independent of operating system and method of installation. Tags: Mobile edit Mobile web edit Visual edit ``` -------------------------------- ### Original hp-setup command example Source: https://wiki.nixos.org/wiki/Talk%3APrinting This is the original command example provided for setting up HP printers, which may no longer be valid on newer NixOS versions. ```bash $ nix run nixpkgs.hplipWithPlugin -c sudo hp-setup ``` -------------------------------- ### Install SteamCMD Source: https://wiki.nixos.org/wiki/Steam Example of installing steamcmd using NixOS configuration. ```nix environment.systemPackages = with pkgs; [ steamcmd ]; ``` -------------------------------- ### Disable Setup Wizard Source: https://wiki.nixos.org/wiki/Invoiceplane Configures Invoiceplane to disable the setup wizard and mark setup as completed. This is recommended after initial installation. ```nix services.invoiceplane.sites."localhost".settings = { DISABLE_SETUP=true; SETUP_COMPLETED=true; }; ``` -------------------------------- ### Create setup.py in preBuild Phase Source: https://wiki.nixos.org/wiki/Packaging/Python When both setup.py and pyproject.toml are missing, this snippet demonstrates creating a setup.py file dynamically in the preBuild phase using a heredoc. ```nix buildPythonPackage { preBuild = '' cat > setup.py << EOF from setuptools import setup with open('requirements.txt') as f: install_requires = f.read().splitlines() setup( name='someprogram', #packages=['someprogram'], version='0.1.0', #author='...', #description='...', install_requires=install_requires, scripts=[ 'someprogram.py', ], entry_points={ # example: file some_module.py -> function main #'console_scripts': ['someprogram=some_module:main'] }, ) EOF ''; } ``` -------------------------------- ### Example Patch Hash Source: https://wiki.nixos.org/wiki/St Example of using 'nix-prefetch-url' to get the hash for a specific patch file. ```bash $ nix-prefetch-url https://st.suckless.org/patches/rightclickpaste/st-rightclickpaste-0.8.2.diff ``` -------------------------------- ### Set Up Users and Install Nix Source: https://wiki.nixos.org/wiki/Install_NixOS_on_Kimsufi Commands to create necessary users, set passwords, grant sudo privileges, disable Nix sandboxing, install Nix, and configure channels. ```bash # Create a user for the install process useradd -m setupuser # Create a user for the Nix daemon groupadd -g 30000 nixbld useradd -u 30000 -g nixbld -G nixbld nixbld # Set this to something you will remember, you'll need it in a moment passwd setupuser # Give sudo rights to your user echo "setupuser ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/setupuser su setupuser -s /bin/bash -l # Disable sandboxing as it doesn't work in tmpfs mounted systems # see: https://github.com/NixOS/nix/issues/5934 sudo mkdir -p /etc/nix/ echo "sandbox = false" | sudo tee -a /etc/nix/nix.conf # Install Nix curl -L https://nixos.org/nix/install | sh # This next line makes the Nix tools available in our shell source $HOME/.nix-profile/etc/profile.d/nix.sh # The default channel is `nixpkgs-unstable`, let's switch to a stable NixOS channel nix-channel --add https://nixos.org/channels/nixos-22.11 nixpkgs nix-channel --update nix-shell -p nixos-install-tools sudo `which nixos-generate-config` --root /mnt ``` -------------------------------- ### Quickemu VM Creation and Launch Source: https://wiki.nixos.org/wiki/Qemu Two commands to quickly create and run a virtual machine using Quickemu. The first command downloads the VM image, and the second starts the VM. ```bash $ quickget windows 11 $ quickemu --vm windows-11.conf ``` -------------------------------- ### Troubleshoot Waydroid GUI and Setup Wizard Source: https://wiki.nixos.org/wiki/Waydroid Commands to start the Android UI, disable the setup wizard, and disable Google Play Services setup if the graphical interface or setup wizard fails. ```bash waydroid shell -- am start -a android.intent.action.MAIN -c android.intent.category.HOME waydroid shell -- pm disable-user --user 0 com.google.android.setupwizard waydroid shell -- pm disable-user --user 0 com.google.android.gms.setup ``` -------------------------------- ### Basic DokuWiki Installation Source: https://wiki.nixos.org/wiki/Dokuwiki Minimal configuration to enable DokuWiki on localhost. DokuWiki will be accessible at http://localhost after applying this configuration. ```nix services.dokuwiki.sites."localhost" = { enable = true; settings.title = "My Wiki"; }; ``` -------------------------------- ### Install nvim-r with Home-Manager Source: https://wiki.nixos.org/wiki/Nvim-r Example configuration for installing the nvim-r plugin using Home-Manager in NixOS. Ensure build dependencies like which, vim, and zip are installed. ```nix with import { }; let customPlugins = { nvim-r = vimUtils.buildVimPlugin { name = "nvim-r"; src = fetchgit { url= "https://github.com/jalvesaq/nvim-r"; rev = "c53b5a402a26df5952718f483c7461af5bb459eb"; sha256 = "13xbb05gnpgmyaww6029saplzjq7cq2dxzlxylcynxhhyibz5ibv"; }; buildInputs = [ which vim zip }; }; ... ... in vim_configurable.customize { name = "vim"; vimrcConfig.customRC = '' vimrc things go here ''; vimrcConfig.vam.knownPlugins = pkgs.vimPlugins // customPlugins; vimrcConfig.vam.pluginDictionaries = [ { names = [ "nvim-r" "other normal vim plugins" ]; } ]; } ``` -------------------------------- ### Usage Example for ARM/installation generic Template Source: https://wiki.nixos.org/wiki/Template%3AARM/installation_generic Demonstrates how to include the ARM/installation generic template in another wiki page, specifying the desired ARM variant. ```Wiki Markup {{ARM/installation generic|variant=EXAMPLE}} ``` -------------------------------- ### Enable Basic Vim Installation Source: https://wiki.nixos.org/wiki/Special%3AMyLanguage/Vim Enables Vim using the default package. This is the most basic way to get Vim installed. ```nix programs.vim.enable = true; ``` -------------------------------- ### Install Nix Store Path into User Profile Source: https://wiki.nixos.org/wiki/Cheatsheet Install an arbitrary Nix store path into the user's profile using 'nix-env -i'. This example installs a specific Firefox version. ```bash $ nix-env -i /nix/store/yzz2gvpcyxg5i68zi11sznbsp1ypccz8-firefox-65.0 ``` -------------------------------- ### Format and Mount Multiple Partitions Source: https://wiki.nixos.org/wiki/Special%3AMyLanguage/bcachefs This example shows formatting and mounting multiple partitions, which may offer better future-proofing. ```bash # bcachefs format /dev/sda1:/dev/sdb2:/dev/sdc3 # mount -t bcachefs /dev/sda1:/dev/sdb2:/dev/sdc3 ``` -------------------------------- ### C Hello World Example with Template Source: https://wiki.nixos.org/wiki/Template%3AFile/Doc Demonstrates how to use the File template to display a C 'hello, world' program. The code is wrapped in tags to ensure correct rendering. ```wikitext {{file|main.c|c| #include main( ) { printf("hello, world\n"); } }} ``` -------------------------------- ### Enable Basic Drupal Installation Source: https://wiki.nixos.org/wiki/Special%3ADiff/31042 Enables a simple Drupal installation using nginx and MySQL. This is the most basic setup for running Drupal on NixOS. ```nix services.drupal.enable = true; ``` -------------------------------- ### Install cloudflared using nix-shell Source: https://wiki.nixos.org/wiki/Cloudflared Use a nix-shell to run cloudflared commands without installing it system-wide. This is useful for initial setup steps. ```bash $ nix-shell -p cloudflared ``` -------------------------------- ### Start F# REPL Source: https://wiki.nixos.org/wiki/Fsharp Installs the .NET SDK and starts the F# Interactive (REPL) environment. Use this to quickly test F# code. ```shell $ nix-shell -p dotnet-sdk warning: unknown setting 'experimental-features' [nix-shell:~]$ dotnet fsi Microsoft (R) F# Interactive version 12.0.5.0 for F# 6.0 Copyright (c) Microsoft Corporation. All Rights Reserved. For help type #help;; > printfn "Hello world from F#!";; Hello world from F#! val it : unit = () ``` -------------------------------- ### Start Service (Ubuntu/NixOS) Source: https://wiki.nixos.org/wiki/Special%3AMyLanguage/Ubuntu_vs._NixOS Starts a system service using systemctl. ```bash $ sudo systemctl start apache ``` -------------------------------- ### Basic Caddy Setup with Hello World Source: https://wiki.nixos.org/wiki/Caddy Enables Caddy and configures a virtual host for localhost to respond with 'Hello, world!'. Caddy automatically handles HTTP to HTTPS redirection. ```nix services.caddy = { enable = true; virtualHosts."localhost".extraConfig = '' tls internal respond "Hello, world!" ''; }; ``` -------------------------------- ### GRUB 2 Bootloader Configuration Example Source: https://wiki.nixos.org/wiki/Installing_from_Linux Example GRUB 2 menu entry for booting the NixOS Installer/Rescue environment. ```grub menuentry "NixOS Installer / Rescue" { linux /nixos-livecd-bzImage init=/nix/store/p5n72ay1c1wx4wry90zabr8jnljpdzgx-nixos-0.2pre4601_1def5ba-48a4e91/init root=/dev/sda2 initrd /nixos-lived-initrd } ``` -------------------------------- ### Basic Steam System Setup Source: https://wiki.nixos.org/wiki/Special%3AMyLanguage/Steam Install the Steam package and enable essential system options for Steam to run on NixOS. This is the primary method for system-wide Steam installation. ```nix programs.steam = { enable = true; }; # Optional: If you encounter amdgpu issues with newer kernels (e.g., 6.10+ reported issues), # you might consider using the LTS kernel or a known stable version. # boot.kernelPackages = pkgs.linuxPackages; # Example for LTS ``` -------------------------------- ### Add Example IPv6 Subnet to Interface Source: https://wiki.nixos.org/wiki/Install_NixOS_on_Liteserver An example of adding a specific IPv6 subnet to the 'ens3' network interface. This is used for establishing internet connectivity during the NixOS installation. ```shell ip addr add 2a04:52c0:118:fe87::2/48 dev ens3 ``` -------------------------------- ### Build, Install, and Run a Flatpak Demo App Source: https://wiki.nixos.org/wiki/Flatpak Steps to clone a demo app, add necessary Flatpak repositories and runtimes, build, and execute the application. ```bash $ flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo $ flatpak install gnome-nightly org.gnome.Sdk org.gnome.Platform $ git clone https://gitlab.gnome.org/GNOME/libadwaita.git $ cd libadwaita $ nix shell nixpkgs#appstream $ flatpak-builder --disable-tests --user --install build demo/org.gnome.Adwaita1.Demo.json $ flatpak run org.gnome.Adwaita1.Demo.json ``` -------------------------------- ### Install Emacs Packages via Nix (e.g., vterm) Source: https://wiki.nixos.org/wiki/Emacs Example of how to install Emacs packages, like vterm, through Nix. This method is useful for packages that require building. ```nix environment.systemPackages = with pkgs; [ ... ((emacsPackagesFor emacs-pgtk).emacsWithPackages ( epkgs: [ epkgs.vterm ] )) ... ]; # To make the packages available to emacsclient, one can do the following: services.emacs.package = with pkgs; ( (emacsPackagesFor emacs-pgtk).emacsWithPackages ( epkgs: [ epkgs.vterm ] ) ); # Some packages have characters like + that Nix considers a syntax error. # To fix this, write the package name in quotes and specify the package set, even if using with epkgs;. # For example, use epkgs."ido-completing-read+". ``` -------------------------------- ### Build U-Boot Natively Source: https://wiki.nixos.org/wiki/U-Boot Example of building the U-Boot package natively on an AArch64 system. ```bash $ # Example output for an AArch64 system. $ uname -m aarch64 $ nix-build -A ubootLibreTechCC ``` -------------------------------- ### Enable Zed Remote Server Installation Source: https://wiki.nixos.org/wiki/Zed_editor Enable Zed's remote server installation declaratively using Home Manager. This simplifies the setup for remote server management. ```nix programs.zed-editor = { enable = true; installRemoteServer = true; }; ``` -------------------------------- ### Blender Configuration Examples Source: https://wiki.nixos.org/wiki/Special%3AContributions/Smudgebun Additional configuration examples for Blender on NixOS. ```nix programs.blender.enable = true; ``` -------------------------------- ### Proxmox VE VM Console Access Example Source: https://wiki.nixos.org/wiki/Proxmox Example of starting a VM and accessing its serial console on Proxmox VE after importing a NixOS image. This demonstrates the boot process and login prompt. ```bash root@proxmox-server:~# qm start root@proxmox-server:~# qm terminal starting serial terminal on interface serial0 (press Ctrl+O to exit) <<< NixOS Stage 1 >>> loading module dm_mod... running udev... Starting version 249.4 . . . [ OK ] Reached target Multi-User System. <<< Welcome to NixOS 21.11.git.d41882c7b98M (x86_64) - ttyS0 >>> Run 'nixos-help' for the NixOS manual. nixos login: root (automatic login) [root@nixos:~]# ``` -------------------------------- ### Basic NixOS Module Example Source: https://wiki.nixos.org/wiki/Module Demonstrates a simple NixOS module with options and configuration. This can be evaluated using nix-instantiate. ```nix let systemModule = { lib, config, ... }: { options.toplevel = lib.mkOption { type = lib.types.str; }; options.enableFoo = lib.mkOption { type = lib.types.bool; default = false; }; config.toplevel = '' Is foo enabled? ${lib.boolToString config.enableFoo} ''; }; userModule = { enableFoo = true; }; in (import ).evalModules { modules = [ systemModule userModule ]; } ``` -------------------------------- ### Install Blender with CUDA Support and Python Packages Source: https://wiki.nixos.org/wiki/Blender Installs Blender with CUDA support enabled and additional Python packages. This example uses an overridden Blender package for CUDA support. ```nix let blender-cuda = blender.override {config.cudaSupport=true;}; in { environment.systemPackages = with pkgs; [ (blender-cuda.withPackages(ps: [ ps.yq ])) # (pkgsRocm.blender.withPackages(ps: [ ps.pyserial ps.fs ])) ]; } ``` -------------------------------- ### Basic WordPress Installation Source: https://wiki.nixos.org/wiki/Wordpress Enables a simple local WordPress setup. A MariaDB server is configured automatically. ```nix services.wordpress.sites."localhost" = {}; ``` -------------------------------- ### Build NixOS VM Example Source: https://wiki.nixos.org/wiki/Module Command to build a NixOS virtual machine using a local configuration. Use --fast for quicker builds. ```bash nixos-rebuild build-vm --fast -I nixos-config=./configuration.nix -I nixpkgs=. ``` -------------------------------- ### Setting up a Nix shell for binary testing Source: https://wiki.nixos.org/wiki/Packaging/Binaries This command prepares a development environment with necessary tools like `binutils`, `stdenv`, `wget`, `dpkg`, and `nix-index` for testing and unpacking binary packages. ```bash $ nix-shell -p binutils stdenv wget dpkg nix-index \ stdenv.cc # stdenv.cc is required for setting $NIX_CC env ``` -------------------------------- ### NixOS Option Examples Source: https://wiki.nixos.org/wiki/NixOS_modules Provides a comprehensive set of examples for declaring various types of options using `lib.options.mkOption` and related helper functions. These examples showcase different option types and configurations. ```nix { lib, pkgs, ... }: { options.examples = { enable = lib.options.mkEnableOption "showcasing of options"; # type = lib.types.bool; package = lib.options.mkPackageOption pkgs "bash" { }; # type = lib.types.package; numberOfTheDay = lib.options.mkOption { type = lib.types.ints.between 50 100; default = 61; }; groceries = lib.options.mkOption { type = lib.types.listOf lib.types.strMatching "^[a-z]*$"; default = []; description = "Showcase `listOf` and `strMatching`". example = [ "bananas" "cherrys" "Throws an error at evaluation beause of regex not matching." ]; }; settings = lib.options.mkOption { type = lib.types.toml; default = {}; description = '' Showcase the possible option for settings of a configuration file. Always document, where you can find possible options e.g.: Refer for possible options. ''; example = { global = { log_format = "-"; log_filter = "^$"; }; }; }; units = lib.options.mkOption { type = lib.types.attrsOf (lib.types.submodule ( { name, ... }: { options = { name = lib.options.mkOption { type = lib.types.str; default = name; defaultText = ""; description = "Name of the unit"; }; unit = lib.options.mkOption { type = lib.types.str; defaultText = '' Default will be set in the `config` block of the `submodule` (see down below) ''; description = "A unit of measurement"; }; }; config = { unit = lib.mkDefault "kg"; }; } )); default = {}; description = "Showcase the combination `attrsOf` and `submodule`"; example = { "unit1" = { unit = "m" }; "unit2".unit = "cm"; "unit3" = {}; # kg }; }; }; } ``` -------------------------------- ### Nix Package Manager Link Update Source: https://wiki.nixos.org/wiki/Special%3AContributions/Sen This edit replaces a dead link in the 'Installation' section of the Nix package manager article and removes redundant information. Use this for maintaining the accuracy of Nix installation guides. ```text Nix (package manager) Replaced dead link in the "Installation" section and removed "NixOS ships with Nix pre-installed." because its extremely obvious. ``` -------------------------------- ### Filesystem Creation and ZFS Pool Setup Source: https://wiki.nixos.org/wiki/Install_NixOS_on_a_Server_With_a_Different_Filesystem Commands to format the boot partition, set up swap, and create a ZFS pool named 'tank' with compression and a legacy mountpoint. ```bash mkfs.ext4 /dev/vda2 mkswap /dev/vda3 zpool create -O compress=on -O mountpoint=legacy tank /dev/vda4 zfs create -o xattr=off -o atime=off tank/nix ``` -------------------------------- ### Start iOS Emulator with QEMU Source: https://wiki.nixos.org/wiki/IOS_Emulation Use this command to launch the iOS emulator. Ensure all specified firmware and device files are correctly path-ed and accessible. ```bash QEMUAppleSilicon/build/qemu-system-aarch64 -M t8030,trustcache=iPhone11_8_iPhone12_1_14.0_18A5351d_Restore/Firmware/038-44135-124.dmg.trustcache,ticket=root_ticket.der,sep-fw=sep-firmware.n104.RELEASE.new.img4,sep-rom=AppleSEPROM-Cebu-B1,kaslr-off=true \ -kernel iPhone11_8_iPhone12_1_14.0_18A5351d_Restore/kernelcache.research.iphone12b -dtb iPhone11_8_iPhone12_1_14.0_18A5351d_Restore/Firmware/all_flash/DeviceTree.n104ap.im4p \ -append "tlto_us=-1 mtxspin=-1 agm-genuine=1 agm-authentic=1 agm-trusted=1 serial=3 launchd_unsecure_cache=1 wdt=-1 -vm_compressor_wk_sw" \ -smp 7 -m 4G -serial mon:stdio \ -drive file=sep_nvram,if=pflash,format=raw \ -drive file=sep_ssc,if=pflash,format=raw \ -drive file=root,format=raw,if=none,id=root -device nvme-ns,drive=root,bus=nvme-bus.0,nsid=1,nstype=1,logical_block_size=4096,physical_block_size=4096 \ -drive file=firmware,format=raw,if=none,id=firmware -device nvme-ns,drive=firmware,bus=nvme-bus.0,nsid=2,nstype=2,logical_block_size=4096,physical_block_size=4096 \ -drive file=syscfg,format=raw,if=none,id=syscfg -device nvme-ns,drive=syscfg,bus=nvme-bus.0,nsid=3,nstype=3,logical_block_size=4096,physical_block_size=4096 \ -drive file=ctrl_bits,format=raw,if=none,id=ctrl_bits -device nvme-ns,drive=ctrl_bits,bus=nvme-bus.0,nsid=4,nstype=4,logical_block_size=4096,physical_block_size=4096 \ -drive file=nvram,if=none,format=raw,id=nvram -device apple-nvram,drive=nvram,bus=nvme-bus.0,nsid=5,nstype=5,id=nvram,logical_block_size=4096,physical_block_size=4096 \ -drive file=effaceable,format=raw,if=none,id=effaceable -device nvme-ns,drive=effaceable,bus=nvme-bus.0,nsid=6,nstype=6,logical_block_size=4096,physical_block_size=4096 \ -drive file=panic_log,format=raw,if=none,id=panic_log -device nvme-ns,drive=panic_log,bus=nvme-bus.0,nsid=7,nstype=8,logical_block_size=4096,physical_block_size=4096 \ -display gtk,zoom-to-fit=on,show-cursor=on ``` -------------------------------- ### Rename Binary Script in postInstall Source: https://wiki.nixos.org/wiki/Packaging/Python Use postInstall to rename the installed binary script, for example, to remove the '.py' extension. ```nix buildPythonPackage { # ... postInstall = '' mv -v $out/bin/someprogram.py $out/bin/someprogram ''; } ``` -------------------------------- ### Mark as a tutorial Source: https://wiki.nixos.org/wiki/Special%3AContributions/Axka This edit marks the 'Adding programs to PATH' page as a tutorial. ```Nix Adding programs to PATH Mark as a tutorial Tags: Mobile edit Mobile web edit ``` -------------------------------- ### Minimal Gitea Configuration Source: https://wiki.nixos.org/wiki/Gitea This is the most minimal configuration to get Gitea started locally. Ensure the database type is set correctly. ```nix services.gitea = { enable = true; database.type = "mysql"; #settings.service.DISABLE_REGISTRATION = true; }; ``` -------------------------------- ### Initialize and Add Python with Pixi Source: https://wiki.nixos.org/wiki/Python Shows the initial steps to set up a project with pixi, including initializing the project and adding Python as a dependency. ```bash $ pixi init $ pixi add python ``` -------------------------------- ### Install Python Versions with uv Source: https://wiki.nixos.org/wiki/Python This command uses `uv` to install a specific Python version (3.14 in this example). The `--preview` flag is used for features not yet stable, and `--default` sets it as the default Python interpreter for uv. ```bash $ uv python install 3.14 --preview --default ``` -------------------------------- ### Disable Service (NixOS) Source: https://wiki.nixos.org/wiki/Special%3AMyLanguage/Ubuntu_vs._NixOS Disables a service from starting on boot by configuring it in configuration.nix and rebuilding the system. This example disables the Tor service. ```nix services.tor.enable = false; ``` ```bash $ sudo nixos-rebuild switch ``` -------------------------------- ### Install QEMU System-Wide Source: https://wiki.nixos.org/wiki/Qemu Add the QEMU package to your system's configuration to install it globally. ```nix environment.systemPackages = [ pkgs.qemu ]; ``` -------------------------------- ### Enable Service (NixOS) Source: https://wiki.nixos.org/wiki/Special%3AMyLanguage/Ubuntu_vs._NixOS Enables a service to start on boot by configuring it in configuration.nix and rebuilding the system. This example enables the Tor service. ```nix services.tor.enable = true; ``` ```bash $ sudo nixos-rebuild switch ``` -------------------------------- ### Basic Nextcloud Setup Source: https://wiki.nixos.org/wiki/Nextcloud A minimal configuration to enable Nextcloud on localhost using SQLite for the database. Ensure 'PWD' meets Nextcloud's password policy. ```nix environment.etc."nextcloud-admin-pass".text = "PWD"; services.nextcloud = { enable = true; hostName = "localhost"; config.adminpassFile = "/etc/nextcloud-admin-pass"; config.dbtype = "sqlite"; }; ``` -------------------------------- ### Example: NixOS VM test with home-manager Source: https://wiki.nixos.org/wiki/Special%3AMyLanguage/NixOS_VM_tests This example demonstrates how to integrate home-manager into a NixOS VM test configuration. It shows how to manage user packages and services within the VM. ```nix let nixpkgs = builtins.fetchTarball "https://github.com/nixOS/nixpkgs/archive/22.05.tar.gz"; pkgs = import nixpkgs {}; home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz"; in pkgs.nixosTest { nodes.machine = { config, pkgs, ... }: { imports = [ (import "${home-manager}/nixos") ]; boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; services.xserver.enable = true; services.xserver.displayManager.gdm.enable = true; services.xserver.desktopManager.gnome.enable = true; users.users.alice = { isNormalUser = true; extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. }; home-manager.users.alice = { home.packages = [ pkgs.firefox pkgs.thunderbird ]; }; system.stateVersion = "22.05"; }; testScript = {nodes, ...}: __ machine.wait_for_unit("default.target") machine.succeed("su -- alice -c 'which firefox'") machine.fail("su -- root -c 'which firefox'") _;_ ``` -------------------------------- ### Exclude default GNOME applications Source: https://wiki.nixos.org/wiki/GNOME Use `environment.gnome.excludePackages` to remove specific applications that are installed by default with GNOME. For example, to exclude 'showtime'. ```nix environment.gnome.excludePackages = with pkgs; [ showtime ]; ``` -------------------------------- ### App Template Usage Example Source: https://wiki.nixos.org/wiki/Template%3AApp Demonstrates how to use the {{app}} template to format application information. Each parameter represents the program name, description, application URL, and NixOS package name respectively. ```Wiki Markup {{app|[[sway]]|A wayland compositor|https://github.com/swaywm/sway|sway}} {{app|mako|A lightweight notification daemon for Wayland|https://github.com/emersion/mako|mako}} ``` -------------------------------- ### Install Docker CLI Temporarily Source: https://wiki.nixos.org/wiki/Docker Use this command to get a shell with the Docker CLI available. The Docker daemon will not be running with this method. ```shell nix-shell -p docker ``` -------------------------------- ### Run Companion VM Source: https://wiki.nixos.org/wiki/IOS_Emulation Starts the NixOS companion VM using QEMU. This command configures networking, USB passthrough for idevicerestore, and SSH forwarding. ```bash qemu-system-x86_64 -m 2024 -nic user -hda ./result/nixos.qcow2 -nographic -usb -device usb-ehci,id=ehci -device usb-tcp-remote,conn-type=ipv4,conn-addr=127.0.0.1,conn-port=8030,bus=ehci.0 -nic user,model=virtio-net-pci,hostfwd=tcp::32222-:22 ``` -------------------------------- ### Generate Steam Log with Strace Source: https://wiki.nixos.org/wiki/Steam Run this command to generate a log file for Steam if it fails to start. Install `strace` temporarily if needed. ```bash strace steam -dev -console 2> steam.logs ``` ```bash nix-shell -p strace ``` ```bash nix run nixpkgs#strace -- steam -dev -console 2> steam.logs ``` -------------------------------- ### Working hp-setup command for NixOS 22.05 Source: https://wiki.nixos.org/wiki/Talk%3APrinting This command is a proposed replacement for the original hp-setup example, designed to work with the updated `nix run` syntax on NixOS 22.05. It requires specific experimental features and allows unfree packages. ```bash $ NIXPKGS_ALLOW_UNFREE=1 nix --extra-experimental-features nix-command --extra-experimental-features --flakes shell --impure nixpkgs#hplipWithPlugin --command sudo hp-setup ```