Skip to content

Instantly share code, notes, and snippets.

@renxida
Created June 29, 2024 06:14
Show Gist options
  • Save renxida/fd3c50bbcdf5d9bb6f333bbf1e2c0ab7 to your computer and use it in GitHub Desktop.
Save renxida/fd3c50bbcdf5d9bb6f333bbf1e2c0ab7 to your computer and use it in GitHub Desktop.
configuration.nix
{ config, pkgs, lib, ... }:
{
# Import disko module
imports = [
(fetchTarball "https://github.com/nix-community/disko/archive/master.tar.gz")
];
# Bootloader configuration
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/sda"; # Install GRUB to the SSD
# Declarative Partitioning
disko.devices = {
disk = {
sda = {
device = "/dev/sda";
type = "disk";
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02"; # for GRUB MBR
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
sdb = {
device = "/dev/sdb";
type = "disk";
content = {
type = "gpt";
partitions = {
swap = {
size = "16G"; # Fixed swap size
content = {
type = "swap";
randomEncryption = true;
};
};
home = {
size = "100%"; # Use remaining space for home
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/home";
};
};
};
};
};
};
};
# Networking
networking = {
hostName = "chisel";
networkmanager.enable = true;
};
# Set your time zone
time.timeZone = "America/Los_Angeles";
# Enable X11 windowing system and i3 window manager
services.xserver = {
enable = true;
displayManager.lightdm.enable = true;
windowManager.i3 = {
enable = true;
extraPackages = with pkgs; [
dmenu
i3status
i3lock
i3blocks
];
};
};
# Configure i3 with some sane defaults (similar to Regolith)
environment.etc."i3/config".text = ''
# Use Windows key as mod
set $mod Mod4
# Font for window titles and bar
font pango:FiraCode Nerd Font 10
# Use Mouse+$mod to drag floating windows
floating_modifier $mod
# Start a terminal
bindsym $mod+Return exec ${pkgs.kitty}/bin/kitty
# Kill focused window
bindsym $mod+Shift+q kill
# Start dmenu (a program launcher)
bindsym $mod+d exec ${pkgs.dmenu}/bin/dmenu_run
# Change focus
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# Move focused window
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# Split in horizontal orientation
bindsym $mod+h split h
# Split in vertical orientation
bindsym $mod+v split v
# Enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# Change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# Toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# Change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# Focus the parent container
bindsym $mod+a focus parent
# Define names for default workspaces
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
# Switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10
# Move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10
# Reload the configuration file
bindsym $mod+Shift+c reload
# Restart i3 inplace
bindsym $mod+Shift+r restart
# Exit i3
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'Do you really want to exit i3?' -B 'Yes, exit i3' 'i3-msg exit'"
# Resize window mode
mode "resize" {
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"
# Start i3bar to display a workspace bar
bar {
status_command i3status
}
'';
# Define a user account
users.users.cedar = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "docker" ];
initialPassword = "changeme";
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile
environment.systemPackages = with pkgs; [
# Editors
neovim
vscode
# Web browsers
firefox
# Communication
discord
# Utilities
wget
curl
git
gh
azure-cli
docker
kitty
# Development tools
gcc
gdb
cmake
gnumake
clang
clang-tools
# Dropbox
dropbox
# SSH
openssh
];
# Docker configuration
virtualisation.docker.enable = true;
# SSH server configuration
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
};
};
# Fonts configuration
fonts.packages = with pkgs; [
(nerdfonts.override { fonts = [ "FiraCode" ]; })
];
# 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.
system.stateVersion = "23.11"; # Edit this to match your NixOS version
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment