From 268374ad58a1bf32d1914fa5a27876cb30868b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 15 Jul 2022 13:11:54 +0200 Subject: [PATCH] :broom: restructure layout --- .gitignore | 1 + apply.sh | 4 - config/nixos-desktop.nix | 17 - config/nixos-laptop.nix | 11 - flake.lock | 51 +- flake.nix | 67 ++- hosts/nixos-desktop/default.nix | 37 +- .../nixos-desktop/hardware-configuration.nix | 18 +- hosts/nixos-laptop/default.nix | 67 ++- hosts/nixos-laptop/hardware-configuration.nix | 19 +- modules/cachix.nix | 13 - modules/cachix/jupyterwith.nix | 8 - modules/cachix/nix-community.nix | 8 - modules/cli/adb.nix | 6 - modules/cli/bin/default.nix | 12 - modules/cli/default.nix | 115 ---- modules/cli/direnv.nix | 8 - modules/cli/git.nix | 22 - modules/cli/ledger/default.nix | 26 - modules/cli/nix.nix | 14 - modules/cli/shell/zsh.nix | 35 -- modules/cli/spotify.nix | 69 --- modules/cli/ssh.nix | 10 - modules/cli/yubikey.nix | 19 - modules/{cli => config}/bin/cycleSinks.nix | 1 - modules/config/bin/default.nix | 34 ++ modules/{cli => config}/bin/protonge.nix | 1 - .../{cli => config}/bin/randomWallpaper.nix | 1 - modules/{cli => config}/bin/share.nix | 1 - modules/{cli => config}/bin/sxhkdHelp.nix | 1 - modules/config/default.nix | 17 + modules/config/email.nix | 98 ++++ modules/config/nix.nix | 54 ++ .../shell/default.nix => config/shell.nix} | 21 +- modules/config/theming.nix | 553 ++++++++++++++++++ modules/config/wallpapers.nix | 31 + .../wallpapers/a_short_walk.png | Bin .../wallpapers/blender_pink_blue.jpg | Bin .../wallpapers/dracula.png | Bin .../wallpapers/elephants.jpg | Bin .../wallpapers/forest_road.jpg | Bin .../wallpapers/little-ships.jpg | Bin .../wallpapers/old-hardware.jpg | Bin .../wallpapers/stardust.jpg | Bin .../wallpapers/whale_in_sky.jpg | Bin modules/config/yubikey.nix | 32 + modules/default.nix | 67 +-- modules/desktop/apps/default.nix | 40 -- modules/desktop/apps/email.nix | 98 ---- modules/desktop/apps/firefox.nix | 62 -- modules/desktop/apps/kitty.nix | 29 - modules/desktop/apps/rofi/default.nix | 24 - modules/desktop/apps/virtualisation.nix | 10 - modules/desktop/apps/zathura.nix | 13 - modules/desktop/bspwm/bspwmrc | 12 - modules/desktop/bspwm/default.nix | 76 --- modules/desktop/bspwm/polybar.nix | 206 ------- modules/desktop/default.nix | 31 - modules/desktop/gtk.nix | 14 - modules/desktop/xmonad/default.nix | 40 -- modules/editors/default.nix | 5 - modules/editors/idea.nix | 18 - modules/editors/vim.nix | 27 - modules/gaming.nix | 19 - modules/podman.nix | 8 - modules/profiles/base.nix | 128 ++++ modules/profiles/desktop.nix | 133 +++++ modules/profiles/gaming.nix | 11 + modules/programs/adb.nix | 24 + modules/programs/bspwm/bspwmrc | 11 + modules/programs/bspwm/default.nix | 79 +++ modules/{desktop => programs}/bspwm/sxhkdrc | 0 modules/{editors => programs}/code.nix | 18 +- modules/programs/default.nix | 30 + modules/programs/direnv.nix | 26 + modules/{editors => programs}/emacs.nix | 30 +- modules/programs/firefox.nix | 47 ++ modules/{cli/shell => programs}/fish.nix | 46 +- modules/programs/git.nix | 57 ++ modules/programs/gpg.nix | 34 ++ modules/programs/hub.nix | 27 + modules/programs/kitty.nix | 48 ++ modules/programs/ledger/default.nix | 44 ++ modules/{cli => programs}/ledger/ledger.fish | 0 modules/programs/rofi/default.nix | 40 ++ .../apps => programs}/rofi/dracula.rasi | 0 modules/programs/spotify.nix | 87 +++ .../sway/default.nix => programs/sway.nix} | 34 +- modules/programs/thunar.nix | 32 + modules/programs/vim.nix | 29 + modules/programs/xmonad/default.nix | 56 ++ .../{desktop => programs}/xmonad/xmonad.hs | 0 modules/programs/zathura.nix | 31 + modules/programs/zsh.nix | 49 ++ .../{security.nix => security/default.nix} | 7 +- modules/services/agenix.nix | 11 - modules/services/default.nix | 40 +- modules/services/dunst.nix | 477 +++++++-------- modules/services/gpg.nix | 11 - modules/services/jupyter.nix | 38 -- modules/services/kdeconnect.nix | 27 +- modules/services/keyring.nix | 6 - modules/services/openconnect.nix | 52 +- modules/services/openvpn.nix | 58 +- modules/services/picom.nix | 73 ++- modules/services/printing.nix | 28 + modules/services/redshift.nix | 23 + modules/theming.nix | 330 ----------- modules/virtualisation/default.nix | 11 + modules/virtualisation/podman.nix | 26 + modules/virtualisation/virtualisation.nix | 28 + overlays/default.nix | 7 +- overlays/python.nix | 2 +- secrets/secrets.nix | 15 +- update.sh | 4 - 115 files changed, 2641 insertions(+), 2085 deletions(-) delete mode 100755 apply.sh delete mode 100644 config/nixos-desktop.nix delete mode 100644 config/nixos-laptop.nix delete mode 100644 modules/cachix.nix delete mode 100644 modules/cachix/jupyterwith.nix delete mode 100644 modules/cachix/nix-community.nix delete mode 100644 modules/cli/adb.nix delete mode 100644 modules/cli/bin/default.nix delete mode 100644 modules/cli/default.nix delete mode 100644 modules/cli/direnv.nix delete mode 100644 modules/cli/git.nix delete mode 100644 modules/cli/ledger/default.nix delete mode 100644 modules/cli/nix.nix delete mode 100644 modules/cli/shell/zsh.nix delete mode 100644 modules/cli/spotify.nix delete mode 100644 modules/cli/ssh.nix delete mode 100644 modules/cli/yubikey.nix rename modules/{cli => config}/bin/cycleSinks.nix (99%) create mode 100644 modules/config/bin/default.nix rename modules/{cli => config}/bin/protonge.nix (99%) rename modules/{cli => config}/bin/randomWallpaper.nix (99%) rename modules/{cli => config}/bin/share.nix (99%) rename modules/{cli => config}/bin/sxhkdHelp.nix (99%) create mode 100644 modules/config/default.nix create mode 100644 modules/config/email.nix create mode 100644 modules/config/nix.nix rename modules/{cli/shell/default.nix => config/shell.nix} (58%) create mode 100644 modules/config/theming.nix create mode 100644 modules/config/wallpapers.nix rename modules/{desktop => config}/wallpapers/a_short_walk.png (100%) rename modules/{desktop => config}/wallpapers/blender_pink_blue.jpg (100%) rename modules/{desktop => config}/wallpapers/dracula.png (100%) rename modules/{desktop => config}/wallpapers/elephants.jpg (100%) rename modules/{desktop => config}/wallpapers/forest_road.jpg (100%) rename modules/{desktop => config}/wallpapers/little-ships.jpg (100%) rename modules/{desktop => config}/wallpapers/old-hardware.jpg (100%) rename modules/{desktop => config}/wallpapers/stardust.jpg (100%) rename modules/{desktop => config}/wallpapers/whale_in_sky.jpg (100%) create mode 100644 modules/config/yubikey.nix delete mode 100644 modules/desktop/apps/default.nix delete mode 100644 modules/desktop/apps/email.nix delete mode 100644 modules/desktop/apps/firefox.nix delete mode 100644 modules/desktop/apps/kitty.nix delete mode 100644 modules/desktop/apps/rofi/default.nix delete mode 100644 modules/desktop/apps/virtualisation.nix delete mode 100644 modules/desktop/apps/zathura.nix delete mode 100755 modules/desktop/bspwm/bspwmrc delete mode 100644 modules/desktop/bspwm/default.nix delete mode 100644 modules/desktop/bspwm/polybar.nix delete mode 100644 modules/desktop/default.nix delete mode 100644 modules/desktop/gtk.nix delete mode 100644 modules/desktop/xmonad/default.nix delete mode 100644 modules/editors/default.nix delete mode 100644 modules/editors/idea.nix delete mode 100644 modules/editors/vim.nix delete mode 100644 modules/gaming.nix delete mode 100644 modules/podman.nix create mode 100644 modules/profiles/base.nix create mode 100644 modules/profiles/desktop.nix create mode 100644 modules/profiles/gaming.nix create mode 100644 modules/programs/adb.nix create mode 100755 modules/programs/bspwm/bspwmrc create mode 100644 modules/programs/bspwm/default.nix rename modules/{desktop => programs}/bspwm/sxhkdrc (100%) rename modules/{editors => programs}/code.nix (75%) create mode 100644 modules/programs/default.nix create mode 100644 modules/programs/direnv.nix rename modules/{editors => programs}/emacs.nix (80%) create mode 100644 modules/programs/firefox.nix rename modules/{cli/shell => programs}/fish.nix (71%) create mode 100644 modules/programs/git.nix create mode 100644 modules/programs/gpg.nix create mode 100644 modules/programs/hub.nix create mode 100644 modules/programs/kitty.nix create mode 100644 modules/programs/ledger/default.nix rename modules/{cli => programs}/ledger/ledger.fish (100%) create mode 100644 modules/programs/rofi/default.nix rename modules/{desktop/apps => programs}/rofi/dracula.rasi (100%) create mode 100644 modules/programs/spotify.nix rename modules/{desktop/sway/default.nix => programs/sway.nix} (76%) create mode 100644 modules/programs/thunar.nix create mode 100644 modules/programs/vim.nix create mode 100644 modules/programs/xmonad/default.nix rename modules/{desktop => programs}/xmonad/xmonad.hs (100%) create mode 100644 modules/programs/zathura.nix create mode 100644 modules/programs/zsh.nix rename modules/{security.nix => security/default.nix} (99%) delete mode 100644 modules/services/agenix.nix delete mode 100644 modules/services/gpg.nix delete mode 100644 modules/services/jupyter.nix delete mode 100644 modules/services/keyring.nix create mode 100644 modules/services/printing.nix create mode 100644 modules/services/redshift.nix delete mode 100644 modules/theming.nix create mode 100644 modules/virtualisation/default.nix create mode 100644 modules/virtualisation/podman.nix create mode 100644 modules/virtualisation/virtualisation.nix delete mode 100755 update.sh diff --git a/.gitignore b/.gitignore index 32435e4..7dcd526 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.log tmp/ .direnv/ +.pre-commit-config.yaml diff --git a/apply.sh b/apply.sh deleted file mode 100755 index 36c3c36..0000000 --- a/apply.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -pushd ~/.dotfiles -sudo nixos-rebuild switch --flake .# -popd diff --git a/config/nixos-desktop.nix b/config/nixos-desktop.nix deleted file mode 100644 index 3e3c699..0000000 --- a/config/nixos-desktop.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - modules = { - gaming = true; - - editors = { - idea = true; - code = true; - }; - - desktop.apps.email = { - enable = true; - passwordFile = ../secrets/email-desktop.age; - }; - }; -} diff --git a/config/nixos-laptop.nix b/config/nixos-laptop.nix deleted file mode 100644 index 68477d8..0000000 --- a/config/nixos-laptop.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - modules = { - editors.code = true; - desktop.apps.email = { - enable = true; - passwordFile = ../secrets/email-desktop.age; - }; - }; -} diff --git a/flake.lock b/flake.lock index 51d4244..58306ac 100644 --- a/flake.lock +++ b/flake.lock @@ -232,6 +232,21 @@ "type": "github" } }, + "flake-utils_4": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "forgit-git": { "flake": false, "locked": { @@ -417,6 +432,20 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1645655918, + "narHash": "sha256-ZfbEFRW7o237+A1P7eTKhXje435FCAoe0blj2n20Was=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "77a7a4197740213879b9a1d2e1788c6c8ade4274", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "nur": { "locked": { "lastModified": 1657272425, @@ -432,6 +461,25 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1656169028, + "narHash": "sha256-y9DRauokIeVHM7d29lwT8A+0YoGUBXV3H0VErxQeA8s=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "db3bd555d3a3ceab208bed48f983ccaa6a71a25e", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", @@ -447,6 +495,7 @@ "nixpkgs": "nixpkgs", "nixpkgs-review-checks": "nixpkgs-review-checks", "nur": "nur", + "pre-commit-hooks": "pre-commit-hooks", "stable": "stable", "statix": "statix", "utils": "utils_3" @@ -539,7 +588,7 @@ }, "utils_3": { "inputs": { - "flake-utils": "flake-utils_3" + "flake-utils": "flake-utils_4" }, "locked": { "lastModified": 1657226504, diff --git a/flake.nix b/flake.nix index 271c7fe..dec5eaf 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,8 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + utils = { url = "github:gytis-ivaskevicius/flake-utils-plus"; inputs.nixpkgs.follows = "nixpkgs"; @@ -80,7 +82,12 @@ }; }; - outputs = inputs@{ self, nixpkgs, utils, ... }: + outputs = + inputs @ { self + , nixpkgs + , utils + , ... + }: utils.lib.mkFlake { inherit self inputs; @@ -90,11 +97,9 @@ ### Overlays ### ################ - overlay = import ./overlays { inherit inputs; }; - # overlays = utils.lib.exportOverlays { inherit (self) pkgs inputs; }; - + overlays.default = import ./overlays { inherit inputs; }; channels.nixpkgs.overlaysBuilder = channels: [ - self.overlay + self.overlays.default inputs.utils.overlay inputs.emacs-overlay.overlay inputs.nur.overlay @@ -104,9 +109,14 @@ ### Modules ### ############### - nixosModules = utils.lib.exportModules [ ./modules/default.nix ]; + nixosModules = utils.lib.exportModules [ + ./modules/profiles/base.nix + ./modules/profiles/gaming.nix + ./modules/profiles/desktop.nix + ]; hostDefaults.modules = [ - ./modules + ./modules/default.nix + self.nixosModules.base inputs.home-manager.nixosModule { home-manager = { @@ -115,16 +125,19 @@ extraSpecialArgs = { inherit inputs self; }; }; } - self.nixosModules.default inputs.agenix.nixosModules.age inputs.base16.nixosModule ]; - hosts.nixos-laptop.modules = - [ ./hosts/nixos-laptop ./config/nixos-laptop.nix ]; - - hosts.nixos-desktop.modules = - [ ./hosts/nixos-desktop ./config/nixos-desktop.nix ]; + hosts.nixos-laptop.modules = [ + ./hosts/nixos-laptop + self.nixosModules.desktop + ]; + hosts.nixos-desktop.modules = [ + ./hosts/nixos-desktop + self.nixosModules.desktop + self.nixosModules.gaming + ]; ############### ### Outputs ### @@ -132,30 +145,24 @@ outputsBuilder = channels: with channels.nixpkgs; { - devShell = mkShell { + devShells.default = mkShell { + inherit (self.checks.${system}.pre-commit-check) shellHook; name = "dotfiles"; - shellHook = '' - alias "lint"='echo "Running nixpkgs-fmt ..." - nixpkgs-fmt --check $(find . -name "*.nix") - echo "" - echo "Running statix ..." - statix check' - alias "fix"='echo "Running nixpkgs-fmt ..." - nixpkgs-fmt $(find . -name "*.nix") - echo "" - echo "Running statix ..." - statix fix' - ''; packages = [ - # Linting - nixpkgs-fmt - statix # Secrets pkgs.agenix - # chachix + # cachix cachix ]; }; + checks.pre-commit-check = inputs.pre-commit-hooks.lib."${system}".run { + src = ./.; + hooks = { + nixpkgs-fmt.enable = true; + statix.enable = true; + shellcheck.enable = true; + }; + }; }; }; } diff --git a/hosts/nixos-desktop/default.nix b/hosts/nixos-desktop/default.nix index e268b0c..24e9717 100644 --- a/hosts/nixos-desktop/default.nix +++ b/hosts/nixos-desktop/default.nix @@ -1,15 +1,22 @@ # 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’). - -{ lib, config, pkgs, ... }: - -{ +{ lib +, config +, pkgs +, ... +}: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix ]; + # MY MODULES + my.email = { + enable = true; + passwordFile = ../../secrets/email-desktop.age; + }; + # BOOT boot = { supportedFilesystems = [ "btrfs" "ntfs" ]; @@ -32,14 +39,18 @@ nameservers = [ "192.168.0.4" ]; useDHCP = false; interfaces.enp42s0 = { - ipv4.addresses = [{ - address = "192.168.0.14"; - prefixLength = 24; - }]; - ipv6.addresses = [{ - address = "fe80::60fb:ffc:df6f:e29e"; - prefixLength = 64; - }]; + ipv4.addresses = [ + { + address = "192.168.0.14"; + prefixLength = 24; + } + ]; + ipv6.addresses = [ + { + address = "fe80::60fb:ffc:df6f:e29e"; + prefixLength = 64; + } + ]; }; networkmanager = { enable = true; @@ -77,6 +88,4 @@ # 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 = "21.05"; # Did you read the comment? - } - diff --git a/hosts/nixos-desktop/hardware-configuration.nix b/hosts/nixos-desktop/hardware-configuration.nix index 08ef410..dc6bd93 100644 --- a/hosts/nixos-desktop/hardware-configuration.nix +++ b/hosts/nixos-desktop/hardware-configuration.nix @@ -1,13 +1,15 @@ # 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, ... }: - -{ +{ config +, lib +, pkgs +, modulesPath +, ... +}: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = - [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; @@ -18,8 +20,7 @@ options = [ "subvol=root" ]; }; - boot.initrd.luks.devices."enc".device = - "/dev/disk/by-uuid/30025a9f-44cf-4074-8ae2-d4925efd67dd"; + boot.initrd.luks.devices."enc".device = "/dev/disk/by-uuid/30025a9f-44cf-4074-8ae2-d4925efd67dd"; fileSystems."/home" = { device = "/dev/disk/by-uuid/668a49b3-d169-461f-861d-0c3e6a1642d1"; @@ -56,8 +57,7 @@ fsType = "ext4"; }; - swapDevices = - [{ device = "/dev/disk/by-uuid/00ad6f74-f23e-4ac0-abfb-89bdfe5ab8ae"; }]; + swapDevices = [{ device = "/dev/disk/by-uuid/00ad6f74-f23e-4ac0-abfb-89bdfe5ab8ae"; }]; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; diff --git a/hosts/nixos-laptop/default.nix b/hosts/nixos-laptop/default.nix index a5d367a..c6e1ec1 100644 --- a/hosts/nixos-laptop/default.nix +++ b/hosts/nixos-laptop/default.nix @@ -1,15 +1,22 @@ # 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, inputs, ... }: - -{ +{ config +, pkgs +, inputs +, ... +}: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix ]; + # MY MODULES + my.email = { + enable = true; + passwordFile = ../../secrets/email-desktop.age; + }; + # BOOT boot = { supportedFilesystems = [ "btrfs" ]; @@ -65,32 +72,35 @@ OnBootSec = "120"; }; }; - systemd.services.hibernate-on-low-battery = let - batteryLevelSufficient = let batteryPath = "/sys/class/power_supply/BATT"; - in pkgs.writeShellScriptBin "battery-level-sufficient" '' - test "$(cat ${batteryPath}/status)" != Discharging \ - || test "$(cat ${batteryPath}/capacity)" -ge 5 - ''; - in { - serviceConfig.Type = "oneshot"; - onFailure = [ "hibernate.target" ]; - script = "${batteryLevelSufficient}/bin/battery-level-sufficient"; - }; + systemd.services.hibernate-on-low-battery = + let + batteryLevelSufficient = + let + batteryPath = "/sys/class/power_supply/BATT"; + in + pkgs.writeShellScriptBin "battery-level-sufficient" '' + test "$(cat ${batteryPath}/status)" != Discharging \ + || test "$(cat ${batteryPath}/capacity)" -ge 5 + ''; + in + { + serviceConfig.Type = "oneshot"; + onFailure = [ "hibernate.target" ]; + script = "${batteryLevelSufficient}/bin/battery-level-sufficient"; + }; # Trackpad # i2c for https://github.com/mohamed-badaoui/asus-touchpad-numpad-driver hardware.i2c.enable = true; systemd.services.asus-touchpad-numpad = { - description = - "Activate Numpad inside the touchpad with top right corner switch"; - documentation = - [ "https://github.com/mohamed-badaoui/asus-touchpad-numpad-driver" ]; + description = "Activate Numpad inside the touchpad with top right corner switch"; + documentation = [ "https://github.com/mohamed-badaoui/asus-touchpad-numpad-driver" ]; path = [ pkgs.i2c-tools ]; script = '' cd ${inputs.asus-touchpad-numpad-driver} # In the last argument here you choose your layout. ${ - pkgs.python3.withPackages (ps: [ ps.libevdev ]) + pkgs.python3.withPackages (ps: [ps.libevdev]) }/bin/python asus_touchpad.py m433ia ''; # Probably needed because it fails on boot seemingly because the driver @@ -105,13 +115,15 @@ nix = { distributedBuilds = true; - buildMachines = [{ - hostName = "builder"; - system = "x86_64-linux"; - maxJobs = 6; - speedFactor = 2; - supportedFeatures = [ "nixos.test" "benchmark" "big-parallel" "kvm" ]; - }]; + buildMachines = [ + { + hostName = "builder"; + system = "x86_64-linux"; + maxJobs = 6; + speedFactor = 2; + supportedFeatures = [ "nixos.test" "benchmark" "big-parallel" "kvm" ]; + } + ]; extraOptions = '' builders-use-substitutes = true ''; @@ -134,5 +146,4 @@ # 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 = "21.05"; # Did you read the comment? - } diff --git a/hosts/nixos-laptop/hardware-configuration.nix b/hosts/nixos-laptop/hardware-configuration.nix index 6a6dacb..b0c8aa8 100644 --- a/hosts/nixos-laptop/hardware-configuration.nix +++ b/hosts/nixos-laptop/hardware-configuration.nix @@ -1,13 +1,15 @@ # 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, ... }: - -{ +{ config +, lib +, pkgs +, modulesPath +, ... +}: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = - [ "nvme" "xhci_pci" "ahci" "rtsx_pci_sdmmc" ]; + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "rtsx_pci_sdmmc" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; @@ -18,8 +20,7 @@ options = [ "subvol=root" ]; }; - boot.initrd.luks.devices."enc".device = - "/dev/disk/by-uuid/078b81ba-238e-471d-9951-b743588532b8"; + boot.initrd.luks.devices."enc".device = "/dev/disk/by-uuid/078b81ba-238e-471d-9951-b743588532b8"; fileSystems."/log" = { device = "/dev/disk/by-uuid/4a91d3eb-1633-42d9-8304-c10e49a61154"; @@ -51,7 +52,5 @@ options = [ "subvol=home" ]; }; - swapDevices = - [{ device = "/dev/disk/by-uuid/29ebf65f-e6ca-4625-9f72-a9321152be1b"; }]; - + swapDevices = [{ device = "/dev/disk/by-uuid/29ebf65f-e6ca-4625-9f72-a9321152be1b"; }]; } diff --git a/modules/cachix.nix b/modules/cachix.nix deleted file mode 100644 index 063fdc3..0000000 --- a/modules/cachix.nix +++ /dev/null @@ -1,13 +0,0 @@ -# WARN: this file will get overwritten by $ cachix use -{ pkgs, lib, ... }: - -let - folder = ./cachix; - toImport = name: value: folder + ("/" + name); - filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key; - imports = lib.mapAttrsToList toImport - (lib.filterAttrs filterCaches (builtins.readDir folder)); -in { - inherit imports; - nix.settings.substituters = [ "https://cache.nixos.org/" ]; -} diff --git a/modules/cachix/jupyterwith.nix b/modules/cachix/jupyterwith.nix deleted file mode 100644 index f65fc85..0000000 --- a/modules/cachix/jupyterwith.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - nix.settings = { - substituters = [ "https://jupyterwith.cachix.org" ]; - trusted-public-keys = [ - "jupyterwith.cachix.org-1:/kDy2B6YEhXGJuNguG1qyqIodMyO4w8KwWH4/vAc7CI=" - ]; - }; -} diff --git a/modules/cachix/nix-community.nix b/modules/cachix/nix-community.nix deleted file mode 100644 index 2a6f291..0000000 --- a/modules/cachix/nix-community.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - nix.settings = { - substituters = [ "https://nix-community.cachix.org" ]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; -} diff --git a/modules/cli/adb.nix b/modules/cli/adb.nix deleted file mode 100644 index a757638..0000000 --- a/modules/cli/adb.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - programs.adb.enable = true; - users.users.moritz.extraGroups = [ "adbusers" ]; -} diff --git a/modules/cli/bin/default.nix b/modules/cli/bin/default.nix deleted file mode 100644 index d047b22..0000000 --- a/modules/cli/bin/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - cycleSinks = import ./cycleSinks.nix { inherit pkgs; }; - protonge = import ./protonge.nix { inherit pkgs; }; - randomWallpaper = import ./randomWallpaper.nix { inherit pkgs; }; - share = import ./share.nix { inherit pkgs; }; - sxhkdHelp = import ./sxhkdHelp.nix { inherit pkgs; }; -in { - home-manager.users.moritz.home.packages = - [ cycleSinks protonge randomWallpaper share sxhkdHelp ]; -} diff --git a/modules/cli/default.nix b/modules/cli/default.nix deleted file mode 100644 index 0aaa7e7..0000000 --- a/modules/cli/default.nix +++ /dev/null @@ -1,115 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - imports = [ - ./adb.nix - ./bin - ./direnv.nix - ./git.nix - ./ledger - ./nix.nix - ./shell - ./spotify.nix - ./ssh.nix - ./yubikey.nix - ]; - modules.cli.shell = let - editor = "emacsclient -t -a 'emacs -t'"; - cmdSub = command: - "${ - if (config.modules.cli.shell.name == "fish") then "" else "$" - }${command}"; - in { - name = "fish"; - abbreviations = { - us = "systemctl --user"; - rs = "doas systemctl"; - - ga = "git add"; - gb = "git branch"; - gc = "git commit"; - gco = "git checkout"; - gd = "git diff"; - gds = "git diff --staged"; - gp = "git push"; - gf = "git fetch"; - gF = "git pull"; - gs = "git status"; - }; - aliases = { - ls = "exa -lh --icons --git"; - cat = "bat"; - feh = "feh --auto-zoom --scale-down"; - grep = "rg"; - rm = "rm -i"; - mv = "mv -i"; - - ssh = "kitty +kitten ssh"; - - nix-switch = "doas nixos-rebuild switch --flake ~/.dotfiles"; - nix-boot = "doas nixos-rebuild boot --flake ~/.dotfiles"; - nix-lock = "pushd ~/.dotfiles && nix flake update && popd"; - - emacs = editor; - - nixpkgs-review = "nixpkgs-review-checks"; - - latexwatch = - ''find -type f -name "*.tex" | entr -c latexmk -pdf -silent''; - - }; - variables = { EDITOR = editor; }; - }; - home-manager.users.moritz = { - home.packages = with pkgs; [ - # archives - p7zip - unzip - zip - - # file management - ranger - trash-cli - - # monitoring - htop - bottom - - # ripping - abcde - handbrake - - # nix - nixpkgs-review - comma - nix-index - - # other - arduino - cht-sh - du-dust - duf - entr - hub - neofetch - tmux - ttyper - up - viu - ]; - programs = { - bat.enable = true; - command-not-found.enable = true; - exa.enable = true; - fzf.enable = true; - gpg.enable = true; - starship.enable = true; - }; - }; - age.secrets = { - github = { - file = ../../secrets/github.age; - owner = "1000"; - }; - }; -} diff --git a/modules/cli/direnv.nix b/modules/cli/direnv.nix deleted file mode 100644 index cec2cb0..0000000 --- a/modules/cli/direnv.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - home-manager.users.moritz.programs.direnv = { - enable = true; - nix-direnv.enable = true; - }; -} diff --git a/modules/cli/git.nix b/modules/cli/git.nix deleted file mode 100644 index cf7ca63..0000000 --- a/modules/cli/git.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - home-manager.users.moritz = { - programs.git = { - enable = true; - userName = "Moritz Böhme"; - userEmail = "mail@moritzboeh.me"; - extraConfig.init.defaultBranch = "main"; - delta.enable = true; - signing = { - key = "0x970C6E89EB0547A9"; - signByDefault = true; - }; - lfs.enable = true; - }; - }; - programs.git = { - enable = true; - config.safe.directory = "/home/moritz/.dotfiles"; - }; -} diff --git a/modules/cli/ledger/default.nix b/modules/cli/ledger/default.nix deleted file mode 100644 index ebc099e..0000000 --- a/modules/cli/ledger/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - modules.cli.shell.aliases = { - bal = "ledger bal"; - balcash = "ledger bal -R -X € --current --flat ^assets:bank ^liabilities"; - balnet = "ledger bal -R -X € --current --depth 2 ^assets ^liabilities"; - bud = ''ledger --budget --unbudgeted bal ^expenses -p "this month"''; - budr = ''ledger --budget reg -p "this month" ^expenses''; - reg = "ledger reg -R -V --tail 15"; - }; - home-manager.users.moritz = { - home.packages = with pkgs; [ ledger ]; - xdg.configFile = { - "fish/completions/ledger.fish" = { - text = builtins.readFile ./ledger.fish; - }; - "ledger/ledgerrc".text = '' - --strict - --explicit - --payee note - --file ~/Notes/ledger/main.ledger - ''; - }; - }; -} diff --git a/modules/cli/nix.nix b/modules/cli/nix.nix deleted file mode 100644 index e5e4979..0000000 --- a/modules/cli/nix.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - nix = { - gc = { - automatic = true; - options = "--max-freed $((32 * 1024**3)) --delete-older-than 14d"; - dates = "weekly"; - }; - optimise.automatic = true; - - settings.trusted-users = [ "root" "@wheel" ]; - }; -} diff --git a/modules/cli/shell/zsh.nix b/modules/cli/shell/zsh.nix deleted file mode 100644 index 0c5d305..0000000 --- a/modules/cli/shell/zsh.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ config, lib, pkgs, inputs, ... }: - -let cfg = config.modules.cli.shell; -in { - config = lib.mkIf (cfg.name == "zsh") { - environment.pathsToLink = [ "/share/zsh" ]; - users.users.moritz.shell = pkgs.zsh; - home-manager.users.moritz = { - home.packages = with pkgs; [ du-dust ]; - programs = { - zsh = { - enable = true; - dotDir = ".config/zsh"; - history.expireDuplicatesFirst = true; - localVariables = cfg.variables; - shellAliases = lib.trivial.mergeAttrs cfg.aliases cfg.abbreviations; - enableSyntaxHighlighting = true; - enableAutosuggestions = true; - enableCompletion = true; - initExtra = '' - function nix-which() { - readlink -f $(which $1) - } - ''; - plugins = [{ - name = "forgit"; - src = inputs.forgit-git; - }]; - }; - fzf.enableZshIntegration = true; - starship.enableZshIntegration = true; - }; - }; - }; -} diff --git a/modules/cli/spotify.nix b/modules/cli/spotify.nix deleted file mode 100644 index ba68eb7..0000000 --- a/modules/cli/spotify.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - age.secrets.spotifyd = { - file = ../../secrets/spotifyd.age; - owner = "1000"; - }; - home-manager.users.moritz = { - home.packages = with pkgs; [ spotify-tui sptlrx ]; - services.spotifyd = { - enable = true; - package = pkgs.spotifyd.override { withMpris = true; }; - settings = { - global = { - # A command that gets executed and can be used to - # retrieve your username. - username_cmd = "${pkgs.coreutils}/bin/head -n 1 /run/agenix/spotifyd"; - - # A command that gets executed and can be used to - # retrieve your password. - password_cmd = "${pkgs.coreutils}/bin/tail -n 1 /run/agenix/spotifyd"; - - # The name that gets displayed under the connect tab on - # official clients. Spaces are not allowed! - device_name = "spotifyd"; - - # The audio bitrate. 96, 160 or 320 kbit/s - bitrate = 320; - - # Volume on startup between 0 and 100 - initial_volume = "71"; - - # The directory used to cache audio data. - cache_path = "/tmp/spotifyd-cache"; - - # The displayed device type in Spotify clients. - device_type = "computer"; - - # set backend to pulseaudio - backend = "pulseaudio"; - }; - }; - }; - xdg.configFile."spotify-tui/config.yml".text = '' - # Dracula theme - theme: - active: "139,233,253" # current playing song in list - banner: "80,250,123" # the "spotify-tui" banner on launch - error_border: "241,250,140" # error dialog border - error_text: "248,248,242" # error message text (e.g. "Spotify API - # reported error 404") - hint: "241,250,140" # hint text in errors - hovered: "255,184,108" # hovered pane border - inactive: "248,248,242" # borders of inactive panes - playbar_background: "68,71,90" # background of progress bar - playbar_progress: "248,248,242" # filled-in part of the progress bar - playbar_progress_text: "248,248,242" # song length and time played/left - # indicator in the progress bar - playbar_text: "248,248,242" # artist name in player pane - selected: "80,250,123" # a) selected pane border, b) hovered item - # in list, & c) track title in player - text: "248,248,242" # text in panes - header: "248,248,242" # header text in panes (e.g. 'Title', - # 'Artist', etc.) - behavior: - volume_increment: 5 - ''; - }; -} diff --git a/modules/cli/ssh.nix b/modules/cli/ssh.nix deleted file mode 100644 index f73a7cc..0000000 --- a/modules/cli/ssh.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - users.users.moritz.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGoAqa2m7hIzZ2LS96Z+RCIlRvhBM/j7h27tMBCwMT+a" # Moritz - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDhtwHDGAZshiQWKkCcPWV9tC83b+bKBgjDcjP/N2CKO" # Laptop - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKl8gMhwSf1NsP5gp14xbbyjqQLZzcHLb/XKRMoHdXgI" # Desktop - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHlemuKagHwz2T5rEwgJNlVUdUdOXyPtCEzD73CrwY2zmpR4AMj7y9u3Rm7HwHUDjLap1ZFwg+53bAsVP6HFZccCXoIfO/8BL0WDGQJrfgb+A+UiRhSqSvyZ77bGJkadbBkadguz3qR3PHcb41DOlhuqVcHxsY8ceHMxAuyb0pLJVJLeytMD+CHS/r7hoj2hckTNAZ+VhCXBtdZfZ7uPUBxLfluYRNNMmdwCglsg3RUS242nJUzy3A84+CXIGeWmNG9Fu45IDkwMthxSW9klyU9R38R9DBDcugkyb6vz+JKSuRVAa47qh/kmtsYekfL3ul9D2JN32P8S+6ZoXx+gXupGJ0ltwJWAFkhLJ+yeXj9kCOv/mIUmCB14jMGsvKiSwV25O/twyjqe2LEkMVgimgrjEYoHu+ZTyp0iFtUvSrFo4tsAhfWPV9yj4F/hUksW7xKIwq5Niyx7he5M/XddudtnAximyiBDGCdJm1Ejl0UaGa6ZQv7y6VZdx0PyZuraT7l9ub8so6JlE4cVgSSU9vE0IS2QqBuHhsIjh8RVksoTR2NQbeDdGaGpGnq2C8y0rDXwE/EJA4LK45khX/GPn73n8F0kBG8dBrWgRDAEODpmebScO7d5mCeM0z3lPcRmh+3e3DPnVVOl+uR7udlc7NauLzl7q913UtxZaF1PlD7Q==" # GPG - ]; -} diff --git a/modules/cli/yubikey.nix b/modules/cli/yubikey.nix deleted file mode 100644 index a465acc..0000000 --- a/modules/cli/yubikey.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - services.udev.packages = [ pkgs.yubikey-personalization ]; - environment.shellInit = '' - export GPG_TTY="$(tty)" - gpg-connect-agent /bye - export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh" - ''; - home-manager.users.moritz.home.packages = with pkgs; [ - # cli - yubikey-manager - yubikey-personalization - paperkey - # graphical - yubikey-manager-qt - yubikey-personalization-gui - ]; -} diff --git a/modules/cli/bin/cycleSinks.nix b/modules/config/bin/cycleSinks.nix similarity index 99% rename from modules/cli/bin/cycleSinks.nix rename to modules/config/bin/cycleSinks.nix index 401caac..235c2e8 100644 --- a/modules/cli/bin/cycleSinks.nix +++ b/modules/config/bin/cycleSinks.nix @@ -1,5 +1,4 @@ { pkgs }: - pkgs.writeShellApplication { name = "cycle_sinks"; diff --git a/modules/config/bin/default.nix b/modules/config/bin/default.nix new file mode 100644 index 0000000..f001be9 --- /dev/null +++ b/modules/config/bin/default.nix @@ -0,0 +1,34 @@ +{ config +, lib +, pkgs +, ... +}: + +with lib; +let + cfg = config.my.bin; + cycleSinks = import ./cycleSinks.nix { inherit pkgs; }; + protonge = import ./protonge.nix { inherit pkgs; }; + randomWallpaper = import ./randomWallpaper.nix { inherit pkgs; }; + share = import ./share.nix { inherit pkgs; }; + sxhkdHelp = import ./sxhkdHelp.nix { inherit pkgs; }; +in +{ + options.my.bin = { + enable = mkOption { + default = true; + type = types.bool; + example = false; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + cycleSinks + protonge + randomWallpaper + share + sxhkdHelp + ]; + }; +} diff --git a/modules/cli/bin/protonge.nix b/modules/config/bin/protonge.nix similarity index 99% rename from modules/cli/bin/protonge.nix rename to modules/config/bin/protonge.nix index ce9bfed..78eb2e5 100644 --- a/modules/cli/bin/protonge.nix +++ b/modules/config/bin/protonge.nix @@ -1,5 +1,4 @@ { pkgs }: - pkgs.writeShellApplication { name = "protonge"; runtimeInputs = with pkgs; [ curl ]; diff --git a/modules/cli/bin/randomWallpaper.nix b/modules/config/bin/randomWallpaper.nix similarity index 99% rename from modules/cli/bin/randomWallpaper.nix rename to modules/config/bin/randomWallpaper.nix index df932af..2dc3d87 100644 --- a/modules/cli/bin/randomWallpaper.nix +++ b/modules/config/bin/randomWallpaper.nix @@ -1,5 +1,4 @@ { pkgs }: - pkgs.writeShellApplication { name = "randomWallpaper"; diff --git a/modules/cli/bin/share.nix b/modules/config/bin/share.nix similarity index 99% rename from modules/cli/bin/share.nix rename to modules/config/bin/share.nix index 527da47..f3fe37d 100644 --- a/modules/cli/bin/share.nix +++ b/modules/config/bin/share.nix @@ -1,5 +1,4 @@ { pkgs }: - pkgs.writeShellApplication { name = "share"; diff --git a/modules/cli/bin/sxhkdHelp.nix b/modules/config/bin/sxhkdHelp.nix similarity index 99% rename from modules/cli/bin/sxhkdHelp.nix rename to modules/config/bin/sxhkdHelp.nix index e9bb6db..285db14 100644 --- a/modules/cli/bin/sxhkdHelp.nix +++ b/modules/config/bin/sxhkdHelp.nix @@ -1,5 +1,4 @@ { pkgs }: - pkgs.writeShellApplication { name = "sxhkd-help"; runtimeInputs = with pkgs; [ rofi ]; diff --git a/modules/config/default.nix b/modules/config/default.nix new file mode 100644 index 0000000..5c8d2ce --- /dev/null +++ b/modules/config/default.nix @@ -0,0 +1,17 @@ +{ config +, lib +, pkgs +, ... +}: + +{ + imports = [ + ./theming.nix + ./nix.nix + ./bin + ./shell.nix + ./yubikey.nix + ./email.nix + ./wallpapers.nix + ]; +} diff --git a/modules/config/email.nix b/modules/config/email.nix new file mode 100644 index 0000000..3c59dfb --- /dev/null +++ b/modules/config/email.nix @@ -0,0 +1,98 @@ +{ config +, lib +, pkgs +, ... +}: + +with lib; +let + cfg = config.my.email; + name = "Moritz Böhme"; + email = "mail@moritzboeh.me"; + mailDirectory = "/home/moritz/.mail"; +in +{ + options.my.email = { + enable = mkOption { + default = false; + type = types.bool; + example = true; + }; + passwordFile = mkOption { + default = null; + type = types.path; + description = "File containing the email password."; + }; + }; + + config = mkIf cfg.enable { + # Protonbridge Setup + environment.systemPackages = with pkgs; [ protonmail-bridge ]; + systemd.user.services.protonmail-bridge = { + description = "Protonmail Bridge"; + enable = true; + script = "${pkgs.protonmail-bridge}/bin/protonmail-bridge --log-level debug"; + path = [ + pkgs.gnome3.gnome-keyring + ]; # HACK: https://github.com/ProtonMail/proton-bridge/issues/176 + wantedBy = [ "graphical-session.target" ]; + partOf = [ "graphical-session.target" ]; + }; + age.secrets.email = { + file = cfg.passwordFile; + owner = "1000"; + }; + + # Email Applications + home-manager.users.moritz = { + home.packages = with pkgs; [ thunderbird ]; + programs = { + msmtp.enable = true; + mbsync.enable = true; + }; + services.mbsync = { + enable = true; + frequency = "*:0/15"; + preExec = "${pkgs.isync}/bin/mbsync -Ha"; + postExec = "${pkgs.mu}/bin/mu index -m ${mailDirectory}"; + }; + accounts.email = { + maildirBasePath = mailDirectory; + accounts.default = { + address = email; + userName = email; + flavor = "plain"; + primary = true; + passwordCommand = "${pkgs.coreutils}/bin/cat /run/agenix/email"; + mbsync = { + enable = true; + create = "both"; + expunge = "both"; + patterns = [ "*" ]; + }; + realName = name; + msmtp.enable = true; + imap = { + host = "127.0.0.1"; + port = 1143; + tls = { + enable = true; + useStartTls = true; + certificatesFile = "/home/moritz/.config/protonmail/bridge/cert.pem"; + }; + }; + smtp = { + host = "127.0.0.1"; + port = 1025; + tls = { + enable = true; + useStartTls = true; + certificatesFile = "/home/moritz/.config/protonmail/bridge/cert.pem"; + }; + }; + }; + }; + }; + networking.firewall.allowedTCPPorts = [ 33728 1025 1143 ]; + }; +} diff --git a/modules/config/nix.nix b/modules/config/nix.nix new file mode 100644 index 0000000..3d1aa60 --- /dev/null +++ b/modules/config/nix.nix @@ -0,0 +1,54 @@ +{ config +, lib +, pkgs +, ... +}: + +with lib; +let + cfg = config.my.nix; +in +{ + options.my.nix = { + gc.enable = mkOption { + default = true; + type = types.bool; + example = false; + }; + optimise.enable = mkOption { + default = true; + type = types.bool; + example = false; + }; + }; + + config.nix = { + gc = { + automatic = cfg.gc.enable; + options = "--max-freed $((32 * 1024**3)) --delete-older-than 14d"; + dates = "weekly"; + }; + + optimise = { + automatic = cfg.optimise.enable; + dates = [ "weekly" ]; + }; + + settings = { + substituters = [ + "https://cache.nixos.org/" + "https://jupyterwith.cachix.org" + "https://nix-community.cachix.org" + "https://pre-commit-hooks.cachix.org" + ]; + trusted-public-keys = [ + "jupyterwith.cachix.org-1:/kDy2B6YEhXGJuNguG1qyqIodMyO4w8KwWH4/vAc7CI=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc=" + ]; + + trusted-users = [ "root" "@wheel" ]; + }; + }; +} diff --git a/modules/cli/shell/default.nix b/modules/config/shell.nix similarity index 58% rename from modules/cli/shell/default.nix rename to modules/config/shell.nix index fb82e05..b277bca 100644 --- a/modules/cli/shell/default.nix +++ b/modules/config/shell.nix @@ -1,14 +1,15 @@ -{ config, lib, pkgs, ... }: +{ config +, lib +, pkgs +, ... +}: with lib; -let cfg = config.module.cli.shell; -in { - options.modules.cli.shell = { - name = mkOption { - default = "fish"; - type = types.enum [ "fish" "zsh" ]; - example = "zsh"; - }; +let + cfg = config.my.shell; +in +{ + options.my.shell = { abbreviations = mkOption { default = { }; type = with types; attrsOf str; @@ -23,6 +24,4 @@ in { type = with types; attrsOf str; }; }; - - imports = [ ./fish.nix ./zsh.nix ]; } diff --git a/modules/config/theming.nix b/modules/config/theming.nix new file mode 100644 index 0000000..9cee01b --- /dev/null +++ b/modules/config/theming.nix @@ -0,0 +1,553 @@ +{ config +, lib +, pkgs +, inputs +, ... +}: + +with lib; +let + cfg = config.my.theming; + schemes = { + dracula = { + slug = "Dracula"; + scheme = "Dracula"; + author = "Moritz Boehme based on Dracula Theme"; + base00 = "282a36"; # Background + base01 = "69ff94"; # Green 2 + base02 = "ffffa5"; # Yellow 2 + base03 = "6272a4"; # Black 2 + base04 = "d6acff"; # Blue 2 + base05 = "f8f8f2"; # Foreground + base06 = "ff92df"; # Magenta 2 + base07 = "44475a"; # White 2 + base08 = "ff5555"; # Red 1 + base09 = "ff6e6e"; # Red 2 + base0A = "f1fa8c"; # Yellow 1 + base0B = "50fa7b"; # Green 1 + base0C = "8be9fd"; # Cyan 1 + base0D = "bd93f9"; # Blue 1 + base0E = "ff79c6"; # Magenta 1 + base0F = "a4ffff"; # Cyan 2 + }; + catppuccin = { + slug = "Catpuccin"; + scheme = "Catpuccin"; + author = "Moritz Boehme based on Catppuccin Theme"; + base00 = "1e1e2e"; # Background + base01 = "abe9b3"; # Green 2 + base02 = "fae380"; # Yellow 2 + base03 = "988ba2"; # Black 2 + base04 = "96cdf8"; # Blue 2 + base05 = "d9e0ee"; # Foreground + base06 = "ddb6f2"; # Magenta 2 + base07 = "d9e0ee"; # White 2 + base08 = "f28fad"; # Red 1 + base09 = "f28fad"; # Red 2 + base0A = "fae3b0"; # Yellow 1 + base0B = "abe9b3"; # Green 1 + base0C = "89dceb"; # Cyan 1 + base0D = "96cdfb"; # Blue 1 + base0E = "f5c2e7"; # Magenta 1 + base0F = "89dceb"; # Cyan 2 + }; + nord = { + slug = "Nord"; + scheme = "Nord"; + author = "arcticicestudio"; + base00 = "2E3440"; + base01 = "ECEFF4"; + base02 = "B48EAD"; + base03 = "4C566A"; + base04 = "D8DEE9"; + base05 = "E5E9F0"; + base06 = "434C5E"; + base07 = "8FBCBB"; + base08 = "BF616A"; + base09 = "3B4252"; + base0A = "EBCB8B"; + base0B = "A3BE8C"; + base0C = "88C0D0"; + base0D = "5E81AC"; + base0E = "D08770"; + base0F = "81A1C1"; + }; + onedark = { + slug = "onedark"; + scheme = "OneDark"; + author = "Lalit Magant (http://github.com/tilal6991)"; + base00 = "282c34"; + base01 = "353b45"; + base02 = "3e4451"; + base03 = "545862"; + base04 = "565c64"; + base05 = "abb2bf"; + base06 = "b6bdca"; + base07 = "c8ccd4"; + base08 = "e06c75"; + base09 = "d19a66"; + base0A = "e5c07b"; + base0B = "98c379"; + base0C = "56b6c2"; + base0D = "61afef"; + base0E = "c678dd"; + base0F = "be5046"; + }; + }; +in +{ + options.my.theming = { + enable = mkOption { + default = false; + type = types.bool; + example = true; + }; + scheme = mkOption { + default = "dracula"; + type = types.enum (builtins.attrNames schemes); + apply = name: schemes."${name}"; + example = "nord"; + }; + }; + config = mkIf cfg.enable { + inherit (cfg) scheme; + home-manager.users.moritz = { + programs = { + kitty.extraConfig = + mkIf config.my.programs.kitty.enable + (builtins.readFile (config.scheme { + template = '' + # Base16 {{scheme-name}} - kitty color config + # Scheme by {{scheme-author}} + background #{{base00-hex}} + foreground #{{base05-hex}} + selection_background #{{base05-hex}} + selection_foreground #{{base00-hex}} + url_color #{{base04-hex}} + cursor #{{base03-hex}} + active_border_color #{{base03-hex}} + inactive_border_color #{{base01-hex}} + active_tab_background #{{base00-hex}} + active_tab_foreground #{{base05-hex}} + inactive_tab_background #{{base01-hex}} + inactive_tab_foreground #{{base04-hex}} + tab_bar_background #{{base01-hex}} + + # normal + color0 #{{base00-hex}} + color1 #{{base08-hex}} + color2 #{{base0B-hex}} + color3 #{{base0A-hex}} + color4 #{{base0D-hex}} + color5 #{{base0E-hex}} + color6 #{{base0C-hex}} + color7 #{{base05-hex}} + + # bright + color8 #{{base03-hex}} + color9 #{{base09-hex}} + color10 #{{base01-hex}} + color11 #{{base02-hex}} + color12 #{{base04-hex}} + color13 #{{base06-hex}} + color14 #{{base0F-hex}} + color15 #{{base07-hex}} + ''; + })); + zathura.extraConfig = builtins.readFile (config.scheme { + template = '' + # Base16 {{scheme-name}} + # Author: {{scheme-author}} + + set completion-bg "#{{base00-hex}}" + set completion-fg "#{{base05-hex}}" + set completion-group-bg "#{{base00-hex}}" + set completion-group-fg "#{{base03-hex}}" + set completion-highlight-bg "#{{base07-hex}}" + set completion-highlight-fg "#{{base06-hex}}" + + set notification-bg "#{{base00-hex}}" + set notification-fg "#{{base05-hex}}" + set notification-warning-bg "#{{base0A-hex}}" + set notification-warning-fg "#{{base05-hex}}" + set notification-error-bg "#{{base08-hex}}" + set notification-error-fg "#{{base05-hex}}" + + set index-bg "#{{base00-hex}}" + set index-fg "#{{base05-hex}}" + set index-active-bg "#{{base07-hex}}" + set index-active-fg "#{{base05-hex}}" + + set default-bg "#{{base00-hex}}" + set default-fg "#{{base05-hex}}" + + set inputbar-bg "#{{base00-hex}}" + set inputbar-fg "#{{base0C-hex}}" + set statusbar-bg "#{{base00-hex}}" + set statusbar-fg "#{{base05-hex}}" + + set highlight-color "#{{base0A-hex}}" + set highlight-active-color "#{{base06-hex}}" + + set recolor-lightcolor "#{{base00-hex}}" + set recolor-darkcolor "#{{base05-hex}}" + ''; + }); + rofi.theme = config.scheme { + template = '' + * { + drac-bgd: #{{base00-hex}}; + drac-cur: #{{base07-hex}}; + drac-fgd: #{{base05-hex}}; + drac-cmt: #{{base03-hex}}; + drac-cya: #{{base0C-hex}}; + drac-grn: #{{base0B-hex}}; + drac-ora: #{{base0A-hex}}; + drac-pnk: #{{base0E-hex}}; + drac-pur: #{{base0D-hex}}; + drac-red: #{{base08-hex}}; + drac-yel: #{{base0A-hex}}; + + font: "FiraCode Nerd Font 14"; + + foreground: @drac-fgd; + background-color: @drac-bgd; + active-background: @drac-pnk; + urgent-background: @drac-red; + + selected-background: @active-background; + selected-urgent-background: @urgent-background; + selected-active-background: @active-background; + separatorcolor: @active-background; + bordercolor: #6272a4; + } + + #window { + background-color: @background; + border: 3; + border-radius: 6; + border-color: @bordercolor; + padding: 25; + } + #mainbox { + border: 0; + padding: 5; + } + #message { + border: 1px dash 0px 0px ; + border-color: @separatorcolor; + padding: 1px ; + } + #textbox { + text-color: @foreground; + } + #listview { + fixed-height: 0; + border: 2px dash 0px 0px ; + border-color: @bordercolor; + spacing: 2px ; + scrollbar: false; + padding: 2px 0px 0px ; + } + #element-text { + border: 0; + padding: 1px ; + text-color: @foreground; + } + #element-text normal.normal { + background-color: @background; + } + #element-text normal.urgent { + background-color: @urgent-background; + text-color: @urgent-foreground; + } + #element-text normal.active { + backgroundr: @active-background; + } + #element-text selected.normal { + background-color: @selected-background; + } + #element-text selected.urgent { + background-color: @selected-urgent-background; + } + #element-text selected.active { + background-color: @selected-active-background; + } + #element-text alternate.normal { + background-color: @background; + } + #element-text alternate.urgent { + background-color: @urgent-background; + } + #element-text alternate.active { + background-color: @active-background; + } + #scrollbar { + width: 2px ; + border: 0; + handle-width: 8px ; + padding: 0; + } + #sidebar { + border: 2px dash 0px 0px ; + border-color: @separatorcolor; + } + #button selected { + background-color: @selected-background; + text-color: @foreground; + } + #inputbar { + spacing: 0; + text-color: @foreground; + padding: 1px ; + } + #case-indicator { + spacing: 0; + text-color: @foreground; + } + #entry { + spacing: 0; + text-color: @drac-cya; + } + #prompt { + spacing: 0; + text-color: @drac-grn; + } + #inputbar { + children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; + } + #textbox-prompt-colon { + expand: false; + str: ":"; + margin: 0px 0.3em 0em 0em ; + text-color: @drac-grn; + } + ''; + }; + firefox.profiles."default" = { + userChrome = with config.scheme; '' + toolbar#nav-bar, nav-bar-customization-target { + background: #${base00} !important; + } + @-moz-document url("about:newtab"), + @-moz-document url("about:blank") { + * { background-color: #${base00} !important; } + } + #urlbar-background { + background-color: #${base00} !important + } + #urlbar { + color: #${base05} !important + } + #sidebar-splitter { + border-color: #${base01} !important; + color: #${base01} !important; + background-color: #${base01} !important; + } + ''; + settings = with config.scheme; { + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + "browser.anchor_color" = "#${base0D}"; + "browser.visited_color" = "#${base0C}"; + }; + }; + }; + xsession.windowManager.bspwm = { + settings = with config.scheme.withHashtag; { + focused_border_color = base0D; + normal_border_color = base03; + active_border_color = base03; + }; + }; + services.polybar = { + config = with config.scheme.withHashtag; { + "bar/bottom" = { + # position + monitor = "\${env:MONITOR}"; + bottom = true; + width = "100%"; + heigth = 20; + + background = base00; + foreground = base05; + + border-size = 5; + border-color = base00; + + separator = " "; + + font-0 = "FiraCode Nerd Font:size=9;0"; + font-1 = "FiraCode Nerd Font:size=9;1"; + font-2 = "FiraCode Nerd Font:size=9;2"; + + modules-left = "cpu memory network battery"; + modules-center = "bspwm"; + modules-right = "pulseaudio date time"; + + tray-position = "right"; + tray-padding = 2; + + wm-restack = "bspwm"; + + cursor-click = "pointer"; + cursor-scroll = "ns-resize"; + }; + "module/battery" = { + type = "internal/battery"; + battery = "BATT"; + adapter = "ACAD"; + time-format = "%H:%M"; + + format-charging = " "; + format-discharging = " "; + format-full = " "; + + label-charging = "%percentage%% %time% remaining"; + label-discharging = "%percentage%% %time% remaining"; + label-full = "Fully charged"; + + animation-charging-0 = " "; + animation-charging-1 = " "; + animation-charging-2 = " "; + animation-charging-3 = " "; + animation-charging-4 = " "; + animation-charging-framerate = 500; + + animation-discharging-0 = " "; + animation-discharging-1 = " "; + animation-discharging-2 = " "; + animation-discharging-3 = " "; + animation-discharging-4 = " "; + animation-discharging-framerate = 500; + }; + "module/bspwm" = { + type = "internal/bspwm"; + + label-focused = ""; + label-focused-foreground = base0E; + label-focused-padding = 1; + + label-occupied = ""; + label-occupied-foreground = base03; + label-occupied-padding = 1; + + label-urgent = ""; + label-urgent-foreground = base08; + label-urgent-padding = 1; + + label-empty = ""; + label-empty-foreground = base03; + label-empty-padding = 1; + + label-separator = " "; + label-separator-foreground = base0C; + label-separator-padding = 1; + + pin-workspaces = true; + }; + "module/cpu" = { + type = "internal/cpu"; + interval = 2; + + format = "