Skip to content

Instantly share code, notes, and snippets.

@SamuelDavis
Last active November 3, 2024 03:00
Show Gist options
  • Save SamuelDavis/4d85e7f6300937ef6b22243026dae361 to your computer and use it in GitHub Desktop.
Save SamuelDavis/4d85e7f6300937ef6b22243026dae361 to your computer and use it in GitHub Desktop.
NixOS Global Config
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, lib, ... }:
let
unstablePkgs = import <unstable> { config = config.nixpkgs.config; };
defaultLocale = "en_US.UTF8";
defaultEditor = "nvim";
riderTarballUrl = "https://download.jetbrains.com/rider/JetBrains.Rider-2024.2.7.tar.gz";
riderChecksum = "71dda49ff9b2eeb982c0d9ea8ff70fde3f45ddc98e2be95c260bdc9cfbba7e42";
rider = pkgs.jetbrains.rider.overrideAttrs {
version = "2024.2.7";
src = pkgs.fetchurl {
url = riderTarballUrl;
sha256 = riderChecksum;
};
};
in
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./lenovo-x1-extreme-gen2-hardware-configuration.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos"; # Define your hostname.
networking.extraHosts = ''
127.0.0.1 localhost.localhost
127.0.0.1 localhost.test
'';
# 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/New_York";
# Select internationalisation properties.
i18n.defaultLocale = defaultLocale;
i18n.extraLocaleSettings = {
LC_ADDRESS = defaultLocale;
LC_IDENTIFICATION = defaultLocale;
LC_MEASUREMENT = defaultLocale;
LC_MONETARY = defaultLocale;
LC_NAME = defaultLocale;
LC_NUMERIC = defaultLocale;
LC_PAPER = defaultLocale;
LC_TELEPHONE = defaultLocale;
LC_TIME = defaultLocale;
};
# Configure Keymap in X11
services.xserver.xkb = {
layout = "us";
variant = "";
};
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.sdavis = {
isNormalUser = true;
description = "Samuel Davis";
extraGroups = [ "networkmanager" "wheel" "audio" "docker" "input" ];
packages = with pkgs; [
# browsers
brave
# neovim
ripgrep
# programming
git
mkcert
nodejs
php
php81Packages.composer
jetbrains.phpstorm
rider
godot_4
];
};
# Password Manager
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"1password"
"1password-cli"
"phpstorm"
"rider"
];
programs._1password.enable = true;
programs._1password-gui = {
enable = true;
polkitPolicyOwners = [ "sdavis" ];
};
# Window Manager
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
extraPackages = with pkgs; [
swaylock
swayidle
wl-clipboard
wlr-randr
foot # terminal
wmenu # app launcher
mako # notifications
brightnessctl # vis controls
playerctl # audio controls
# screenshots
grim
slurp
xdg-utils # mime-type app launching
];
};
# Fn Media Keys
programs.light.enable = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
pkgs.neovim
];
# Environment Variables
environment.sessionVariables = rec {
EDITOR = defaultEditor;
VISUAL = defaultEditor;
BROWSER = "brave";
};
environment.loginShellInit = ''
[[ "$(tty)" == /dev/tty1 ]] && sway --unsupported-gpu
'';
# Sound
sound.enable = true;
hardware.pulseaudio.enable = true;
# mkcert Local Certificates
security.pki = {
certificateFiles = [
/home/sdavis/.local/share/mkcert/rootCA.pem
];
};
# Display Drivers
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
services.xserver.videoDrivers = [ "nvidia-open" ];
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = true;
powerManagement.finegrained = true;
open = true;
nvidiaSettings = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
prime = {
offload = {
enable = true;
enableOffloadCmd = true;
};
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
};
};
# 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;
# 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 = "24.05"; # Did you read the comment?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment