From 3f7e4e32c30889042d039777086709fb5f58ff72 Mon Sep 17 00:00:00 2001 From: Felix Wittwer Date: Thu, 18 Nov 2021 19:04:41 +0100 Subject: [PATCH] Clean up nix config --- .gitignore | 2 + entropy/.vimrc | 1 + entropy/nixos/configuration.nix | 227 +++++------------------ entropy/nixos/modules/audio.nix | 33 ++++ entropy/nixos/modules/kde.nix | 12 ++ entropy/nixos/modules/printing.nix | 39 ++++ entropy/nixos/modules/sway.nix | 110 +---------- entropy/nixos/modules/video.nix | 32 ++++ entropy/nixos/modules/virtualisation.nix | 16 ++ 9 files changed, 191 insertions(+), 281 deletions(-) create mode 100644 entropy/nixos/modules/audio.nix create mode 100644 entropy/nixos/modules/kde.nix create mode 100644 entropy/nixos/modules/printing.nix create mode 100644 entropy/nixos/modules/video.nix create mode 100644 entropy/nixos/modules/virtualisation.nix diff --git a/.gitignore b/.gitignore index b4c2316..60c9838 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ entropy/mail/neomutt/signature.txt entropy/mail/neomutt/notmuch-hook.sh entropy/mail/neomutt/whoami.muttrc entropy/vpn/credentials.txt + +**/*.swp diff --git a/entropy/.vimrc b/entropy/.vimrc index b9e4ea9..671b7bd 100644 --- a/entropy/.vimrc +++ b/entropy/.vimrc @@ -26,6 +26,7 @@ Plug 'rust-lang/rust.vim', { 'for': 'rust' } Plug 'cespare/vim-toml', { 'for': 'toml' } Plug 'keith/swift.vim', { 'for': 'swift' } Plug 'neovimhaskell/haskell-vim', { 'for': 'haskell' } +Plug 'jalvesaq/Nvim-R', {'branch': 'stable', 'for': 'r'} " Lingua Franca Plug 'lf-lang/lingua-franca.vim' diff --git a/entropy/nixos/configuration.nix b/entropy/nixos/configuration.nix index d074783..a4066a9 100644 --- a/entropy/nixos/configuration.nix +++ b/entropy/nixos/configuration.nix @@ -8,47 +8,39 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + + ./modules/audio.nix + ./modules/video.nix + ./modules/virtualisation.nix + + # Desktop configuration + ./modules/sway.nix + ./modules/kde.nix + # old i3 compositor + # ./modules/i3.nix + + ./modules/printing.nix + ./modules/backup.nix + # include and configure R ./modules/r.nix # python with modules ./modules/python.nix - # Wayland - ./modules/sway.nix - # old i3 compositor - # ./modules/i3.nix - ./modules/backup.nix ]; # set up LUKS discovery boot.initrd.luks.devices.cryptlvm.device = "/dev/disk/by-uuid/f382cd01-9048-4b1b-8a73-48e1f61e6c08"; - # make the screen usable - #hardware.video.hidpi.enable = true; - #services.xserver.dpi = 180; - # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - # enable powertop for saving power - #powerManagement.powertop.enable = true; - + # ------------ networking --------------------------------------------------- networking.hostName = "entropy"; # Define your hostname. networking.wireless = { enable = true; # Enables wireless support via wpa_supplicant. interfaces = [ "wlp0s20f3" ]; }; - - # Set your time zone. - time.timeZone = "Europe/Berlin"; - - # geoclue2 does not yield a location at home, so I'll make the manual configuration the default - # location.provider = "geoclue2"; - location.provider = "manual"; - # using the location of the cafe ascii should be good enough - location.latitude = 51.0250869; - location.longitude = 13.7210005; - # The global useDHCP flag is deprecated, therefore explicitly set to false here. # Per-interface useDHCP will be mandatory in the future, so this generated config # replicates the default behaviour. @@ -58,31 +50,26 @@ networking.interfaces.enp0s20f0u2u1.useDHCP = true; networking.interfaces.wlp0s20f3.useDHCP = true; - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + # enable OpenVPN for connecting to the TUD network + services.openvpn.servers.tud = { + config = '' config /home/felix/.config/vpn/TUD.ovpn ''; + autoStart = false; #true; + updateResolvConf = true; + }; - nixpkgs.config = { - # enable hardware-accelerated graphics - packageOverrides = pkgs: { - vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; }; - # add nixpkgs for unstable package sources - #unstable = import { - #config = config.nixpkgs.config; - #}; - }; - # allow unfree licenced packges - allowUnfree = true; - }; - hardware.opengl = { - enable = true; - extraPackages = with pkgs; [ - intel-media-driver # LIBVA_DRIVER_NAME=iHD - vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium) - vaapiVdpau - libvdpau-va-gl - ]; - }; + # for SAMBA file shares + services.gvfs.enable = true; + + + # ------------ time, location & input --------------------------------------- + # Set your time zone. + time.timeZone = "Europe/Berlin"; + # geoclue2 does not yield a location at home, so I'll make the manual configuration the default + # location.provider = "geoclue2"; + location.provider = "manual"; + # using the location of the cafe ascii should be good enough + location.latitude = 51.0250869; + location.longitude = 13.7210005; # Select internationalisation properties. i18n.defaultLocale = "en_US.UTF-8"; @@ -100,75 +87,8 @@ # enable touchpad support services.xserver.libinput.enable = true; - # Enable CUPS to print documents. - services.printing.enable = true; - services.printing.drivers = [ - pkgs.gutenprint - pkgs.epson-escpr - ]; - - # set up my printer at home - hardware.printers.ensurePrinters = [ - { - description = "My private printer"; - deviceUri = "https://192.168.178.30:631/ipp/print"; - location = "Home"; - model = "epson-inkjet-printer-escpr/Epson-XP-322_323_325_Series-epson-escpr-en.ppd"; - name = "Home"; - } - ]; - - # setup the printers at work - #hardware.printers.ensurePrinters = [ - #{ - #description = "CC printer"; - #deviceUri = ""; - #location = "BAR/III51"; - #model = "Ricoh-MP_C307_PS.ppd"; - #name = "CC_small"; - #} - #{ - #description = "PD printer (A3)"; - #deviceUri = ""; - #location = "BAR/III71B"; - #model = "Ricoh-MP_C3004_PS.ppd"; - #name = "PD_Chair"; - #} - #]; - - # Enable sound. - sound.enable = true; - # configure pulseaudio to work with bluetooth headsets using aptx - hardware.pulseaudio = { - enable = true; - extraModules = [ pkgs.pulseaudio-modules-bt ]; - # the full package is necessary for BT support - package = pkgs.pulseaudioFull; - # switch to bluetooth automatically if they are connected - extraConfig = " - load-module module-switch-on-connect - load-module module-bluetooth-policy auto_switch=2 - "; - }; - nixpkgs.config.pulseaudio = true; - - # enable bluetooth in general and add a simple tool for connecting devices - hardware.bluetooth = { - enable = true; - package = pkgs.bluezFull; - # enable A2DP - settings = { - General = { - Enable = "Source,Sink,Media"; - Disable = "Socket"; - }; - }; - }; - services.blueman.enable = true; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; + # ------------ security ----------------------------------------------------- # Define a user account. Don't forget to set a password with ‘passwd’. users.users.felix = { createHome = true; @@ -189,36 +109,29 @@ } ]; + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryFlavor = "curses"; + }; + + services.udev.packages = [ pkgs.libu2f-host ]; + ## enable fingerprint reader #services.fprintd.enable = true; #security.pam.services.login.fprintAuth = true; ##security.pam.services.xscreensaver.fprintAuth = true; #security.pam.services.sudo.fprintAuth = true; - # set up virtualization with virtualbox - virtualisation.virtualbox.host.enable = true; - # I'm gonna keep this disabled for the sake of my sanity - # virtualisation.virtualbox.host.enableExtensionPack = true; - users.extraGroups.vboxusers.members = [ "felix" ]; - # enable docker on-demand - virtualisation.docker.enable = true; - virtualisation.docker.enableOnBoot = false; - users.extraGroups.docker.members = [ "felix" ]; + # ------------ programs ----------------------------------------------------- + programs.fish.enable = true; + programs.vim.defaultEditor = true; - # add overlay for the LF IDE - #nixpkgs.overlays = [ - #(self: super: { - #lingua-franca-ide = super.callPackage ./overlays/lf-eclipse.nix { }; - #}) - #]; - - # List packages installed in system profile. To search, run: - # $ nix search wget + # List of packages installed in system profile. environment.systemPackages = with pkgs; [ ## basic command line tooling wget - vim emacs w3m htop @@ -276,11 +189,10 @@ kitty vscodium eclipses.eclipse-platform - typora + # typora # aged electron? firefox-wayland # torbrowser #next - # rstudio ## time tracking watson ## file managers @@ -322,8 +234,6 @@ xdg-desktop-portal-wlr ]; - #services.emacs.enable = true; - # install fonts fonts.fonts = with pkgs; [ font-awesome @@ -341,40 +251,6 @@ }) ]; - # 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; - # }; - programs.fish.enable = true; - programs.vim.defaultEditor = true; - - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - pinentryFlavor = "curses"; - }; - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - services.udev.packages = [ pkgs.libu2f-host ]; - # for SAMBA file shares - services.gvfs.enable = true; - - # allow brightness control - services.illum.enable = true; - - # enable OpenVPN for connecting to the TUD network - services.openvpn.servers.tud = { - config = '' config /home/felix/.config/vpn/TUD.ovpn ''; - autoStart = false; #true; - updateResolvConf = true; - }; - # periodic automated mail fetching systemd.user.services.mailfetch = { enable = true; @@ -391,13 +267,6 @@ ''; }; - # 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. It‘s perfectly fine and recommended to leave diff --git a/entropy/nixos/modules/audio.nix b/entropy/nixos/modules/audio.nix new file mode 100644 index 0000000..0a3c90d --- /dev/null +++ b/entropy/nixos/modules/audio.nix @@ -0,0 +1,33 @@ +{ config, pkgs, ... }: + +{ + # Enable sound. + sound.enable = true; + # configure pulseaudio to work with bluetooth headsets using aptx + hardware.pulseaudio = { + enable = true; + extraModules = [ pkgs.pulseaudio-modules-bt ]; + # the full package is necessary for BT support + package = pkgs.pulseaudioFull; + # switch to bluetooth automatically if they are connected + extraConfig = " + load-module module-switch-on-connect + load-module module-bluetooth-policy auto_switch=2 + "; + }; + nixpkgs.config.pulseaudio = true; + + # enable bluetooth in general and add a simple tool for connecting devices + hardware.bluetooth = { + enable = true; + package = pkgs.bluezFull; + # enable A2DP + settings = { + General = { + Enable = "Source,Sink,Media"; + Disable = "Socket"; + }; + }; + }; + services.blueman.enable = true; +} diff --git a/entropy/nixos/modules/kde.nix b/entropy/nixos/modules/kde.nix new file mode 100644 index 0000000..404d06c --- /dev/null +++ b/entropy/nixos/modules/kde.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: + +{ + services.xserver.desktopManager.plasma5 = { + enable = true; + }; + #environment.variables = { + #GDK_SCALE = "2"; + #GDK_DPI_SCALE = "0.5"; + #_JAVA_OPTIONS = "-Dsun.java2d.uiScale=2"; + #}; +} diff --git a/entropy/nixos/modules/printing.nix b/entropy/nixos/modules/printing.nix new file mode 100644 index 0000000..d60eef1 --- /dev/null +++ b/entropy/nixos/modules/printing.nix @@ -0,0 +1,39 @@ +{ config, pkgs, ... }: + +{ + # Enable CUPS to print documents. + services.printing.enable = true; + services.printing.drivers = [ + pkgs.gutenprint + pkgs.epson-escpr + ]; + + # set up my printer at home + hardware.printers.ensurePrinters = [ + { + description = "My private printer"; + deviceUri = "https://192.168.178.30:631/ipp/print"; + location = "Home"; + model = "epson-inkjet-printer-escpr/Epson-XP-322_323_325_Series-epson-escpr-en.ppd"; + name = "Home"; + } + ]; + + # setup the printers at work + #hardware.printers.ensurePrinters = [ + #{ + #description = "CC printer"; + #deviceUri = ""; + #location = "BAR/III51"; + #model = "Ricoh-MP_C307_PS.ppd"; + #name = "CC_small"; + #} + #{ + #description = "PD printer (A3)"; + #deviceUri = ""; + #location = "BAR/III71B"; + #model = "Ricoh-MP_C3004_PS.ppd"; + #name = "PD_Chair"; + #} + #]; +} diff --git a/entropy/nixos/modules/sway.nix b/entropy/nixos/modules/sway.nix index 5dbecb4..e371cfb 100644 --- a/entropy/nixos/modules/sway.nix +++ b/entropy/nixos/modules/sway.nix @@ -31,36 +31,17 @@ ''; }; + programs.waybar.enable = true; - #environment = { - #etc = { - ## Put config files in /etc. Note that you also can put these in ~/.config, but then you can't manage them with NixOS anymore! - #"sway/config".source = ./dotfiles/sway/config; - #"xdg/waybar/config".source = ./dotfiles/waybar/config; - #"xdg/waybar/style.css".source = ./dotfiles/waybar/style.css; - #}; - #}; + services.redshift = { + enable = true; + package = pkgs.redshift-wlr; + temperature.night = 3500; + }; - # Here we but a shell script into path, which lets us start sway.service (after importing the environment of the login shell). - environment.systemPackages = with pkgs; [ - ( - pkgs.writeTextFile { - name = "startsway"; - destination = "/bin/startsway"; - executable = true; - text = '' - #! ${pkgs.bash}/bin/bash - # first import environment variables from the login manager - systemctl --user import-environment - # then start the service - exec systemctl --user start sway.service - ''; - } - ) - ]; - - # use gdm for authentication + # ------------ Display Manager ---------------------------------------------- + # use sddm for authentication services.xserver.enable = true; #services.xserver.displayManager.gdm = { #enable = true; @@ -69,79 +50,4 @@ services.xserver.displayManager.sddm = { enable = true; }; - - services.xserver.desktopManager.plasma5 = { - enable = true; - }; - #environment.variables = { - #GDK_SCALE = "2"; - #GDK_DPI_SCALE = "0.5"; - #_JAVA_OPTIONS = "-Dsun.java2d.uiScale=2"; - #}; - - services.redshift = { - enable = true; - # Redshift with wayland support isn't present in nixos-19.09 atm. You have to cherry-pick the commit from https://github.com/NixOS/nixpkgs/pull/68285 to do that. - package = pkgs.redshift-wlr; - temperature.night = 3500; - }; - - systemd.user.targets.sway-session = { - description = "Sway compositor session"; - documentation = [ "man:systemd.special(7)" ]; - bindsTo = [ "graphical-session.target" ]; - wants = [ "graphical-session-pre.target" ]; - after = [ "graphical-session-pre.target" ]; - }; - - systemd.user.services.sway = { - description = "Sway - Wayland window manager"; - documentation = [ "man:sway(5)" ]; - bindsTo = [ "graphical-session.target" ]; - wants = [ "graphical-session-pre.target" ]; - after = [ "graphical-session-pre.target" ]; - # We explicitly unset PATH here, as we want it to be set by - # systemctl --user import-environment in startsway - environment.PATH = pkgs.lib.mkForce null; - serviceConfig = { - Type = "simple"; - ExecStart = '' - ${pkgs.dbus}/bin/dbus-run-session ${pkgs.sway}/bin/sway --debug - ''; - Restart = "on-failure"; - RestartSec = 1; - TimeoutStopSec = 10; - }; - }; - - systemd.user.services.swayidle = { - description = "Idle Manager for Wayland"; - documentation = [ "man:swayidle(1)" ]; - wantedBy = [ "sway-session.target" ]; - partOf = [ "graphical-session.target" ]; - path = [ pkgs.bash ]; - serviceConfig = { - ExecStart = '' ${pkgs.swayidle}/bin/swayidle -w -d \ - timeout 300 '${pkgs.sway}/bin/swaymsg "output * dpms off"' \ - resume '${pkgs.sway}/bin/swaymsg "output * dpms on"' - ''; - }; - }; - - programs.waybar.enable = true; - - systemd.user.services.kanshi = { - description = "Kanshi output autoconfig "; - wantedBy = [ "graphical-session.target" ]; - partOf = [ "graphical-session.target" ]; - serviceConfig = { - # kanshi doesn't have an option to specifiy config file yet, so it looks - # at .config/kanshi/config - ExecStart = '' - ${pkgs.kanshi}/bin/kanshi - ''; - RestartSec = 5; - Restart = "always"; - }; - }; } diff --git a/entropy/nixos/modules/video.nix b/entropy/nixos/modules/video.nix new file mode 100644 index 0000000..996a4c8 --- /dev/null +++ b/entropy/nixos/modules/video.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: + +{ + # make the screen usable + #hardware.video.hidpi.enable = true; + #services.xserver.dpi = 180; + + nixpkgs.config = { + # enable hardware-accelerated graphics + packageOverrides = pkgs: { + vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; }; + # add nixpkgs for unstable package sources + #unstable = import { + #config = config.nixpkgs.config; + #}; + }; + # allow unfree licenced packges + allowUnfree = true; + }; + hardware.opengl = { + enable = true; + extraPackages = with pkgs; [ + intel-media-driver # LIBVA_DRIVER_NAME=iHD + vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium) + vaapiVdpau + libvdpau-va-gl + ]; + }; + + # allow brightness control + services.illum.enable = true; +} diff --git a/entropy/nixos/modules/virtualisation.nix b/entropy/nixos/modules/virtualisation.nix new file mode 100644 index 0000000..a3ded71 --- /dev/null +++ b/entropy/nixos/modules/virtualisation.nix @@ -0,0 +1,16 @@ +{ config, pkgs, ... }: + +{ + # set up virtualization with virtualbox + virtualisation.virtualbox.host.enable = true; + # I'm gonna keep this disabled for the sake of my sanity + # virtualisation.virtualbox.host.enableExtensionPack = true; + + # enable docker on-demand + virtualisation.docker.enable = true; + virtualisation.docker.enableOnBoot = false; + users.extraGroups = { + docker.members = [ "felix" ]; + vboxusers.members = [ "felix" ]; + }; +}