add flake, copytoram boot image, wip pxe
This commit is contained in:
100
nix/common.nix
Normal file
100
nix/common.nix
Normal file
@@ -0,0 +1,100 @@
|
||||
# Common NixOS configuration shared between ISO and netboot
|
||||
{ config, lib, pkgs, workshopSrc, ... }:
|
||||
|
||||
let
|
||||
workshopPackages = import ./packages.nix {
|
||||
inherit pkgs;
|
||||
kernelPackages = config.boot.kernelPackages;
|
||||
};
|
||||
in
|
||||
{
|
||||
# System identification
|
||||
system.stateVersion = "24.11";
|
||||
|
||||
# Use a recent stable kernel
|
||||
boot.kernelPackages = pkgs.linuxPackages_6_12;
|
||||
|
||||
# Set perf permissions for non-root users
|
||||
boot.kernel.sysctl = {
|
||||
"kernel.perf_event_paranoid" = 1;
|
||||
"kernel.kptr_restrict" = 0; # Allow reading kernel symbols
|
||||
};
|
||||
|
||||
# Workshop packages
|
||||
environment.systemPackages = workshopPackages ++ (with pkgs; [
|
||||
# Additional GUI utilities
|
||||
firefox # for viewing flamegraphs
|
||||
xfce4-terminal
|
||||
]);
|
||||
|
||||
# Create workshop user with auto-login
|
||||
users.users.workshop = {
|
||||
isNormalUser = true;
|
||||
description = "Workshop User";
|
||||
extraGroups = [ "wheel" "video" "audio" "networkmanager" ];
|
||||
initialPassword = "workshop";
|
||||
home = "/home/workshop";
|
||||
};
|
||||
|
||||
# Auto-login to workshop user
|
||||
services.displayManager.autoLogin = {
|
||||
enable = true;
|
||||
user = "workshop";
|
||||
};
|
||||
|
||||
# Allow passwordless sudo for workshop user
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
|
||||
# XFCE desktop environment
|
||||
services.xserver.desktopManager.xfce.enable = true;
|
||||
services.displayManager.defaultSession = "xfce";
|
||||
|
||||
# Embed workshop materials into home directory
|
||||
system.activationScripts.workshopMaterials = ''
|
||||
mkdir -p /home/workshop/perf-workshop
|
||||
cp -rT ${workshopSrc} /home/workshop/perf-workshop
|
||||
chmod -R u+w /home/workshop/perf-workshop
|
||||
chown -R workshop:users /home/workshop/perf-workshop
|
||||
'';
|
||||
|
||||
# Desktop shortcut for workshop
|
||||
environment.etc."skel/Desktop/Workshop.desktop".text = ''
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Performance Workshop
|
||||
Comment=Open terminal in workshop directory
|
||||
Exec=xfce4-terminal --working-directory=/home/workshop/perf-workshop
|
||||
Icon=utilities-terminal
|
||||
Terminal=false
|
||||
Categories=Development;
|
||||
'';
|
||||
|
||||
# Copy desktop shortcut for workshop user
|
||||
system.activationScripts.workshopDesktop = ''
|
||||
mkdir -p /home/workshop/Desktop
|
||||
cp /etc/skel/Desktop/Workshop.desktop /home/workshop/Desktop/
|
||||
chown -R workshop:users /home/workshop/Desktop
|
||||
chmod +x /home/workshop/Desktop/Workshop.desktop
|
||||
'';
|
||||
|
||||
# Networking
|
||||
networking = {
|
||||
hostName = "perf-workshop";
|
||||
networkmanager.enable = true;
|
||||
};
|
||||
|
||||
# Enable SSH for remote access (useful for debugging)
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PermitRootLogin = "no";
|
||||
PasswordAuthentication = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Timezone (can be changed by user)
|
||||
time.timeZone = "Asia/Kolkata";
|
||||
|
||||
# Locale
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
}
|
||||
17
nix/iso.nix
Normal file
17
nix/iso.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
# NixOS ISO-specific configuration
|
||||
{ config, lib, pkgs, workshopSrc, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./common.nix ];
|
||||
|
||||
# Enable copytoram - boots from USB, runs entirely from RAM
|
||||
boot.kernelParams = [ "copytoram" ];
|
||||
|
||||
# ISO image customization
|
||||
isoImage = {
|
||||
volumeID = lib.mkForce "PERF_WORKSHOP";
|
||||
makeEfiBootable = true;
|
||||
makeUsbBootable = true;
|
||||
};
|
||||
image.fileName = lib.mkForce "perf-workshop-${config.system.nixos.label}-x86_64.iso";
|
||||
}
|
||||
8
nix/netboot.nix
Normal file
8
nix/netboot.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
# NixOS netboot-specific configuration
|
||||
{ config, lib, pkgs, workshopSrc, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./common.nix ];
|
||||
|
||||
# Netboot runs entirely from RAM by default (initrd contains squashfs)
|
||||
}
|
||||
45
nix/packages.nix
Normal file
45
nix/packages.nix
Normal file
@@ -0,0 +1,45 @@
|
||||
# Shared package list for the Linux Performance Workshop
|
||||
{ pkgs, kernelPackages ? pkgs.linuxPackages }:
|
||||
|
||||
with pkgs; [
|
||||
# Build essentials
|
||||
gcc
|
||||
gnumake
|
||||
binutils
|
||||
pkg-config
|
||||
|
||||
# Performance and tracing tools
|
||||
perf
|
||||
strace
|
||||
ltrace
|
||||
htop
|
||||
bpftrace
|
||||
|
||||
# Python ecosystem
|
||||
(python3.withPackages (ps: with ps; [
|
||||
pip
|
||||
flask # for scenario7 pyroscope demo
|
||||
]))
|
||||
py-spy
|
||||
|
||||
# Benchmarking and debugging
|
||||
hyperfine
|
||||
valgrind
|
||||
flamegraph
|
||||
|
||||
# USDT/SDT support (provides sys/sdt.h)
|
||||
libsystemtap
|
||||
|
||||
# Continuous profiling
|
||||
pyroscope
|
||||
|
||||
# Utilities
|
||||
curl
|
||||
wget
|
||||
git
|
||||
file
|
||||
which
|
||||
less
|
||||
vim
|
||||
nano
|
||||
]
|
||||
33
nix/system-manager.nix
Normal file
33
nix/system-manager.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
# System-manager module for Ubuntu systems
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
workshopPackages = import ./packages.nix { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
config = {
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
|
||||
environment.systemPackages = workshopPackages;
|
||||
|
||||
# Create a script to configure perf permissions
|
||||
# (system-manager cannot set sysctl directly)
|
||||
environment.etc."perf-workshop-setup.sh" = {
|
||||
mode = "0755";
|
||||
text = ''
|
||||
#!/bin/sh
|
||||
# Run this script to enable perf for non-root users
|
||||
echo "Setting kernel.perf_event_paranoid=1..."
|
||||
sudo sysctl -w kernel.perf_event_paranoid=1
|
||||
|
||||
# Make it persistent
|
||||
if ! grep -q "kernel.perf_event_paranoid" /etc/sysctl.conf 2>/dev/null; then
|
||||
echo "kernel.perf_event_paranoid=1" | sudo tee -a /etc/sysctl.conf
|
||||
echo "Added to /etc/sysctl.conf for persistence"
|
||||
fi
|
||||
|
||||
echo "Done! You can now use perf as a regular user."
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user