Desktop nix configuration

This commit is contained in:
asonix 2022-09-27 17:29:38 -05:00
commit cbae960733
5 changed files with 449 additions and 0 deletions

60
config/nixpkgs/home.nix Normal file
View file

@ -0,0 +1,60 @@
{ config, pkgs, ... }:
{
imports = [ ./zsh.nix ./ssh.nix ];
home.username = "asonix";
home.homeDirectory = "/home/asonix";
nixpkgs.overlays = [
(self: super: {
obs-studio-plugins = super.obs-studio-plugins // {
obs-scene-switcher = super.libsForQt5.callPackage ./obs-scene-switcher/obs-scene-switcher.nix {};
obs-streamfx = super.libsForQt5.callPackage ./obs-streamfx/obs-streamfx.nix {};
};
})
];
home.packages = with pkgs; [
bat
bottom
dig
exa
htop
neofetch
starship
topgrade
gnome.dconf-editor
nextcloud-client
tdesktop
vlc
];
home.stateVersion = "22.05";
programs.home-manager.enable = true;
programs.git = {
enable = true;
userName = "asonix";
userEmail = "asonix@asonix.dog";
};
programs.bat.enable = true;
programs.obs-studio = {
enable = true;
plugins = with pkgs.obs-studio-plugins; [
obs-gstreamer
obs-move-transition
obs-multi-rtmp
obs-nvfbc
obs-pipewire-audio-capture
obs-scene-switcher
obs-streamfx
obs-vkcapture
obs-websocket
wlrobs
];
};
}

68
config/nixpkgs/ssh.nix Normal file
View file

@ -0,0 +1,68 @@
{ config, pkgs, ... }:
let
server = ({ hostname, user ? "asonix", port ? 22, proxyJump ? true }: {
hostname = hostname;
user = user;
identitiesOnly = true;
identityFile = "/home/asonix/.ssh/kube-rsa";
port = port;
proxyJump = if proxyJump then "router" else null;
});
in {
programs.ssh = {
enable = true;
matchBlocks = {
"github.com" = {
hostname = "github.com";
user = "git";
identitiesOnly = true;
identityFile = "/home/asonix/.ssh/github";
port = 22;
};
"gitlab.com" = {
hostname = "gitlab.com";
user = "git";
identitiesOnly = true;
identityFile = "/home/asonix/.ssh/gitlab";
port = 22;
};
"git.asonix.dog" = {
hostname = "git.asonix.dog";
user = "git";
identitiesOnly = true;
identityFile = "/home/asonix/.ssh/gitea-key";
port = 22;
};
"router" = server {
hostname = "ssh.asonix.dog";
port = 3128;
proxyJump = false;
};
"mc1" = server { hostname = "192.168.20.100"; };
"build2" = server { hostname = "192.168.20.99"; };
"bluestar" = server { hostname = "192.168.20.36"; };
"nextcloud" = server { hostname = "192.168.20.21"; };
"lionheart" = server { hostname = "192.168.5.6"; };
"redtail" = server { hostname = "192.168.20.23"; };
"redtail2" = server { hostname = "192.168.20.24"; };
"whitestorm" = server { hostname = "192.168.20.11"; };
"whitestorm2" = server { hostname = "192.168.20.26"; };
"gluster2" = server { hostname = "192.168.20.19"; user = "kube"; };
"gluster3" = server { hostname = "192.168.20.25"; };
"gluster4" = server { hostname = "192.168.20.33"; };
"k8s1" = server { hostname = "192.168.20.13"; user = "ubuntu"; };
"k8s2" = server { hostname = "192.168.20.16"; user = "ubuntu"; };
"k8s3" = server { hostname = "192.168.20.14"; user = "ubuntu"; };
"k8s4" = server { hostname = "192.168.20.18"; user = "ubuntu"; };
"k8s5" = server { hostname = "192.168.20.15"; user = "ubuntu"; };
"k8s6" = server { hostname = "192.168.20.20"; };
"k8s7" = server { hostname = "192.168.20.10"; };
"k8s8" = server { hostname = "192.168.20.27"; };
"k8s9" = server { hostname = "192.168.20.22"; };
"k8s10" = server { hostname = "192.168.20.34"; };
"q64b1" = server { hostname = "192.168.20.116"; };
};
};
}

89
config/nixpkgs/zsh.nix Normal file
View file

@ -0,0 +1,89 @@
{ config, pkgs, ... }:
{
programs.zsh = {
enable = true;
dotDir = ".config/zsh";
enableAutosuggestions = true;
shellAliases = {
cat = "bat";
l = "exa -l";
la = "exa -la";
ls = "exa";
};
initExtra = ''
bindkey -v
if [ "$IN_NIX_SHELL" = "impure" ]; then
alias b='cargo build'
alias c='cargo check'
alias r='cargo run'
alias t='cargo check'
alias v=lvim
alias vi=lvim
alias vim=lvim
else
alias v=nvim
alias vi=nvim
alias vim=nvim
alias dev="nix-shell $HOME/Development/default.nix"
fi
eval "$(starship init zsh)"
'';
plugins = with pkgs; [
{
name = "base16-shell";
src = fetchFromGitHub {
owner = "chriskempson";
repo = "base16-shell";
rev = "ae84047d378700bfdbabf0886c1fb5bb1033620f";
sha256 = "0qy+huAbPypEMkMumDtzcJdQQx5MVgsvgYu4Em/FGpQ=";
};
file = "base16-shell.plugin.zsh";
}
{
name = "zsh-completions";
src = fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-completions";
rev = "0.34.0";
sha256 = "qSobM4PRXjfsvoXY6ENqJGI9NEAaFFzlij6MPeTfT0o=";
};
file = "zsh-completions.plugin.zsh";
}
{
name = "zsh-nix-shell";
src = fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "v0.5.0";
sha256 = "IT3wpfw8zhiNQsrw59lbSWYh0NQ1CUdUtFzRzHlURH0=";
};
file = "nix-shell.plugin.zsh";
}
{
name = "zsh-syntax-highlighting";
src = fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-syntax-highlighting";
rev = "0.7.1";
sha256 = "gOG0NLlaJfotJfs+SUhGgLTNOnGLjoqnUp54V9aFJg8=";
};
file = "zsh-syntax-highlighting.zsh";
}
{
name = "zsh-z";
src = fetchFromGitHub {
owner = "agkozak";
repo = "zsh-z";
rev = "aaafebcd97424c570ee247e2aeb3da30444299cd";
sha256 = "9Wr4uZLk2CvINJilg4o72x0NEAl043lP30D3YnHk+ZA=";
};
file = "zsh-z.plugin.zsh";
}
];
};
}

