Dotfiles

nix

Flake

Create a flake.nix.

{
  description = "I.W.'s nix config'";

  inputs = {
    nixpkgs = {
      url = "github:nixos/nixpkgs/nixpkgs-unstable";
    };
    home-manager = {
      url = "github:nix-community/home-manager/master";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = inputs @ { self, nixpkgs, home-manager, ... }: {
    <<flake-outputs>>
  };
}

Enable the experimental flake feature in nix config.

nix = {
package = pkgs.nixVersions.latest;
extraOptions = ''
    experimental-features = nix-command flakes
'';
};

NixOS

Define my laptop, a nixos system named ai.

nixosConfigurations.ai = nixpkgs.lib.nixosSystem {
    system = "x86_64-linux";
    modules = [
    ./nix/ai.nix
    home-manager.nixosModules.home-manager
    {
        home-manager.useGlobalPkgs = true;
        home-manager.useUserPackages = true;
        home-manager.users.i = import ./nix/home.nix;
    home-manager.backupFileExtension = "backup";
    }
    ({ pkgs, ... }: {
        nixpkgs.overlays = [ ];
    })
    ];
};

Configure it.

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./ai-hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/nvme0n1";
  boot.loader.grub.useOSProber = true;

  # Setup keyfile
  boot.initrd.secrets = {
    "/crypto_keyfile.bin" = null;
  };

  boot.loader.grub.enableCryptodisk=true;

  boot.initrd.luks.devices."luks-b64b7411-f1bc-400c-9427-a51e91d90509".keyFile = "/crypto_keyfile.bin";
  networking.hostName = "ai"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "America/Los_Angeles";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_US.UTF-8";
    LC_IDENTIFICATION = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_NAME = "en_US.UTF-8";
    LC_NUMERIC = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_TELEPHONE = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.displayManager.sddm.enable = true;
  services.desktopManager.plasma6.enable = true;

  # Configure keymap in X11
  services.xserver = {
    xkb.layout = "us";
    xkb.variant = "";
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.i = {
    isNormalUser = true;
    description = "Inge Winsome";
    extraGroups = [ "networkmanager" "wheel" "adbusers" ];
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
    ncdu
    git
    zip
    unzip
    imagemagick
    haskellPackages.git-annex
    tesseract
    pinentry-curses
    passExtensions.pass-import
    (pass.withExtensions (ext: with ext; [ pass-import ]))
    pass
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  services.openssh = {
    enable = true;
    settings.PasswordAuthentication = false;
    ports = [ 17856 ];
  };

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # 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://nixos.org/nixos/options.html).
  system.stateVersion = "23.11"; # Did you read the comment?

  users.defaultUserShell = pkgs.zsh;
  programs.zsh.enable = true;
  programs.zsh.ohMyZsh = {
    enable = true;
    plugins = [ "git" ];
    # theme = "lambda";
  };

  <<nixos-section>>

  fonts.packages = with pkgs; [
    sarasa-gothic
  ];

  programs.steam.enable = true;
  # hardware.bluetooth.enable = true;

}

hardware config

Configure hardware.

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/6ecb174c-be9a-4cff-9525-235c86200dc6";
      fsType = "ext4";
    };

  boot.initrd.luks.devices."luks-b64b7411-f1bc-400c-9427-a51e91d90509".device = "/dev/disk/by-uuid/b64b7411-f1bc-400c-9427-a51e91d90509";

  fileSystems."/omnibus" =
    { device = "/dev/disk/by-uuid/8d60f73d-6b51-4f5c-a9a3-44353698266e";
      fsType = "ext4";
    };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlp61s0.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

home

Configure home environment using home-manager.

{ config, pkgs, ... }:

{
  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

  # Home Manager needs a bit of information about you and the
  # paths it should manage.
  home.username = "i";
  home.homeDirectory = "/home/i";

  # This value determines the Home Manager release that your
  # configuration is compatible with. This helps avoid breakage
  # when a new Home Manager release introduces backwards
  # incompatible changes.
  #
  # You can update Home Manager without changing this value. See
  # the Home Manager release notes for a list of state version
  # changes in each release.
  home.stateVersion = "21.05";

  nixpkgs.config.allowUnfree = true;
  home.packages = [
    pkgs.htop
    pkgs.signal-desktop
    pkgs.tmux
    pkgs.byobu
    pkgs.cachix
    pkgs.emacs29-pgtk
    pkgs.autoconf
    pkgs.automake
    pkgs.libpng
    pkgs.zlib
    # pkgs.poppler
    pkgs.sqlite
    # pkgs.calibre
    # pkgs.pythonPackages.pycryptodome # needed for calibre deDRM plugin - removed for now because it was trying to build a python2 version? figure out later which version is correct
    pkgs.soulseekqt
    pkgs.beets
    pkgs.nodePackages.node2nix
    pkgs.bibtool
    pkgs.pdfsandwich
    pkgs.pdftk
    pkgs.minidjvu
    pkgs.djvulibre
    pkgs.imagemagick
    pkgs.ruby
    pkgs.rubyPackages.rmagick
    pkgs.rubyPackages.nokogiri
    pkgs.rubyPackages.iconv
    pkgs.openjpeg
    pkgs.jbig2enc
    pkgs.pkg-config
    pkgs.file-rename
    pkgs.scantailor-advanced
    pkgs.tesseract5
    pkgs.poppler_utils
    pkgs.glances
    pkgs.pandoc
    pkgs.kolourpaint
    # pkgs.anki
    pkgs.anki-bin # Anki from source currently outdated in nixpkgs https://github.com/NixOS/nixpkgs/issues/78449
    pkgs.logseq
    pkgs.zotero
    pkgs.mpv
    # pkgs.appimage-run # for latest logseq
    # pkgs.puddletag # broken dependency (python3.10-m2r-0.2.1.drv) as of 2022-08-23
    pkgs.tup
    pkgs.tectonic
    pkgs.koreader
    pkgs.vlc
    pkgs.ripgrep
    # pkgs.syncplay #broke 2024-05-23
    pkgs.ungoogled-chromium
    pkgs.ncdu
    pkgs.haskellPackages.git-annex
    pkgs.sarasa-gothic
    pkgs.git-remote-gcrypt
    pkgs.briss
    pkgs.nodejs
    pkgs.biber
    pkgs.hocr-tools
    pkgs.transmission-gtk
    pkgs.fwupd
    pkgs.pciutils
    pkgs.kdePackages.kdeconnect-kde
    pkgs.kdePackages.yakuake
    # pkgs.libsForQt5.qtstyleplugin-kvantum
  ];

  programs.git = {
    enable = true;
    userName = "I W";
    userEmail = "wildthyme+git@protonmail.com";
  };

  programs.direnv.enable = true;
  programs.direnv.nix-direnv.enable = true;

  home.sessionPath = [
    "~/.local/bin"
    "~/.local/share/gem/ruby/2.7.0/bin"
    "~/.config/emacs/bin"
  ];

  programs.chromium = {
    enable = true;
    package = pkgs.ungoogled-chromium;
  };
  fonts.fontconfig.enable = true;

  targets.genericLinux.enable = true;

  programs.zsh = {
    enable = true;
    oh-my-zsh = {
      enable = true;
      theme = "random";
      plugins = [ "git" "history-substring-search" "vi-mode" ];
    };
  };

  programs.browserpass = {
    enable = true;
    browsers = [ "chromium" ];
  };

  i18n.inputMethod = {
    enabled = "fcitx5";
    fcitx5.addons = [ pkgs.fcitx5-chinese-addons pkgs.kdePackages.fcitx5-with-addons pkgs.kdePackages.fcitx5-qt ];
  };

  # services.kdeconnect.enable = true;
}