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
|
** Note: All commit names are the unix timestamps for the config files
|
||||||
@@ -12,11 +12,10 @@
|
|||||||
./modules/audio.nix
|
./modules/audio.nix
|
||||||
./modules/users.nix
|
./modules/users.nix
|
||||||
./modules/packages.nix
|
./modules/packages.nix
|
||||||
./modules/programs.nix
|
|
||||||
./modules/hardware.nix
|
./modules/hardware.nix
|
||||||
./modules/services.nix
|
./modules/services.nix
|
||||||
./modules/aliases.nix
|
./modules/aliases.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
system.stateVersion = "25.05";
|
system.stateVersion = "25.11";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,24 +4,12 @@
|
|||||||
environment.shellAliases = {
|
environment.shellAliases = {
|
||||||
# Nix Commands
|
# Nix Commands
|
||||||
"nix:rebuild" = "sudo nixos-rebuild switch";
|
"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:update" = "sudo nixos-rebuild switch --upgrade";
|
||||||
"nix:edit:boot" = "sudo nano ~/Developer/lavitz/modules/boot.nix";
|
"nix:purge" = "sudo nix-collect-garbage -d && sudo /run/current-system/bin/switch-to-configuration boot";
|
||||||
"nix:edit:net" = "sudo nano ~/Developer/lavitz/modules/networking.nix";
|
"nix:edit" = "$EDITOR /etc/nixos";
|
||||||
"nix:edit:desktop" = "sudo nano ~/Developer/lavitz/modules/desktop.nix";
|
"nix:push" = "cd /etc/nixos && git add -A && git commit -m \"$(date -u +%s)\" && git push";
|
||||||
"nix:edit:audio" = "sudo nano ~/Developer/lavitz/modules/audio.nix";
|
"nix:pull" = "cd /etc/nixos && git pull";
|
||||||
"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
|
|
||||||
"nf" = "neofetch";
|
"nf" = "neofetch";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,12 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
# Bootloader
|
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
# Kernel
|
|
||||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||||
|
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||||
|
boot.kernelParams = [ "preempt=full" ];
|
||||||
|
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
|
||||||
xdg.portal.config.common.default = [ "gnome" ];
|
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, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
# Enable X11
|
|
||||||
services.xserver.enable = true;
|
services.xserver.enable = true;
|
||||||
|
services.xserver.displayManager.gdm = {
|
||||||
# Enable GNOME
|
enable = true;
|
||||||
services.xserver.displayManager.gdm.enable = true;
|
wayland = true;
|
||||||
|
};
|
||||||
services.xserver.desktopManager.gnome.enable = true;
|
services.xserver.desktopManager.gnome.enable = true;
|
||||||
|
|
||||||
# Configure XKB
|
|
||||||
services.xserver.xkb = {
|
services.xserver.xkb = {
|
||||||
layout = "us";
|
layout = "us";
|
||||||
variant = "";
|
variant = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Enable CUPS for printing
|
|
||||||
services.printing.enable = true;
|
services.printing.enable = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,8 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
# Enable OpenGL
|
|
||||||
hardware.graphics = {
|
hardware.graphics = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
enable32Bit = 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;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
settings = import ../settings.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
# Time zone
|
# Time zone
|
||||||
time.timeZone = "America/Edmonton";
|
time.timeZone = settings.timezone;
|
||||||
|
|
||||||
# Internationalization properties
|
# Internationalization properties
|
||||||
i18n.defaultLocale = "en_CA.UTF-8";
|
i18n.defaultLocale = settings.locale;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
settings = import ../settings.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
networking.hostName = "lavitz";
|
networking.hostName = settings.hostname;
|
||||||
|
|
||||||
# Enable networking
|
# Enable networking
|
||||||
networking.networkmanager.enable = true;
|
networking.networkmanager.enable = true;
|
||||||
|
|||||||
@@ -91,4 +91,15 @@
|
|||||||
# GNOME extensions
|
# GNOME extensions
|
||||||
gnomeExtensions.appindicator
|
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
|
# Enable the OpenSSH daemon
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
|
|
||||||
# Sleep config for NVIDIA
|
|
||||||
systemd.sleep.extraConfig = ''
|
|
||||||
AllowSuspend=yes
|
|
||||||
AllowHibernation=no
|
|
||||||
AllowHybridSleep=no
|
|
||||||
AllowSuspendThenHibernate=no
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Tailscale
|
# Tailscale
|
||||||
services.tailscale.enable = true;
|
services.tailscale.enable = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
settings = import ../settings.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
# Groups
|
users.groups.plugdev.gid = 69420;
|
||||||
users.groups.plugdev = {
|
|
||||||
gid = 69420;
|
|
||||||
};
|
|
||||||
|
|
||||||
# User Accounts
|
users.users.${settings.username} = {
|
||||||
users.users.atridad = {
|
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
description = "Atridad";
|
description = settings.userDescription;
|
||||||
extraGroups = [ "networkmanager" "wheel" "docker" "plugdev" ];
|
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