Skip to content

Commit 7799700

Browse files
desktop
1 parent 9f7456d commit 7799700

19 files changed

+2156
-0
lines changed

desktop/l/Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#
2+
# nixos/laptops/l/Makefile
3+
#
4+
EXPECTED_HOSTNAME := l
5+
6+
ACTUAL_HOSTNAME := $(shell hostname)
7+
8+
all: check_hostname rebuild
9+
10+
check_hostname:
11+
ifeq ($(ACTUAL_HOSTNAME),$(EXPECTED_HOSTNAME))
12+
@echo "Hostnames match: $(ACTUAL_HOSTNAME)"
13+
else
14+
@echo "Error: Hostname does not match. Expected: $(EXPECTED_HOSTNAME), Got: $(ACTUAL_HOSTNAME)"
15+
@exit 1
16+
endif
17+
18+
rebuild:
19+
sudo nixos-rebuild switch --flake .
20+
21+
rebuild_t:
22+
sudo nixos-rebuild switch --flake .#t
23+
24+
#https://nixos.org/manual/nixos/unstable/index.html#sec-nix-network-issues
25+
#nixos-rebuild switch --option binary-caches http://my-cache.example.org/
26+
27+
impure:
28+
sudo nixos-rebuild switch --impure --flake .
29+
30+
rebuild_trace:
31+
sudo nixos-rebuild switch --show-trace --flake .
32+
33+
update:
34+
sudo nix flake update;
35+
36+
rebuild_old:
37+
# sudo cp ./flake.nix /etc/nixos/
38+
# sudo cp ./flake.lock /etc/nixos/
39+
# sudo cp ../../modules/* /etc/nixos/
40+
# sudo cp ./configuration.nix /etc/nixos/
41+
# #sudo cp ./home-manager.nix /etc/nixos/
42+
# sudo cp ./home.nix /etc/nixos/
43+
# sudo cp ./prometheus.nix /etc/nixos/
44+
# sudo cp ./*.nix /etc/nixos/
45+
# sudo nix-channel --update
46+
# sudo nixos-rebuild switch
47+
#sudo cp ./* /etc/nixos/
48+
sudo nix flake update;
49+
#sudo nix-channel --update;
50+
sudo nixos-rebuild switch --flake .
51+
52+
update_oldm.:
53+
sudo nix-channel --update
54+
sudo nixos-rebuild switch
55+
#nix-shell -p vim
56+
57+
restart_display_manager:
58+
sudo systemctl restart display-manager.service
59+
60+
# end

