From 2c52325b2feab33c33e6bd270a4d303ebc40613b Mon Sep 17 00:00:00 2001 From: Tyler Starr Date: Sat, 13 May 2023 16:15:13 -0700 Subject: [PATCH] initial nixos config --- home/dot_config/sway/config | 3 +- home/dot_config/xmonad/xmonad.hs | 4 +- home/dot_xinitrc | 2 +- home/dot_zprofile | 18 +- home/dot_zshrc | 4 + .../arch/ansible/tasks/desktop/configs.yml | 8 + .../arch/ansible/tasks/desktop/packages.yml | 4 + provision/arch/readme.md | 2 +- provision/nixos/.gitignore | 1 + provision/nixos/flake.lock | 64 ++++ provision/nixos/flake.nix | 41 +++ .../nixos/hosts/kestrel/configuration.nix | 290 ++++++++++++++++++ provision/nixos/hosts/kestrel/hardware.nix | 51 +++ .../hosts/kestrel/home-configuration.nix | 42 +++ provision/nixos/modules/.placeholder | 0 provision/nixos/modules/default.nix | 5 + provision/nixos/modules/devel/default.nix | 5 + provision/nixos/modules/devel/engineering.nix | 14 + provision/nixos/modules/devel/python.nix | 14 + provision/nixos/modules/editors/default.nix | 5 + provision/nixos/modules/editors/emacs.nix | 22 ++ provision/nixos/modules/services/default.nix | 5 + provision/nixos/modules/services/samba.nix | 32 ++ provision/nixos/modules/services/vfio.nix | 57 ++++ provision/nixos/modules/stow.nix | 27 ++ provision/nixos/overlays/.placeholder | 0 provision/nixos/overlays/default.nix | 5 + provision/nixos/overlays/overrides.nix | 18 ++ provision/nixos/pkgs/.placeholder | 0 29 files changed, 729 insertions(+), 14 deletions(-) create mode 100644 provision/nixos/.gitignore create mode 100644 provision/nixos/flake.lock create mode 100644 provision/nixos/flake.nix create mode 100644 provision/nixos/hosts/kestrel/configuration.nix create mode 100644 provision/nixos/hosts/kestrel/hardware.nix create mode 100644 provision/nixos/hosts/kestrel/home-configuration.nix create mode 100644 provision/nixos/modules/.placeholder create mode 100644 provision/nixos/modules/default.nix create mode 100644 provision/nixos/modules/devel/default.nix create mode 100644 provision/nixos/modules/devel/engineering.nix create mode 100644 provision/nixos/modules/devel/python.nix create mode 100644 provision/nixos/modules/editors/default.nix create mode 100644 provision/nixos/modules/editors/emacs.nix create mode 100644 provision/nixos/modules/services/default.nix create mode 100644 provision/nixos/modules/services/samba.nix create mode 100644 provision/nixos/modules/services/vfio.nix create mode 100644 provision/nixos/modules/stow.nix create mode 100644 provision/nixos/overlays/.placeholder create mode 100644 provision/nixos/overlays/default.nix create mode 100644 provision/nixos/overlays/overrides.nix create mode 100644 provision/nixos/pkgs/.placeholder diff --git a/home/dot_config/sway/config b/home/dot_config/sway/config index 48acdff9..fc01f7bf 100644 --- a/home/dot_config/sway/config +++ b/home/dot_config/sway/config @@ -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" diff --git a/home/dot_config/xmonad/xmonad.hs b/home/dot_config/xmonad/xmonad.hs index 154a4c0d..11252bbd 100644 --- a/home/dot_config/xmonad/xmonad.hs +++ b/home/dot_config/xmonad/xmonad.hs @@ -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 diff --git a/home/dot_xinitrc b/home/dot_xinitrc index 7d01551a..c34a0587 100644 --- a/home/dot_xinitrc +++ b/home/dot_xinitrc @@ -1 +1 @@ -exec dbus-run-session xmonad +exec dbus-launch xmonad diff --git a/home/dot_zprofile b/home/dot_zprofile index f8234dbe..ce947113 100644 --- a/home/dot_zprofile +++ b/home/dot_zprofile @@ -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 diff --git a/home/dot_zshrc b/home/dot_zshrc index d13ec5a2..e46bbab6 100644 --- a/home/dot_zshrc +++ b/home/dot_zshrc @@ -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' diff --git a/provision/arch/ansible/tasks/desktop/configs.yml b/provision/arch/ansible/tasks/desktop/configs.yml index 400ed907..519e30e1 100644 --- a/provision/arch/ansible/tasks/desktop/configs.yml +++ b/provision/arch/ansible/tasks/desktop/configs.yml @@ -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 diff --git a/provision/arch/ansible/tasks/desktop/packages.yml b/provision/arch/ansible/tasks/desktop/packages.yml index 7cb97519..e5acc684 100644 --- a/provision/arch/ansible/tasks/desktop/packages.yml +++ b/provision/arch/ansible/tasks/desktop/packages.yml @@ -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 diff --git a/provision/arch/readme.md b/provision/arch/readme.md index 7d811fe8..0fa96264 100644 --- a/provision/arch/readme.md +++ b/provision/arch/readme.md @@ -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: diff --git a/provision/nixos/.gitignore b/provision/nixos/.gitignore new file mode 100644 index 00000000..b25c15b8 --- /dev/null +++ b/provision/nixos/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/provision/nixos/flake.lock b/provision/nixos/flake.lock new file mode 100644 index 00000000..8eb74708 --- /dev/null +++ b/provision/nixos/flake.lock @@ -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 +} diff --git a/provision/nixos/flake.nix b/provision/nixos/flake.nix new file mode 100644 index 00000000..84670c33 --- /dev/null +++ b/provision/nixos/flake.nix @@ -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 ]; + }; + } + ]; + }; + }; + }; +} diff --git a/provision/nixos/hosts/kestrel/configuration.nix b/provision/nixos/hosts/kestrel/configuration.nix new file mode 100644 index 00000000..b7c6aa01 --- /dev/null +++ b/provision/nixos/hosts/kestrel/configuration.nix @@ -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. + # # `@` 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; + }; + }; +} diff --git a/provision/nixos/hosts/kestrel/hardware.nix b/provision/nixos/hosts/kestrel/hardware.nix new file mode 100644 index 00000000..d4c01470 --- /dev/null +++ b/provision/nixos/hosts/kestrel/hardware.nix @@ -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..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; +} diff --git a/provision/nixos/hosts/kestrel/home-configuration.nix b/provision/nixos/hosts/kestrel/home-configuration.nix new file mode 100644 index 00000000..ad91ac1b --- /dev/null +++ b/provision/nixos/hosts/kestrel/home-configuration.nix @@ -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"; + }; + }; + + +} diff --git a/provision/nixos/modules/.placeholder b/provision/nixos/modules/.placeholder new file mode 100644 index 00000000..e69de29b diff --git a/provision/nixos/modules/default.nix b/provision/nixos/modules/default.nix new file mode 100644 index 00000000..676d7607 --- /dev/null +++ b/provision/nixos/modules/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + imports = [ ./devel ./services ./editors ./stow.nix ]; +} diff --git a/provision/nixos/modules/devel/default.nix b/provision/nixos/modules/devel/default.nix new file mode 100644 index 00000000..4ef52ea3 --- /dev/null +++ b/provision/nixos/modules/devel/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + imports = [ ./python.nix ./engineering.nix ]; +} diff --git a/provision/nixos/modules/devel/engineering.nix b/provision/nixos/modules/devel/engineering.nix new file mode 100644 index 00000000..e794e151 --- /dev/null +++ b/provision/nixos/modules/devel/engineering.nix @@ -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 ]; + }; +} diff --git a/provision/nixos/modules/devel/python.nix b/provision/nixos/modules/devel/python.nix new file mode 100644 index 00000000..04d4c6ca --- /dev/null +++ b/provision/nixos/modules/devel/python.nix @@ -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 ]; + }; +} \ No newline at end of file diff --git a/provision/nixos/modules/editors/default.nix b/provision/nixos/modules/editors/default.nix new file mode 100644 index 00000000..ca62e98a --- /dev/null +++ b/provision/nixos/modules/editors/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + imports = [ ./emacs.nix ]; +} diff --git a/provision/nixos/modules/editors/emacs.nix b/provision/nixos/modules/editors/emacs.nix new file mode 100644 index 00000000..7eb6c267 --- /dev/null +++ b/provision/nixos/modules/editors/emacs.nix @@ -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 + ''; + }; + }; +} diff --git a/provision/nixos/modules/services/default.nix b/provision/nixos/modules/services/default.nix new file mode 100644 index 00000000..2cd00db1 --- /dev/null +++ b/provision/nixos/modules/services/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + imports = [ ./samba.nix ./vfio.nix ]; +} diff --git a/provision/nixos/modules/services/samba.nix b/provision/nixos/modules/services/samba.nix new file mode 100644 index 00000000..2c5d073f --- /dev/null +++ b/provision/nixos/modules/services/samba.nix @@ -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 ]; + }; +} diff --git a/provision/nixos/modules/services/vfio.nix b/provision/nixos/modules/services/vfio.nix new file mode 100644 index 00000000..46853e29 --- /dev/null +++ b/provision/nixos/modules/services/vfio.nix @@ -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"; + }; + }; + }; +} diff --git a/provision/nixos/modules/stow.nix b/provision/nixos/modules/stow.nix new file mode 100644 index 00000000..b7ac2fd8 --- /dev/null +++ b/provision/nixos/modules/stow.nix @@ -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 + ''; + }; + }; +} diff --git a/provision/nixos/overlays/.placeholder b/provision/nixos/overlays/.placeholder new file mode 100644 index 00000000..e69de29b diff --git a/provision/nixos/overlays/default.nix b/provision/nixos/overlays/default.nix new file mode 100644 index 00000000..7ff75997 --- /dev/null +++ b/provision/nixos/overlays/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + overrides = import ./overrides.nix; +} diff --git a/provision/nixos/overlays/overrides.nix b/provision/nixos/overlays/overrides.nix new file mode 100644 index 00000000..08e35914 --- /dev/null +++ b/provision/nixos/overlays/overrides.nix @@ -0,0 +1,18 @@ +# This overlay is used for overriding upstream packages. + +self: super: + +let + nixpkgs-master = import { inherit (super) config; }; + nixpkgs-unstable = import { inherit (super) config; }; + +in { + inherit nixpkgs-master; + inherit nixpkgs-unstable; + + qtile = super.qtile.overrideAttrs(oldAttrs: { + propagatedBuildInputs = oldAttrs.passthru.unwrapped.propagatedBuildInputs ++ (with self.python3Packages; [ + pyyaml + ]); + }); +} diff --git a/provision/nixos/pkgs/.placeholder b/provision/nixos/pkgs/.placeholder new file mode 100644 index 00000000..e69de29b