initial nixos config

This commit is contained in:
Tyler Starr 2023-05-13 16:15:13 -07:00
parent 9f10eb7e44
commit 2c52325b2f
29 changed files with 729 additions and 14 deletions

View File

@ -186,6 +186,7 @@ bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle
# [o]pen applications
bindsym $mod+Return exec alacritty
bindsym $mod+u exec foot
bindsym $mod+a exec rofi -show drun -show-icons
bindsym $mod+Shift+a exec rofi -show window -show-icons
bindsym $mod+o mode open
@ -227,6 +228,6 @@ exec --no-startup-id "udiskie"
exec_always --no-startup-id "blueman-applet"
exec_always --no-startup-id "nm-applet"
exec_always --no-startup-id "flameshot"
#exec_always --no-startup-id "dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK"
exec_always --no-startup-id "dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK"
exec_always --no-startup-id "waybar"

View File

@ -353,7 +353,7 @@ rmKeys keys =
main = do
home <- getHomeDirectory
xmproc0 <- spawnPipe "xmobar -x 0 ~/.config/xmobar/xmobarrc"
xmproc1 <- spawnPipe "xmobar -x 1 ~/.config/xmobar/xmobarrc1"
--xmproc1 <- spawnPipe "xmobar -x 1 ~/.config/xmobar/xmobarrc1"
-- The monad
xmonad
$ docks
@ -381,7 +381,7 @@ main = do
handleEventHook = myEventHook,
logHook = workspaceHistoryHook <+> myLogHook <+> dynamicLogWithPP xmobarPP
{ ppOutput = \x -> hPutStrLn xmproc0 x
>> hPutStrLn xmproc1 x
-- >> hPutStrLn xmproc1 x
, ppCurrent = xmobarColor "#a6e22e" "" . wrap "[" "]" -- Current workspace in xmobar
, ppVisible = xmobarColor "#ae81ff" "" -- Visible but not current workspace
, ppHidden = xmobarColor "#ae81ff" "" . wrap "*" "" -- Hidden workspaces in xmobar

View File

@ -1 +1 @@
exec dbus-run-session xmonad
exec dbus-launch xmonad

View File

@ -1,9 +1,9 @@
export SSH_AUTH_SOCK=~/.ssh/ssh-agent.$HOSTNAME.sock
ssh-add -l 2>/dev/null >/dev/null
if [ $? -ge 2 ]; then
ssh-agent -a "$SSH_AUTH_SOCK" >/dev/null
fi
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
startx
fi
#export SSH_AUTH_SOCK=~/.ssh/ssh-agent.$HOSTNAME.sock
#ssh-add -l 2>/dev/null >/dev/null
#if [ $? -ge 2 ]; then
# ssh-agent -a "$SSH_AUTH_SOCK" >/dev/null
#fi
#
#if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
# startx
#fi

View File

@ -87,6 +87,9 @@ export PATH
export PATH=/home/tstarr/.nimble/bin:$PATH
export PATH=/home/tstarr/.cargo/bin:$PATH
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
@ -107,6 +110,7 @@ export EDITOR=nvim
#
alias ssway='export WLR_NO_HARDWARE_CURSORS=1 && sway --unsupported-gpu'
alias s='startx'
# tmuxinator
alias tsplat='tmuxinator start splat'

View File

@ -54,3 +54,11 @@
enabled: true
state: started
become: true
- name: Start and enable bluetooth
tags: ["once"]
systemd:
name: libvirtd
enabled: true
state: started
become: true

View File

@ -29,6 +29,9 @@
- lxsession
- nitrogen
- lxappearance
- virt-manager
- qemu-desktop
- dnsmasq
state: present
become: true
@ -49,3 +52,4 @@
use: yay
name:
- google-earth-pro
- google-chrome

View File

@ -18,7 +18,7 @@ Install Arch with BTRFS and partition:
@home/.snapshots /home/.snapshots
```
Select pipwire for audio, networkmanager for network, and install.
Select pipewire for audio, networkmanager for network, and install.
Run the following commands:

1
provision/nixos/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*~

64
provision/nixos/flake.lock generated Normal file
View File

@ -0,0 +1,64 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1668332334,
"narHash": "sha256-YT1qcE/MCqBO1Bi/Yr6GcFpNKsvmzrBKh8juyXDbxQc=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "bc90de24d898655542589237cc0a6ada7564cb6c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1668417584,
"narHash": "sha256-yeuEyxKPwsm5fIHN49L/syn9g5coxnPp3GsVquhrv5A=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "013fcdd106823416918004bb684c3c186d3c460f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
},
"utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

41
provision/nixos/flake.nix Normal file
View File

@ -0,0 +1,41 @@
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = github:nix-community/home-manager;
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ { self, nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
user = "tstarr";
in {
nixosConfigurations = {
kestrel = lib.nixosSystem {
inherit system;
specialArgs = { inherit user; };
modules = [
./hosts/kestrel/configuration.nix
./hosts/kestrel/hardware.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user; };
home-manager.users.${user} = {
imports = [ ./hosts/kestrel/home-configuration.nix ];
};
}
];
};
};
};
}

View File

@ -0,0 +1,290 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, user, lib, ... }:
{
nix = {
# Flakes!
package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
settings.auto-optimise-store = true;
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 7d";
};
};
# Use zen kernel
boot.kernelPackages = pkgs.linuxPackages_zen;
hardware.bluetooth.enable = true;
hardware.sensor.iio.enable = true;
services.blueman.enable = true;
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "kestrel"; # Define your hostname.
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
time.timeZone = "America/Los_Angeles";
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
programs.seahorse.enable = lib.mkForce false;
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
programs.ssh.askPassword = "";
services.xserver = {
enable = true;
layout = "us";
#displayManager.lightdm.greeters.mini = {
# enable = true;
# user = "${user}";
# extraConfig = ''
# # LightDM Mini Greeter Configuration
# #
# # To test your configuration out, run: lightdm --test-mode
#
# [greeter]
# # The user to login as.
# user = tstarr
# # Whether to show the password input's label.
# show-password-label = true
# # The text of the password input's label.
# password-label-text = Password:
# # The text shown when an invalid password is entered. May be blank.
# invalid-password-text = Invalid Password
# # Show a blinking cursor in the password input.
# show-input-cursor = true
# # The text alignment for the password input. Possible values are:
# # "left", "center", or "right"
# password-alignment = right
# # The number of characters that should fit into the password input.
# # A value of -1 will use GTK's default width.
# # Note: The entered width is a suggestion, GTK may render a narrower input.
# password-input-width = -1
# # Show the background image on all monitors or just the primary monitor.
# show-image-on-all-monitors = false
# # Show system info above the password input.
# # `<user>@<hostname>` is shown on the left side, & current time on the right.
# show-sys-info = false
#
#
# [greeter-hotkeys]
# # The modifier key used to trigger hotkeys. Possible values are:
# # "alt", "control" or "meta"
# # meta is also known as the "Windows"/"Super" key
# mod-key = meta
# # Power management shortcuts (single-key, case-sensitive)
# shutdown-key = s
# restart-key = r
# hibernate-key = h
# suspend-key = u
# # Cycle through available sessions
# session-key = e
#
#
# [greeter-theme]
# # A color from X11's `rgb.txt` file, a quoted hex string(`"#rrggbb"`) or a
# # RGB color(`rgb(r,g,b)`) are all acceptable formats.
#
# # The font to use for all text
# font = "Sans"
# # The font size to use for all text
# font-size = 1em
# # The font weight to use for all text
# font-weight = bold
# # The font style to use for all text
# font-style = normal
# # The default text color
# text-color = "#080800"
# # The color of the error text
# error-color = "#F8F8F0"
# # An absolute path to an optional background image.
# # Note: The file should be somewhere that LightDM has permissions to read
# # (e.g., /etc/lightdm/).
# background-image = ""
# # Background image size:
# # auto: unscaled
# # cover: scale image to fill screen space
# # contain: scale image to fit inside screen space
# # (more options: https://www.w3.org/TR/css-backgrounds-3/#background-size)
# background-image-size = auto
# # The screen's background color.
# background-color = "#1B1D1E"
# # The password window's background color
# window-color = "#F92672"
# # The color of the password window's border
# border-color = "#080800"
# # The width of the password window's border.
# # A trailing `px` is required.
# border-width = 2px
# # The pixels of empty space around the password input.
# # Do not include a trailing `px`.
# layout-space = 15
# # The character used to mask your password. Possible values are:
# # "-1", "0", or a single unicode character(including emojis)
# # A value of -1 uses the default bullet & 0 displays no characters when you
# # type your password.
# password-character = -1
# # The color of the text in the password input.
# password-color = "#F8F8F0"
# # The background color of the password input.
# password-background-color = "#1B1D1E"
# # The color of the password input's border.
# # Falls back to `border-color` if missing.
# password-border-color = "#080800"
# # The width of the password input's border.
# # Falls back to `border-width` if missing.
# password-border-width = 2px
# # The border radius of the password input.
# password-border-radius = 0.341125em
# # Override font for system info
# # Falls back to `font` if missing.
# sys-info-font = "Mono"
# # Set font size of system info
# # Falls back to `font-size` if missing.
# sys-info-font-size = 0.8em
# # Override color for system info text
# # Falls back to `text-color` if missing.
# #sys-info-color = "#080800"
# # Margins around the system info section
# # The default `-5px -5px -5px` works well with the password label enabled.
# # If you have the label disabled, you might want to try `-5px -5px 0px`
# sys-info-margin = -5px -5px -5px
# '';
# };
desktopManager.xterm.enable = false;
# Use nvidia drivers
videoDrivers = [ "nvidia" ];
screenSection = ''
Option "metamodes" "DP-4: 2560x1440_144 +2560+0, HDMI-0: 2560x1440_144 +0+0"
'';
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
# Use the xmonad wm
windowManager = {
xmonad = {
enable = true;
enableContribAndExtras = true;
};
};
};
hardware.opengl.enable = true;
# Enable CUPS to print documents.
services.printing.enable = true;
services.printing.drivers = [ pkgs.hplip ];
services.avahi.enable = true;
services.avahi.nssmdns = true;
# Enable sound.
sound.enable = true;
hardware.pulseaudio.enable = true;
hardware.pulseaudio.support32Bit = true;
# Add non-free packages
nixpkgs.config.allowUnfree = true;
fonts.fonts = with pkgs; [
nerdfonts
];
services = {
# USB automount
gvfs.enable = true;
# File sync
syncthing = {
enable = true;
user = "tstarr";
dataDir = "/home/tstarr/sync";
configDir = "/home/tstarr/.config/syncthing";
};
};
programs.steam = {
enable = true;
};
# Define a user account. Don't forget to set a password with passwd.
users.users.${user} = {
isNormalUser = true;
extraGroups = [ "wheel" "docker" ]; # Enable sudo for the user.
};
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
vim
neovim
git
haskellPackages.xmobar
killall
pciutils
syncthing
nnn
xidlehook
pamixer
vifm
play-with-mpv
mpv
autokey
gnome-extension-manager
gnome.gnome-tweaks
];
# Enable the OpenSSH daemon.
services.openssh.enable = true;
system.stateVersion = "22.05"; # Did you read the comment?
programs.bash.shellAliases = {
# Nix rebuild and switch
nr = "cd ~/.setup && sudo nixos-rebuild switch --flake .# && cd -";
sd = "cd ~/.setup/local/stow && stow . -t /home/${user} --no-folding && cd -";
};
virtualisation.docker.enable = true;
imports = [ ../../modules ];
modules = {
stow.enable = true;
services = {
samba.enable = true;
vfio.enable = true;
};
devel = {
python.enable = true;
engineering.enable = true;
};
editors = {
emacs.enable = true;
};
};
}

View File

@ -0,0 +1,51 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/3d7796f4-9950-49a3-a1d7-e21d35b19cdb";
fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" ];
};
fileSystems."/home" =
{ device = "/dev/disk/by-uuid/3d7796f4-9950-49a3-a1d7-e21d35b19cdb";
fsType = "btrfs";
options = [ "subvol=home" "compress=zstd" ];
};
fileSystems."/nix" =
{ device = "/dev/disk/by-uuid/3d7796f4-9950-49a3-a1d7-e21d35b19cdb";
fsType = "btrfs";
options = [ "subvol=nix" "noatime" "compress=zstd" ];
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/9AEE-2BD0";
fsType = "vfat";
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp3s0.useDHCP = lib.mkDefault true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
# high-resolution display
hardware.video.hidpi.enable = lib.mkDefault true;
}

View File

@ -0,0 +1,42 @@
{ config, pkgs, user, ... }:
{
home.username = "${user}";
home.homeDirectory = "/home/${user}";
home.stateVersion = "22.05";
programs.home-manager.enable = true;
programs.vscode = {
enable = true;
package = pkgs.vscode.fhsWithPackages (ps: with ps; [ ]);
};
home.packages = with pkgs; [
brave
rofi
alacritty
gamemode
lutris
prismlauncher
nitrogen
keepassxc
pcmanfm
discord
inkscape
gruvbox-dark-gtk
gruvbox-dark-icons-gtk
libreoffice-fresh
];
gtk = {
enable = true;
theme = {
name = "gruvbox-dark";
};
};
}

View File

View File

@ -0,0 +1,5 @@
{ ... }:
{
imports = [ ./devel ./services ./editors ./stow.nix ];
}

View File

@ -0,0 +1,5 @@
{ ... }:
{
imports = [ ./python.nix ./engineering.nix ];
}

View File

@ -0,0 +1,14 @@
# CAD and 3d printing and everything nice
{ config, lib, pkgs, user, ... }:
let
cfg = config.modules.devel.engineering;
in {
options.modules.devel.engineering.enable = lib.mkEnableOption "engineering";
config = lib.mkIf cfg.enable {
# Install packages
environment.systemPackages = with pkgs; [ super-slicer-latest freecad blender ];
};
}

View File

@ -0,0 +1,14 @@
# python with all the venom
{ config, lib, pkgs, user, ... }:
let
cfg = config.modules.devel.python;
in {
options.modules.devel.python.enable = lib.mkEnableOption "python";
config = lib.mkIf cfg.enable {
# Install packages
environment.systemPackages = with pkgs; [ python3 python3Packages.virtualenv beancount fava ];
};
}

View File

@ -0,0 +1,5 @@
{ ... }:
{
imports = [ ./emacs.nix ];
}

View File

@ -0,0 +1,22 @@
# emacs because my life isn't already hard enough
{ config, lib, pkgs, user, ... }:
let cfg = config.modules.editors.emacs;
in {
options.modules.editors.emacs.enable = lib.mkEnableOption "emacs";
config = lib.mkIf cfg.enable {
# Install packages
environment.systemPackages = with pkgs; [ emacs silver-searcher ripgrep ];
# Setup SystemCrafter's awesome crafted-emacs
system.userActivationScripts = {
installCraftedEmacs = ''
if [ ! -d "/home/${user}/.emacs.d" ]; then
${pkgs.git}/bin/git clone "https://github.com/SystemCrafters/crafted-emacs.git" "/home/${user}/.emacs.d"
fi
'';
};
};
}

View File

@ -0,0 +1,5 @@
{ ... }:
{
imports = [ ./samba.nix ./vfio.nix ];
}

View File

@ -0,0 +1,32 @@
# Samba for file sharing!
{ config, lib, pkgs, ... }:
let cfg = config.modules.services.samba;
in {
options.modules.services.samba.enable = lib.mkEnableOption "samba";
config = lib.mkIf cfg.enable {
services.samba = {
enable = true;
extraConfig = ''
browseable = yes
smb encrypt = required
'';
shares = {
homes = {
browseable = "no"; # note: each home will be browseable; the "homes" share will not.
"read only" = "no";
"guest ok" = "no";
};
};
};
# Curiously, `services.samba` does not automatically open
# the needed ports in the firewall.
networking.firewall.allowedTCPPorts = [ 445 139 ];
networking.firewall.allowedUDPPorts = [ 137 138 ];
# To make SMB mounting easier on the command line
environment.systemPackages = with pkgs; [ cifs-utils ];
};
}

View File

@ -0,0 +1,57 @@
# vfio setup for windows gaming with single gpu
{ config, lib, pkgs, user, ... }:
let cfg = config.modules.services.vfio;
in {
options.modules.services.vfio.enable = lib.mkEnableOption "samba";
config = lib.mkIf cfg.enable {
users.users.${user}.extraGroups = [ "qemu-libvirtd" "libvirtd" "kvm" ];
# Boot configuration
boot.kernelParams = [ "amd_iommu=on" "iommu=pt" ];
boot.kernelModules = [ "kvm-amd" "vfio-pci" ];
programs.dconf.enable = true;
environment.systemPackages = with pkgs; [ virt-manager ];
# Enable libvirtd
virtualisation.libvirtd = {
enable = true;
onBoot = "ignore";
onShutdown = "shutdown";
qemu.ovmf.enable = true;
qemu.runAsRoot = true;
};
# Place helper files where libvirt can get to them
environment.etc = {
"libvirt/hooks/qemu" = {
source = "/home/${user}/.setup/local/gpu-passthrough/qemu";
mode = "0755";
};
"libvirt/hooks/qemu.d/win10/prepare/begin/start.sh" = {
source = "/home/${user}/.setup/local/gpu-passthrough/start.sh";
mode = "0755";
};
"libvirt/hooks/qemu.d/win10/release/end/revert.sh" = {
source = "/home/${user}/.setup/local/gpu-passthrough/revert.sh";
mode = "0755";
};
"libvirt/qemu.conf" = {
source = "/home/${user}/.setup/local/gpu-passthrough/qemu.conf";
mode = "0755";
};
"libvirt/libvirtd.conf" = {
source = "/home/${user}/.setup/local/gpu-passthrough/libvirtd.conf";
mode = "0755";
};
"libvirt/patch.rom" = {
source = "/home/${user}/.setup/local/gpu-passthrough/patch.rom";
mode = "0755";
};
};
};
}

View File

@ -0,0 +1,27 @@
# stow config files for great sanity!
{ config, lib, pkgs, user, ... }:
let cfg = config.modules.stow;
in {
options.modules.stow.enable = lib.mkEnableOption "stow";
config = lib.mkIf cfg.enable {
# Install packages
environment.systemPackages = with pkgs; [ stow ];
# Run script that checks the .stow-on-rebuild file
# if it is 1 then it will re-stow else it won't
# this is to aviod the slow stow on every rebuild
system.userActivationScripts = {
stowDots = ''
if [ -f "/home/${user}/.stow-on-rebuild" ]; then
if [ $(cat "/home/${user}/.stow-on-rebuild") -eq 1 ]; then
cd "/home/${user}/.setup/local/stow"
${pkgs.stow}/bin/stow . -t "/home/${user}" --no-folding
fi
fi
'';
};
};
}

View File

View File

@ -0,0 +1,5 @@
{ ... }:
{
overrides = import ./overrides.nix;
}

View File

@ -0,0 +1,18 @@
# This overlay is used for overriding upstream packages.
self: super:
let
nixpkgs-master = import <nixpkgs-master> { inherit (super) config; };
nixpkgs-unstable = import <channels-nixos-unstable> { inherit (super) config; };
in {
inherit nixpkgs-master;
inherit nixpkgs-unstable;
qtile = super.qtile.overrideAttrs(oldAttrs: {
propagatedBuildInputs = oldAttrs.passthru.unwrapped.propagatedBuildInputs ++ (with self.python3Packages; [
pyyaml
]);
});
}

View File