desktop/l/configuration.nix

Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
# Edit this configuration file to define what should be installed on
2+
# your system. Help is available in the configuration.nix(5) man page
3+
# and in the NixOS manual (accessible by running 'nixos-help').
4+
5+
# sudo nixos-rebuild switch
6+
# sudo nix-channel --update
7+
# nix-shell -p vim
8+
# nmcli device wifi connect MYSSID password PWORD
9+
# systemctl restart display-manager.service
10+
11+
{
12+
inputs,
13+
config,
14+
pkgs,
15+
lib,
16+
...
17+
}:
18+
19+
# https://nixos.wiki/wiki/FAQ#How_can_I_install_a_package_from_unstable_while_remaining_on_the_stable_channel.3F
20+
# https://discourse.nixos.org/t/differences-between-nix-channels/13998
21+
22+
{
23+
# https://nixos.wiki/wiki/NixOS_modules
24+
# https://nixos-and-flakes.thiscute.world/nixos-with-flakes/start-using-home-manager
25+
imports =
26+
[
27+
./hardware-configuration.nix
28+
./hardware-graphics.nix
29+
./sysctl.nix
30+
./wireless_desktop.nix
31+
./locale.nix
32+
./hosts.nix
33+
./firewall.nix
34+
#./systemdSystem.nix
35+
./systemPackages.nix
36+
# home manager is imported in the flake
37+
#./home.nix
38+
./nodeExporter.nix
39+
./prometheus.nix
40+
./grafana.nix
41+
# clickhouse
42+
#./docker-compose.nix
43+
./docker-daemon.nix
44+
#./smokeping.nix
45+
./distributed-builds.nix
46+
];
47+
48+
boot = {
49+
loader.systemd-boot = {
50+
enable = true;
51+
consoleMode = "max";
52+
memtest86.enable = true;
53+
};
54+
55+
loader.efi.canTouchEfiVariables = true;
56+
57+
# https://nixos.wiki/wiki/Linux_kernel
58+
#kernelPackages = pkgs.linuxPackages; # need to run this old kernel to allow nvidia driver to compile :(
59+
kernelPackages = pkgs.unstable.linuxPackages;
60+
#boot.kernelPackages = pkgs.linuxPackages_latest;
61+
#boot.kernelPackages = pkgs.linuxPackages_rpi4
62+
63+
# # https://github.com/tolgaerok/nixos-2405-gnome/blob/main/core/boot/efi/efi.nix#L56C5-L56C21
64+
# kernelParams = [
65+
# "nvidia-drm.modeset=1"
66+
# "nvidia-drm.fbdev=1"
67+
# # https://www.reddit.com/r/NixOS/comments/u5l3ya/cant_start_x_in_nixos/?rdt=56160
68+
# #"nomodeset"
69+
# ];
70+
71+
blacklistedKernelModules = [
72+
"nouveau"
73+
#"i915"
74+
];
75+
76+
# https://wiki.nixos.org/wiki/NixOS_on_ARM/Building_Images#Compiling_through_binfmt_QEMU
77+
# https://nixos.org/manual/nixos/stable/options#opt-boot.binfmt.emulatedSystems
78+
binfmt.emulatedSystems = [ "aarch64-linux" "riscv64-linux" ];
79+
80+
extraModulePackages = [
81+
config.boot.kernelPackages.v4l2loopback
82+
#pkgs.unstable.linuxPackages.nvidiaPackages.production
83+
];
84+
85+
extraModprobeConfig = ''
86+
options kvm_intel nested=1
87+
options v4l2loopback devices=1 video_nr=1 card_label="OBS Cam" exclusive_caps=1
88+
'';
89+
};
90+
91+
# https://fzakaria.com/2025/02/26/nix-pragmatism-nix-ld-and-envfs
92+
# Enable nix-ld for better compatibility with non-Nix binaries
93+
programs.nix-ld = {
94+
enable = false;
95+
# Add commonly needed libraries
96+
libraries = with pkgs; [
97+
stdenv.cc.cc.lib
98+
zlib
99+
libxml2
100+
# Add more libraries as needed
101+
];
102+
};
103+
104+
# Enable envfs for better compatibility with FHS expectations
105+
services.envfs = {
106+
enable = false;
107+
};
108+
109+
# For OBS
110+
security.polkit.enable = true;
111+
112+
nix = {
113+
settings = {
114+
auto-optimise-store = true;
115+
experimental-features = [ "nix-command" "flakes" ];
116+
download-buffer-size = "500000000";
117+
};
118+
gc = {
119+
automatic = true; # Enable automatic execution of the task
120+
dates = "daily"; # Schedule the task to run daily
121+
options = "--delete-older-than 10d"; # Specify options for the task: delete files older than 10 days
122+
randomizedDelaySec = "14m"; # Introduce a randomized delay of up to 14 minutes before executing the task
123+
};
124+
};
125+
126+
# https://nixos.wiki/wiki/Networking
127+
networking.hostName = "l";
128+
129+
time.timeZone = "America/Los_Angeles";
130+
131+
services.udev.packages = [ pkgs.gnome-settings-daemon ];
132+
# services.udev.packages = [ pkgs.gnome.gnome-settings-daemon ];
133+
134+
# https://nixos.wiki/wiki/NixOS_Wiki:Audio
135+
hardware.pulseaudio.enable = false; # Use Pipewire, the modern sound subsystem
136+
137+
security.rtkit.enable = true; # Enable RealtimeKit for audio purposes
138+
139+
services.pipewire = {
140+
enable = true;
141+
alsa.enable = true;
142+
alsa.support32Bit = true;
143+
pulse.enable = true;
144+
# Uncomment the following line if you want to use JACK applications
145+
# jack.enable = true;
146+
};
147+
148+
services.lldpd.enable = true;
149+
services.openssh.enable = true;
150+
services.timesyncd.enable = true;
151+
services.fstrim.enable = true;
152+
services.avahi = {
153+
enable = true;
154+
nssmdns4 = true;
155+
ipv4 = true;
156+
ipv6 = true;
157+
openFirewall = true;
158+
};
159+
160+
services.bpftune.enable = true;
161+
# Enable touchpad support (enabled default in most desktopManager).
162+
# services.libinput.enable = true;
163+
164+
# https://nixos.wiki/wiki/Printing
165+
services.printing.enable = true;
166+
167+
# https://wiki.nixos.org/wiki/Flameshot
168+
# services.flameshot = {
169+
# enable = true;
170+
# settings.General = {
171+
# showStartupLaunchMessage = false;
172+
# saveLastRegion = true;
173+
# };
174+
# };
175+
176+
systemd.services.modem-manager.enable = false;
177+
systemd.services."dbus-org.freedesktop.ModemManager1".enable = false;
178+
179+
services.clickhouse.enable = false;
180+
181+
# environment.variables defined in hardware-graphics.nix
182+
environment.sessionVariables = {
183+
TERM = "xterm-256color";
184+
#MY_VARIABLE = "my-value";
185+
#ANOTHER_VARIABLE = "another-value";
186+
};
187+
188+
users.users.das = {
189+
isNormalUser = true;
190+
description = "das";
191+
extraGroups = [ "wheel" "networkmanager" "kvm" "libvirtd" "docker" "video" ];
192+
packages = with pkgs; [
193+
];
194+
# https://nixos.wiki/wiki/SSH_public_key_authentication
195+
openssh.authorizedKeys.keys = [
196+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGMCFUMSCFJX95eLfm7P9r72NBp9I1FiXwNwJ+x/HGPV das@t"
197+
];
198+
};
199+
200+
# package moved to systemPackages.nix
201+
# environment.systemPackages = with pkgs; [
202+
203+
# Some programs need SUID wrappers, can be configured further or are
204+
# started in user sessions.
205+
# programs.mtr.enable = true;
206+
207+
programs.gnupg.agent = {
208+
enable = true;
209+
enableSSHSupport = true;
210+
};
211+
212+
# # https://wiki.hyprland.org/Nix/Hyprland-on-NixOS/
213+
programs.hyprland = {
214+
enable = true;
215+
# Nvidia patches are no longer needed
216+
#nvidiaPatches = true;
217+
xwayland.enable = true;
218+
};
219+
# programs.hyprland = {
220+
# enable = true;
221+
# # set the flake package
222+
# package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
223+
# # make sure to also set the portal package, so that they are in sync
224+
# portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
225+
# };
226+
227+
# programs.chromium.enable = true;
228+
# # programs.chromium.package = pkgs.google-chrome;
229+
# # https://nixos.wiki/wiki/Chromium#Enabling_native_Wayland_support
230+
# nixpkgs.config.chromium.commandLineArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
231+
# #programs.chromium.commandLineArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
232+
233+
# programs.firefox.enable = true;
234+
# # # https://github.com/TLATER/dotfiles/blob/master/nixos-modules/nvidia/default.nix
235+
# programs.firefox.preferences = {
236+
# "media.ffmpeg.vaapi.enabled" = true;
237+
# "media.rdd-ffmpeg.enabled" = true;
238+
# "media.av1.enabled" = true; # Won't work on the 2060
239+
# "gfx.x11-egl.force-enabled" = true;
240+
# "widget.dmabuf.force-enabled" = true;
241+
# };
242+
243+
# Open ports in the firewall.
244+
# networking.firewall.allowedTCPPorts = [ ... ];
245+
# networking.firewall.allowedUDPPorts = [ ... ];
246+
# Or disable the firewall altogether.
247+
# networking.firewall.enable = false;
248+
249+
# # https://nixos.wiki/wiki/Podman
250+
# virtualisation.podman = {
251+
# enable = true;
252+
# dockerCompat = true;
253+
# defaultNetwork.settings.dns_enabled = true;
254+
# autoPrune.enable = true;
255+
# };
256+
# #virtualisation.oci-containers.backend = "podman";
257+
# # virtualisation.oci-containers.containers = {
258+
# # container-name = {
259+
# # image = "container-image";
260+
# # autoStart = true;
261+
# # ports = [ "127.0.0.1:1234:1234" ];
262+
# # };
263+
# # };
264+
265+
# https://nixos.wiki/wiki/Virt-manager
266+
virtualisation.libvirtd.enable = true;
267+
programs.virt-manager.enable = true;
268+
virtualisation.spiceUSBRedirection.enable = true;
269+
270+
virtualisation.containers = {
271+
ociSeccompBpfHook.enable = true;
272+
};
273+
274+
# guest
275+
# services.qemuGuest.enable = true;
276+
# services.spice-vdagentd.enable = true;
277+
278+
# https://wiki.nixos.org/wiki/Laptop
279+
280+
# This value determines the NixOS release from which the default
281+
# settings for stateful data, like file locations and database versions
282+
# on your system were taken. It's perfectly fine and recommended to leave
283+
# this value at the release version of the first install of this system.
284+
# Before changing this value read the documentation for this option
285+
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
286+
#system.stateVersion = "23.11";
287+
288+
system.stateVersion = "24.11";
289+
290+
nixpkgs.config = {
291+
allowUnfree = true;
292+
# allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
293+
# "nvidia-x11"
294+
# "nvidia-settings"
295+
# "nvidia-persistenced"
296+
# ];
297+
};
298+
299+
# hardware.opengl = {
300+
# enable = true;
301+
# driSupport = true;
302+
# driSupport32Bit = true;
303+
# extraPackages = with pkgs; [
304+
# vaapiVdpau
305+
# libvdpau-va-gl
306+
# ];
307+
# };
308+
}

desktop/l/distributed-builds.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# latops/t/distributed-builds.nix
3+
#
4+
# https://nix.dev/tutorials/nixos/distributed-builds-setup.html#set-up-distributed-builds
5+
{ pkgs, ... }:
6+
{
7+
nix.distributedBuilds = true;
8+
nix.settings.builders-use-substitutes = true;
9+
10+
nix.buildMachines = [
11+
{
12+
hostName = "hp4.home";
13+
sshUser = "remotebuild";
14+
sshKey = "/root/.ssh/remotebuild";
15+
system = pkgs.stdenv.hostPlatform.system;
16+
supportedFeatures = [ "nixos-test" "big-parallel" "kvm" ];
17+
}
18+
];
19+
}

0 commit comments

Comments
 (0)