configuration.nix
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| configuration.nix [2026/07/09 22:15] – Add mpd service sam | configuration.nix [2026/07/10 00:19] (current) – removed sam | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== My Nix Configuration ====== | ||
| - | In order to edit the configuration without root permissions, | ||
| - | < | ||
| - | mkdir ~/etc | ||
| - | sudo mv /etc/nixos/ ~/etc/ | ||
| - | sudo chown -R $(id -un):users ~/ | ||
| - | sudo ln -s ~/ | ||
| - | </ | ||
| - | |||
| - | ===== The Configuration ===== | ||
| - | |||
| - | < | ||
| - | # Edit this configuration file to define what should be installed on | ||
| - | # your system. | ||
| - | # and in the NixOS manual (accessible by running ‘nixos-help’). | ||
| - | |||
| - | { config, pkgs, lib, ... }: | ||
| - | |||
| - | let | ||
| - | home-manager = builtins.fetchTarball https:// | ||
| - | |||
| - | # Given a list of attribute sets, union them into a single attribute | ||
| - | # set, preferring keys earlier in the list. | ||
| - | unionsAttrs = lib.foldAttrs lib.const {}; | ||
| - | in | ||
| - | { | ||
| - | imports = | ||
| - | [ # Include the results of the hardware scan. | ||
| - | ./ | ||
| - | (import " | ||
| - | ]; | ||
| - | |||
| - | # Bootloader. | ||
| - | boot.loader.systemd-boot.enable = true; | ||
| - | boot.loader.efi.canTouchEfiVariables = true; | ||
| - | |||
| - | networking.hostName = " | ||
| - | networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. | ||
| - | |||
| - | # Configure network proxy if necessary | ||
| - | # networking.proxy.default = " | ||
| - | # networking.proxy.noProxy = " | ||
| - | |||
| - | # Enable networking | ||
| - | networking.networkmanager.enable = true; | ||
| - | |||
| - | # Enable bluetooth | ||
| - | hardware.bluetooth = { | ||
| - | enable = true; | ||
| - | powerOnBoot = false; | ||
| - | }; | ||
| - | |||
| - | # Set your time zone. | ||
| - | time.timeZone = " | ||
| - | |||
| - | # Select internationalisation properties. | ||
| - | i18n.defaultLocale = " | ||
| - | |||
| - | i18n.extraLocaleSettings = { | ||
| - | LC_ADDRESS = " | ||
| - | LC_IDENTIFICATION = " | ||
| - | LC_MEASUREMENT = " | ||
| - | LC_MONETARY = " | ||
| - | LC_NAME = " | ||
| - | LC_NUMERIC = " | ||
| - | LC_PAPER = " | ||
| - | LC_TELEPHONE = " | ||
| - | LC_TIME = " | ||
| - | }; | ||
| - | |||
| - | # Add swap | ||
| - | swapDevices = [{ | ||
| - | device = "/ | ||
| - | size = 16*1024; # 16 GiB | ||
| - | }]; | ||
| - | |||
| - | # Define a user account. Don't forget to set a password with ‘passwd’. | ||
| - | users.users." | ||
| - | isNormalUser = true; | ||
| - | description = "Sam Cohen"; | ||
| - | extraGroups = [ " | ||
| - | packages = with pkgs; []; | ||
| - | }; | ||
| - | |||
| - | # Necessary for sway | ||
| - | security.polkit.enable = true; | ||
| - | |||
| - | # Keyring for wayland applications | ||
| - | services.gnome.gnome-keyring.enable = true; | ||
| - | security.pam.services = { | ||
| - | greetd.enableGnomeKeyring = true; | ||
| - | # Necessary for swaylock to work correctly. | ||
| - | swaylock = {}; | ||
| - | }; | ||
| - | |||
| - | # Launches sway on login | ||
| - | services.greetd = { | ||
| - | enable = true; | ||
| - | settings = { | ||
| - | default_session = { | ||
| - | command = " | ||
| - | user = " | ||
| - | }; | ||
| - | }; | ||
| - | }; | ||
| - | |||
| - | services.logind.settings.Login = { | ||
| - | # don’t shutdown when power button is short-pressed. We want sway | ||
| - | # to handle that key instead. | ||
| - | HandlePowerKey = " | ||
| - | }; | ||
| - | |||
| - | # CPU frequency scaling. This is meant to extend battery life. | ||
| - | services.auto-cpufreq = { | ||
| - | enable = true; | ||
| - | settings = { | ||
| - | battery = { | ||
| - | governor = " | ||
| - | turbo = " | ||
| - | }; | ||
| - | charger = { | ||
| - | governor = " | ||
| - | turbo = " | ||
| - | }; | ||
| - | }; | ||
| - | }; | ||
| - | # Tries to keep the CPU at a reasonable temperature by throttling | ||
| - | # when necessary. | ||
| - | services.thermald.enable = true; | ||
| - | |||
| - | # A service which automatically mounts external storage devices. | ||
| - | services.udisks2.enable = true; | ||
| - | |||
| - | ## Printing ########## | ||
| - | |||
| - | # NOTE: see http:// | ||
| - | services.printing.enable = true; | ||
| - | |||
| - | # The below is for automatic discovery of network printers using | ||
| - | # the IPP Everywhere protocol. | ||
| - | services.avahi = { | ||
| - | enable = true; | ||
| - | nssmdns4 = true; | ||
| - | openFirewall = true; | ||
| - | }; | ||
| - | |||
| - | # Fonts | ||
| - | fonts.packages = with pkgs; [ | ||
| - | hack-font | ||
| - | ]; | ||
| - | |||
| - | home-manager.users." | ||
| - | let | ||
| - | # Permits adjustment of display brightness | ||
| - | brightnessctl = " | ||
| - | # Permits adjustment of audio volume via pactl | ||
| - | pactl = " | ||
| - | # Permits locking the screen | ||
| - | swaylock = " | ||
| - | in { | ||
| - | home.packages = with pkgs; [ | ||
| - | # For keeping track of passwords: | ||
| - | pass | ||
| - | |||
| - | # For reading mail: | ||
| - | mu | ||
| - | |||
| - | # For syncing with mail servers: | ||
| - | isync | ||
| - | # For sending email: | ||
| - | msmtp | ||
| - | # For communicating with exchange servers. See below, usually | ||
| - | # we will start this program as a systemd service. | ||
| - | davmail | ||
| - | |||
| - | # dokoff (locally defined) | ||
| - | (callPackage / | ||
| - | |||
| - | # For taking screenshots | ||
| - | grim | ||
| - | ]; | ||
| - | |||
| - | programs.bash = { | ||
| - | enable = true; | ||
| - | enableCompletion = true; | ||
| - | bashrcExtra = "eval \" | ||
| - | }; | ||
| - | |||
| - | programs.git = { | ||
| - | enable = true; | ||
| - | signing = { | ||
| - | key = " | ||
| - | format = " | ||
| - | signByDefault = true; | ||
| - | }; | ||
| - | settings = { | ||
| - | init.defaultBranch = " | ||
| - | user.useConfigOnly = true; | ||
| - | user.name = "Sam Cohen"; | ||
| - | user.email = " | ||
| - | rebase.autoSquash = true; | ||
| - | }; | ||
| - | }; | ||
| - | |||
| - | ## GPG ########## | ||
| - | |||
| - | programs.gpg = { | ||
| - | enable = true; | ||
| - | }; | ||
| - | services.gpg-agent = { | ||
| - | enable = true; | ||
| - | pinentry.package = pkgs.pinentry-qt; | ||
| - | defaultCacheTtl = 1800; # Only ask for a password half an hour after inactivity | ||
| - | }; | ||
| - | |||
| - | ## Sway/GUI ########## | ||
| - | |||
| - | programs.kitty = { | ||
| - | enable = true; | ||
| - | themeFile = " | ||
| - | font.name = " | ||
| - | font.size = 10; | ||
| - | # Make the text render a lot thicker, more similar to emacs | ||
| - | # text rendering: | ||
| - | extraConfig = " | ||
| - | }; | ||
| - | |||
| - | programs.rofi = { | ||
| - | enable = true; | ||
| - | modes = [ " | ||
| - | theme = " | ||
| - | }; | ||
| - | |||
| - | # Client for udisks2 | ||
| - | services.udiskie = { | ||
| - | enable = true; | ||
| - | }; | ||
| - | |||
| - | services.emacs.enable = true; | ||
| - | programs.emacs = { | ||
| - | enable = true; | ||
| - | }; | ||
| - | home.sessionVariables = { | ||
| - | # Put the location of mu4e on the path so that emacs can find | ||
| - | # it later. | ||
| - | MU4E = " | ||
| - | EDITOR = " | ||
| - | }; | ||
| - | |||
| - | wayland.windowManager.sway = { | ||
| - | enable = true; | ||
| - | wrapperFeatures.gtk = true; # Fixes common issues with gtk3 apps | ||
| - | checkConfig = true; | ||
| - | config = rec { | ||
| - | terminal = " | ||
| - | startup = [ | ||
| - | # Launch emacs on start | ||
| - | { command = " | ||
| - | ]; | ||
| - | modifier = " | ||
| - | keybindings = let | ||
| - | workspaces = [1 2 3 4]; | ||
| - | |||
| - | # Setup two bindings for each workspace, one which moves | ||
| - | # to the workspace, and one which moves the current | ||
| - | # container to the workspace: | ||
| - | bindings = lib.listToAttrs | ||
| - | (lib.concatMap (n: | ||
| - | let | ||
| - | ns = toString n; | ||
| - | in [ | ||
| - | { " | ||
| - | { " | ||
| - | ]) workspaces); | ||
| - | in | ||
| - | unionsAttrs [ | ||
| - | bindings | ||
| - | { | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | |||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | |||
| - | # Brightness Controls | ||
| - | " | ||
| - | " | ||
| - | |||
| - | # Volume Controls | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | |||
| - | # Launching | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | |||
| - | # Locking | ||
| - | " | ||
| - | } | ||
| - | ]; | ||
| - | |||
| - | input = { | ||
| - | " | ||
| - | xkb_options = " | ||
| - | repeat_delay = " | ||
| - | repeat_rate = " | ||
| - | }; | ||
| - | " | ||
| - | tap = " | ||
| - | # Prevent an odd feature where after tapping you can drag | ||
| - | # the mouse to create a selection. | ||
| - | drag = " | ||
| - | drag_lock = " | ||
| - | |||
| - | # Change scroll direction. | ||
| - | natural_scroll = " | ||
| - | |||
| - | # Disable trackpad while typing. | ||
| - | dwt = " | ||
| - | }; | ||
| - | }; | ||
| - | }; | ||
| - | }; | ||
| - | |||
| - | # Turns off the display, then suspends the computer after a period | ||
| - | # of inactivity. | ||
| - | services.swayidle = { | ||
| - | enable = true; | ||
| - | timeouts = [ | ||
| - | { | ||
| - | timeout = 1 * 60; | ||
| - | command = " | ||
| - | resumeCommand = " | ||
| - | } | ||
| - | { | ||
| - | timeout = 5 * 60; | ||
| - | command = " | ||
| - | } | ||
| - | ]; | ||
| - | events = { | ||
| - | # Restore the previously saved brightness. | ||
| - | " | ||
| - | " | ||
| - | }; | ||
| - | }; | ||
| - | |||
| - | # Locks the screen when power button is pressed. | ||
| - | programs.swaylock = { | ||
| - | enable = true; | ||
| - | }; | ||
| - | |||
| - | # Displays notifications when called upon. | ||
| - | services.mako = { | ||
| - | enable = true; | ||
| - | settings = { | ||
| - | default-timeout = 5000; # 5 seconds. | ||
| - | }; | ||
| - | }; | ||
| - | |||
| - | programs.firefox = { | ||
| - | enable = true; | ||
| - | }; | ||
| - | |||
| - | ## Mail ########## | ||
| - | |||
| - | # We use a davmail server to proxy Exchange mail servers as | ||
| - | # local SMTP/IMAP servers. | ||
| - | systemd.user.services.davmail = { | ||
| - | Unit = { | ||
| - | Description = "Proxy Exchange servers through local SMTP/ | ||
| - | }; | ||
| - | Install = { | ||
| - | WantedBy = [ " | ||
| - | }; | ||
| - | Service = { | ||
| - | ExecStart = " | ||
| - | }; | ||
| - | }; | ||
| - | |||
| - | ## Music ######### | ||
| - | |||
| - | services.mpd = { | ||
| - | enable = true; | ||
| - | musicDirectory = " | ||
| - | network.startWhenNeeded = true; | ||
| - | }; | ||
| - | |||
| - | # Restart user services when we perform a configuration switch. | ||
| - | systemd.user.startServices = " | ||
| - | |||
| - | home.stateVersion = " | ||
| - | }; | ||
| - | |||
| - | # List packages installed in system profile. To search, run: | ||
| - | # $ nix search wget | ||
| - | environment.systemPackages = with pkgs; [ | ||
| - | libnotify | ||
| - | wl-clipboard | ||
| - | direnv | ||
| - | kdePackages.okular # A PDF viewer | ||
| - | darktable | ||
| - | gphoto2 | ||
| - | |||
| - | ## In Service of Emacs ########## | ||
| - | |||
| - | # Ghostscript is necessary to interpret PDF files in emacs' | ||
| - | # document viewer. | ||
| - | ghostscript | ||
| - | ispell | ||
| - | ripgrep | ||
| - | ]; | ||
| - | |||
| - | # This value determines the NixOS release from which the default | ||
| - | # settings for stateful data, like file locations and database versions | ||
| - | # on your system were taken. It‘s perfectly fine and recommended to leave | ||
| - | # this value at the release version of the first install of this system. | ||
| - | # Before changing this value read the documentation for this option | ||
| - | # (e.g. man configuration.nix or on https:// | ||
| - | system.stateVersion = " | ||
| - | } | ||
| - | </ | ||
configuration.nix.1783635344.txt.gz · Last modified: by sam