209
etc/nixos/configuration.nix Normal file
View file

@ -0,0 +1,209 @@
# 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, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./wireguard.nix
<home-manager/nixos>
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.efi.efiSysMountPoint = "/boot/efi";
# Setup keyfile
boot.initrd.secrets = {
"/crypto_keyfile.bin" = null;
"/keyfile" = null;
};
# Enable swap on luks
boot.initrd.luks.devices."luks-28ea4268-e74a-4ed7-9484-b113c676124e".device = "/dev/disk/by-uuid/28ea4268-e74a-4ed7-9484-b113c676124e";
boot.initrd.luks.devices."luks-28ea4268-e74a-4ed7-9484-b113c676124e".keyFile = "/crypto_keyfile.bin";
boot.initrd.luks.devices."cryptdrive4".device = "/dev/disk/by-uuid/d2119824-fe98-449b-9d1b-2ab552568493";
boot.initrd.luks.devices."cryptdrive4".keyFile = "/keyfile";
boot.initrd.luks.devices."cryptdrive3".device = "/dev/disk/by-uuid/99dd440d-c6ed-4149-85a1-e8f22a6f2535";
boot.initrd.luks.devices."cryptdrive3".keyFile = "/keyfile";
boot.initrd.luks.devices."cryptdrive2".device = "/dev/disk/by-uuid/fd0c26d4-db05-4218-826c-51a87dd39eb5";
boot.initrd.luks.devices."cryptdrive2".keyFile = "/keyfile";
boot.initrd.luks.devices."cryptdrive1".device = "/dev/disk/by-uuid/20515efa-5380-4116-946e-7fe527ed3b92";
boot.initrd.luks.devices."cryptdrive1".keyFile = "/keyfile";
boot.kernelPackages = pkgs.linuxPackages_latest;
fileSystems = {
"/home/asonix/Development".options = [ "compress=zstd" ];
"/home/asonix/Diskimages".options = [ "compress=zstd" ];
"/home/asonix/Documents".options = [ "compress=zstd" ];
"/home/asonix/Downloads".options = [ "compress=zstd" ];
"/home/asonix/Games".options = [ "compress=zstd" ];
"/home/asonix/Games2".options = [ "compress=zstd" ];
"/home/asonix/Music".options = [ "compress=zstd" ];
"/home/asonix/Pictures".options = [ "compress=zstd" ];
"/home/asonix/Videos".options = [ "compress=zstd" ];
};
networking.hostName = "firestar"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
networking.networkmanager.enable = true;
# This makes Spyro Reignighted Trilogy not crash
networking.extraHosts =
''
0.0.0.0 datarouter.ol.epicgames.com
0.0.0.0 datarouter-weighted.ol.epicgames.com
'';
# Set your time zone.
time.timeZone = "America/Chicago";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.utf8";
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the Pantheon Desktop Environment.
services.xserver.displayManager.lightdm.enable = true;
services.xserver.desktopManager.pantheon.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "us";
xkbVariant = "";
};
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
services.flatpak.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
# Define a user account. Don't forget to set a password with passwd.
users.users.asonix = {
isNormalUser = true;
description = "Tavi";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [
firefox
];
};
users.defaultUserShell = pkgs.zsh;
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
docker-compose
git
neovim
vim
zsh
protonup
protontricks
wine-staging
winetricks
usbutils
pciutils
bolt
thunderbolt
wireguard-tools
];
systemd.packages = with pkgs; [
bolt
];
fonts = {
enableDefaultFonts = true;
fonts = with pkgs; [
fantasque-sans-mono
(nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
];
fontconfig.defaultFonts.monospace = [ "Fantasque Sans Mono" "Roboto Mono" ];
fontDir.enable = true;
};
programs.zsh.enable = true;
programs.steam = {
enable = true;
remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true;
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
virtualisation.docker.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.05"; # Did you read the comment?
}

23
etc/nixos/wireguard.nix Normal file
View file

@ -0,0 +1,23 @@
{ config, pkgs, ... }:
{
networking.firewall = {
allowedUDPPorts = [ 51820 ];
};
networking.wg-quick.interfaces = {
wg0 = {
address = [ "192.168.5.10/24" ];
dns = [ "192.168.5.1" ];
privateKeyFile = "/etc/wireguard/privatekey";
peers = [
{
publicKey = "lQYGzNIxgUrDmU32rlnmnc72dK7TSH7hxts3tMtE+VQ=";
allowedIPs = [ "192.168.5.0/24" "192.168.6.0/24" "192.168.20.0/24" ];
endpoint = "wg.asonix.dog:51820";
persistentKeepalive = 25;
}
];
};
};
}