New Nix config
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# User-specific configuration (generated by make init)
|
||||
settings.nix
|
||||
hardware-configuration.nix
|
||||
99
Makefile
Normal file
99
Makefile
Normal file
@@ -0,0 +1,99 @@
|
||||
.PHONY: init install link unlink rebuild update purge edit help
|
||||
|
||||
NIXOS_DIR := /etc/nixos
|
||||
REPO_DIR := $(shell pwd)
|
||||
SETTINGS := settings.nix
|
||||
|
||||
# Colors for output
|
||||
GREEN := \033[0;32m
|
||||
YELLOW := \033[0;33m
|
||||
RED := \033[0;31m
|
||||
NC := \033[0m # No Color
|
||||
|
||||
help:
|
||||
@echo "NixOS Config"
|
||||
@echo ""
|
||||
@echo " make init - first time setup"
|
||||
@echo " make rebuild - rebuild nixos"
|
||||
@echo " make update - upgrade + rebuild"
|
||||
@echo " make purge - garbage collect"
|
||||
@echo " make link - symlink to /etc/nixos"
|
||||
@echo " make unlink - remove symlink"
|
||||
@echo " make edit - edit settings.nix"
|
||||
|
||||
init:
|
||||
@if [ -f "$(SETTINGS)" ]; then \
|
||||
echo "$(YELLOW)settings.nix exists. overwrite? [y/N]$(NC)"; \
|
||||
read -r confirm; \
|
||||
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
|
||||
echo "keeping existing settings"; \
|
||||
exit 0; \
|
||||
fi; \
|
||||
fi
|
||||
@username=$$(whoami); \
|
||||
userdesc=$$(getent passwd $$username | cut -d: -f5 | cut -d, -f1); \
|
||||
userdesc=$${userdesc:-$$username}; \
|
||||
echo "user: $$username ($$userdesc)"; \
|
||||
echo ""; \
|
||||
echo "hostname:"; \
|
||||
read -r hostname; \
|
||||
echo "timezone [America/Edmonton]:"; \
|
||||
read -r tz; \
|
||||
tz=$${tz:-America/Edmonton}; \
|
||||
echo "locale [en_CA.UTF-8]:"; \
|
||||
read -r locale; \
|
||||
locale=$${locale:-en_CA.UTF-8}; \
|
||||
echo ""; \
|
||||
echo "{" > $(SETTINGS); \
|
||||
echo " hostname = \"$$hostname\";" >> $(SETTINGS); \
|
||||
echo " username = \"$$username\";" >> $(SETTINGS); \
|
||||
echo " userDescription = \"$$userdesc\";" >> $(SETTINGS); \
|
||||
echo " timezone = \"$$tz\";" >> $(SETTINGS); \
|
||||
echo " locale = \"$$locale\";" >> $(SETTINGS); \
|
||||
echo " userGroups = [ \"networkmanager\" \"wheel\" \"docker\" \"plugdev\" ];" >> $(SETTINGS); \
|
||||
echo "}" >> $(SETTINGS); \
|
||||
echo "wrote settings.nix"
|
||||
@if [ -f "/etc/nixos/hardware-configuration.nix" ]; then \
|
||||
cp /etc/nixos/hardware-configuration.nix $(REPO_DIR)/hardware-configuration.nix; \
|
||||
echo "copied hardware-configuration.nix"; \
|
||||
else \
|
||||
echo "$(YELLOW)no hardware-configuration.nix found - run nixos-generate-config first$(NC)"; \
|
||||
fi
|
||||
@$(MAKE) --no-print-directory link
|
||||
@echo ""
|
||||
@echo "done. run 'make rebuild' when ready"
|
||||
|
||||
link:
|
||||
@if [ -L "$(NIXOS_DIR)" ]; then \
|
||||
sudo rm $(NIXOS_DIR); \
|
||||
elif [ -d "$(NIXOS_DIR)" ]; then \
|
||||
sudo mv $(NIXOS_DIR) $(NIXOS_DIR).bak; \
|
||||
echo "backed up /etc/nixos to /etc/nixos.bak"; \
|
||||
fi
|
||||
@sudo ln -sf $(REPO_DIR) $(NIXOS_DIR)
|
||||
@echo "linked $(REPO_DIR) -> $(NIXOS_DIR)"
|
||||
|
||||
unlink:
|
||||
@if [ -L "$(NIXOS_DIR)" ]; then \
|
||||
sudo rm $(NIXOS_DIR); \
|
||||
sudo mkdir -p $(NIXOS_DIR); \
|
||||
echo "unlinked"; \
|
||||
else \
|
||||
echo "/etc/nixos is not a symlink"; \
|
||||
fi
|
||||
|
||||
rebuild:
|
||||
sudo nixos-rebuild switch
|
||||
|
||||
update:
|
||||
sudo nixos-rebuild switch --upgrade
|
||||
|
||||
purge:
|
||||
sudo nix-collect-garbage -d
|
||||
sudo /run/current-system/bin/switch-to-configuration boot
|
||||
|
||||
check:
|
||||
nix-instantiate '<nixpkgs/nixos>' -A system --dry-run
|
||||
|
||||
edit:
|
||||
@$${EDITOR:-nano} $(SETTINGS)
|
||||
@@ -1,5 +1,5 @@
|
||||
# My NixOS Config
|
||||
# NixOS Configuration
|
||||
|
||||
Use `nix:help` to list all commands
|
||||
Use nix:help to list all commands
|
||||
|
||||
** Note: All commit names are the unix timestamps for the config files
|
||||
@@ -12,11 +12,10 @@
|
||||
./modules/audio.nix
|
||||
./modules/users.nix
|
||||
./modules/packages.nix
|
||||
./modules/programs.nix
|
||||
./modules/hardware.nix
|
||||
./modules/services.nix
|
||||
./modules/aliases.nix
|
||||
];
|
||||
|
||||
system.stateVersion = "25.05";
|
||||
system.stateVersion = "25.11";
|
||||
}
|
||||
|
||||
@@ -4,24 +4,12 @@
|
||||
environment.shellAliases = {
|
||||
# Nix Commands
|
||||
"nix:rebuild" = "sudo nixos-rebuild switch";
|
||||
"nix:conf:edit" = "sudo nano ~/Developer/lavitz/configuration.nix";
|
||||
"nix:conf:sync" = "sudo rm -rf /etc/nixos/configuration.nix && sudo cp ~/Developer/lavitz/configuration.nix /etc/nixos/configuration.nix && sudo rm -rf /etc/nixos/modules && sudo cp -r ~/Developer/lavitz/modules /etc/nixos/";
|
||||
"nix:purge" = "sudo nix-collect-garbage -d && sudo /run/current-system/bin/switch-to-configuration boot";
|
||||
"nix:update" = "sudo nixos-rebuild switch --upgrade";
|
||||
"nix:edit:boot" = "sudo nano ~/Developer/lavitz/modules/boot.nix";
|
||||
"nix:edit:net" = "sudo nano ~/Developer/lavitz/modules/networking.nix";
|
||||
"nix:edit:desktop" = "sudo nano ~/Developer/lavitz/modules/desktop.nix";
|
||||
"nix:edit:audio" = "sudo nano ~/Developer/lavitz/modules/audio.nix";
|
||||
"nix:edit:users" = "sudo nano ~/Developer/lavitz/modules/users.nix";
|
||||
"nix:edit:pkgs" = "sudo nano ~/Developer/lavitz/modules/packages.nix";
|
||||
"nix:edit:programs" = "sudo nano ~/Developer/lavitz/modules/programs.nix";
|
||||
"nix:edit:hardware" = "sudo nano ~/Developer/lavitz/modules/hardware.nix";
|
||||
"nix:edit:services" = "sudo nano ~/Developer/lavitz/modules/services.nix";
|
||||
"nix:edit:aliases" = "sudo nano ~/Developer/lavitz/modules/aliases.nix";
|
||||
"nix:conf:push" = "sudo rm -rf /etc/nixos/configuration.nix && sudo cp ~/Developer/lavitz/configuration.nix /etc/nixos/configuration.nix && sudo rm -rf /etc/nixos/modules && sudo cp -r ~/Developer/lavitz/modules /etc/nixos/ && cd ~/Developer/lavitz && git add -A && git commit -m \"$(date -u +%s)\" && git push";
|
||||
"nix:conf:pull" = "cd ~/Developer/lavitz && git pull && sudo rm -rf /etc/nixos/configuration.nix && sudo cp ~/Developer/lavitz/configuration.nix /etc/nixos/configuration.nix && sudo rm -rf /etc/nixos/modules && sudo cp -r ~/Developer/lavitz/modules /etc/nixos/";
|
||||
|
||||
# General Commands
|
||||
"nix:purge" = "sudo nix-collect-garbage -d && sudo /run/current-system/bin/switch-to-configuration boot";
|
||||
"nix:edit" = "$EDITOR /etc/nixos";
|
||||
"nix:push" = "cd /etc/nixos && git add -A && git commit -m \"$(date -u +%s)\" && git push";
|
||||
"nix:pull" = "cd /etc/nixos && git pull";
|
||||
|
||||
"nf" = "neofetch";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Bootloader
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
# Kernel
|
||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||
boot.kernelParams = [ "preempt=full" ];
|
||||
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
|
||||
xdg.portal.config.common.default = [ "gnome" ];
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"nvidia_drm" "nvidia_modeset" "nvidia" "nvidia_uvm"
|
||||
];
|
||||
|
||||
boot.kernelParams = [ "preempt=full" ];
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Enable X11
|
||||
services.xserver.enable = true;
|
||||
|
||||
# Enable GNOME
|
||||
services.xserver.displayManager.gdm.enable = true;
|
||||
services.xserver.displayManager.gdm = {
|
||||
enable = true;
|
||||
wayland = true;
|
||||
};
|
||||
services.xserver.desktopManager.gnome.enable = true;
|
||||
|
||||
# Configure XKB
|
||||
services.xserver.xkb = {
|
||||
layout = "us";
|
||||
variant = "";
|
||||
};
|
||||
|
||||
# Enable CUPS for printing
|
||||
services.printing.enable = true;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Enable OpenGL
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
# Load nvidia driver for X and Wayland
|
||||
services.xserver.videoDrivers = ["nvidia"];
|
||||
|
||||
hardware.nvidia = {
|
||||
modesetting.enable = true;
|
||||
powerManagement.enable = true;
|
||||
powerManagement.finegrained = false;
|
||||
gsp.enable = true;
|
||||
open = false;
|
||||
nvidiaSettings = true;
|
||||
enable32Bit = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
settings = import ../settings.nix;
|
||||
in
|
||||
{
|
||||
# Time zone
|
||||
time.timeZone = "America/Edmonton";
|
||||
time.timeZone = settings.timezone;
|
||||
|
||||
# Internationalization properties
|
||||
i18n.defaultLocale = "en_CA.UTF-8";
|
||||
i18n.defaultLocale = settings.locale;
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
settings = import ../settings.nix;
|
||||
in
|
||||
{
|
||||
networking.hostName = "lavitz";
|
||||
networking.hostName = settings.hostname;
|
||||
|
||||
# Enable networking
|
||||
networking.networkmanager.enable = true;
|
||||
|
||||
@@ -91,4 +91,15 @@
|
||||
# GNOME extensions
|
||||
gnomeExtensions.appindicator
|
||||
];
|
||||
|
||||
# Programs with extra configuration
|
||||
programs.steam = {
|
||||
enable = true;
|
||||
remotePlay.openFirewall = true;
|
||||
dedicatedServer.openFirewall = true;
|
||||
localNetworkGameTransfers.openFirewall = true;
|
||||
};
|
||||
|
||||
programs.thunderbird.enable = true;
|
||||
programs.obs-studio.enable = true;
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# Steam
|
||||
programs.steam = {
|
||||
enable = true;
|
||||
remotePlay.openFirewall = true;
|
||||
dedicatedServer.openFirewall = true;
|
||||
localNetworkGameTransfers.openFirewall = true;
|
||||
};
|
||||
|
||||
# Thunderbird
|
||||
programs.thunderbird.enable = true;
|
||||
|
||||
# OBS
|
||||
programs.obs-studio = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
programs.obs-studio.package = (pkgs.obs-studio.override {
|
||||
cudaSupport = true;
|
||||
});
|
||||
}
|
||||
@@ -4,14 +4,6 @@
|
||||
# Enable the OpenSSH daemon
|
||||
services.openssh.enable = true;
|
||||
|
||||
# Sleep config for NVIDIA
|
||||
systemd.sleep.extraConfig = ''
|
||||
AllowSuspend=yes
|
||||
AllowHibernation=no
|
||||
AllowHybridSleep=no
|
||||
AllowSuspendThenHibernate=no
|
||||
'';
|
||||
|
||||
# Tailscale
|
||||
services.tailscale.enable = true;
|
||||
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
settings = import ../settings.nix;
|
||||
in
|
||||
{
|
||||
# Groups
|
||||
users.groups.plugdev = {
|
||||
gid = 69420;
|
||||
};
|
||||
users.groups.plugdev.gid = 69420;
|
||||
|
||||
# User Accounts
|
||||
users.users.atridad = {
|
||||
users.users.${settings.username} = {
|
||||
isNormalUser = true;
|
||||
description = "Atridad";
|
||||
extraGroups = [ "networkmanager" "wheel" "docker" "plugdev" ];
|
||||
description = settings.userDescription;
|
||||
extraGroups = settings.userGroups;
|
||||
};
|
||||
}
|
||||
|
||||
8
settings.example.nix
Normal file
8
settings.example.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
hostname = "nixos";
|
||||
username = "user";
|
||||
userDescription = "User";
|
||||
timezone = "America/Edmonton";
|
||||
locale = "en_CA.UTF-8";
|
||||
userGroups = [ "networkmanager" "wheel" "docker" "plugdev" ];
|
||||
}
|
||||
Reference in New Issue
Block a user