From f3a5290a80f434ad126e72930862d1be9e935b3f Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 21 Mar 2024 15:59:10 -0500 Subject: [PATCH] let's do some inheritance shenanigans --- lib/default.nix | 4 +- modules/desktop/window-managers/hyprland.nix | 5 +- modules/development/cli.nix | 44 +++++++-------- modules/networking/vpn.nix | 12 ++-- modules/programs/chrome/default.nix | 46 ++++++++-------- modules/storage/restic.nix | 58 ++++++++++---------- modules/virtualization/docker.nix | 29 +++------- modules/virtualization/virtualbox.nix | 18 +++--- 8 files changed, 96 insertions(+), 120 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 058ee25..c494ab1 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -6,7 +6,7 @@ lib = nixpkgs.lib.extend (import ./extended.nix); inherit (builtins) mapAttrs readDir filter listToAttrs; - inherit (lib) nixosSystem genAttrs isNixFile; + inherit (lib) nixosSystem genAttrs isNixFile mkDefaultOizysModule mkOizysModule; inherit (lib.filesystem) listFilesRecursive; inherit (import ./find-modules.nix {inherit lib;}) findModulesList; @@ -29,7 +29,7 @@ in rec { isNixFile (listFilesRecursive (../. + "/hosts/${hostname}")); - specialArgs = {inherit inputs lib self;}; + specialArgs = {inherit inputs lib self mkDefaultOizysModule mkOizysModule;}; }; oizysHosts = mapAttrs (name: _: mkSystem name) (readDir ../hosts); diff --git a/modules/desktop/window-managers/hyprland.nix b/modules/desktop/window-managers/hyprland.nix index d9af273..ab28a32 100644 --- a/modules/desktop/window-managers/hyprland.nix +++ b/modules/desktop/window-managers/hyprland.nix @@ -2,10 +2,9 @@ inputs, pkgs, config, - lib, + mkOizysModule, ... }: let - inherit (lib) mkOizysModule enabled; lock = pkgs.writeShellApplication { name = "lock"; runtimeInputs = with pkgs; [swaylock]; @@ -15,7 +14,7 @@ }; in mkOizysModule config "hyprland" { - programs.hyprland = enabled; + programs.hyprland.enable = true; security.pam.services.swaylock = {}; # Optional, hint electron apps to use wayland: environment.sessionVariables.NIXOS_OZONE_WL = "1"; diff --git a/modules/development/cli.nix b/modules/development/cli.nix index be0b6e7..cb4d982 100644 --- a/modules/development/cli.nix +++ b/modules/development/cli.nix @@ -1,31 +1,29 @@ { inputs, - lib, pkgs, config, + mkDefaultOizysModule, ... -}: let - inherit (lib) mkDefaultOizysModule; -in - mkDefaultOizysModule config "cli" { - programs.direnv.enable = true; - environment.sessionVariables = { - DIRENV_LOG_FORMAT = "direnv: %s"; - }; +}: +mkDefaultOizysModule config "cli" { + programs.direnv.enable = true; + environment.sessionVariables = { + DIRENV_LOG_FORMAT = "direnv: %s"; + }; - environment.systemPackages = with pkgs; [ - chezmoi - zoxide - lsd - fzf + environment.systemPackages = with pkgs; [ + chezmoi + zoxide + lsd + fzf - # utils - fd - bat - delta - ripgrep + # utils + fd + bat + delta + ripgrep - btop - inputs.tsm.packages.${pkgs.system}.tsm - ]; - } + btop + inputs.tsm.packages.${pkgs.system}.tsm + ]; +} diff --git a/modules/networking/vpn.nix b/modules/networking/vpn.nix index 45294b2..a6371a3 100644 --- a/modules/networking/vpn.nix +++ b/modules/networking/vpn.nix @@ -1,11 +1,9 @@ { config, - lib, pkgs, + mkOizysModule, ... -}: let - inherit (lib) mkOizysModule; -in - mkOizysModule config "vpn" { - environment.systemPackages = [pkgs.openconnect]; - } +}: +mkOizysModule config "vpn" { + environment.systemPackages = [pkgs.openconnect]; +} diff --git a/modules/programs/chrome/default.nix b/modules/programs/chrome/default.nix index fb90a90..fafc79e 100644 --- a/modules/programs/chrome/default.nix +++ b/modules/programs/chrome/default.nix @@ -1,30 +1,28 @@ { pkgs, config, - lib, + mkOizysModule, ... -}: let - inherit (lib) mkOizysModule; -in - mkOizysModule config "chrome" { - programs.chromium = { - enable = true; +}: +mkOizysModule config "chrome" { + programs.chromium = { + enable = true; - extensions = [ - "nngceckbapebfimnlniiiahkandclblb" # bitwarden - "gfbliohnnapiefjpjlpjnehglfpaknnc" # surfingkeys - "pbmlfaiicoikhdbjagjbglnbfcbcojpj" # simplify gmail - "oemmndcbldboiebfnladdacbdfmadadm" # pdf viewer - "clngdbkpkpeebahjckkjfobafhncgmne" # stylus - "cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin - ]; - }; - - environment.systemPackages = with pkgs; [ - (google-chrome.override { - commandLineArgs = [ - "--force-dark-mode" - ]; - }) + extensions = [ + "nngceckbapebfimnlniiiahkandclblb" # bitwarden + "gfbliohnnapiefjpjlpjnehglfpaknnc" # surfingkeys + "pbmlfaiicoikhdbjagjbglnbfcbcojpj" # simplify gmail + "oemmndcbldboiebfnladdacbdfmadadm" # pdf viewer + "clngdbkpkpeebahjckkjfobafhncgmne" # stylus + "cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin ]; - } + }; + + environment.systemPackages = with pkgs; [ + (google-chrome.override { + commandLineArgs = [ + "--force-dark-mode" + ]; + }) + ]; +} diff --git a/modules/storage/restic.nix b/modules/storage/restic.nix index 8889975..2165a7e 100644 --- a/modules/storage/restic.nix +++ b/modules/storage/restic.nix @@ -1,37 +1,35 @@ { config, pkgs, - lib, + mkOizysModule, ... -}: let - inherit (lib) mkOizysModule; -in - mkOizysModule config "backups" { - environment.systemPackages = with pkgs; [rclone]; +}: +mkOizysModule config "backups" { + environment.systemPackages = with pkgs; [rclone]; - services.restic.backups.gdrive = { - # BUG: if .conda/environments.txt doesn't exist then this won't work - # workaround for now `mkdir ~/.conda && touch ~/.conda/environments.txt` + services.restic.backups.gdrive = { + # BUG: if .conda/environments.txt doesn't exist then this won't work + # workaround for now `mkdir ~/.conda && touch ~/.conda/environments.txt` - extraBackupArgs = [ - "--exclude-file /home/daylin/.config/restic/excludes.txt" - "--exclude-file /home/daylin/.conda/environments.txt" - "--verbose" - "--one-file-system" - "--tag systemd.timer" - ]; - pruneOpts = [ - "--verbose" - "--tag systemd.timer" - "--keep-daily 7" - "--keep-weekly 4" - "--keep-monthly 12" - "--keep-yearly 3" - ]; - timerConfig = { - OnCalendar = "00:05"; - Persistent = true; - RandomizedDelaySec = "5h"; - }; + extraBackupArgs = [ + "--exclude-file /home/daylin/.config/restic/excludes.txt" + "--exclude-file /home/daylin/.conda/environments.txt" + "--verbose" + "--one-file-system" + "--tag systemd.timer" + ]; + pruneOpts = [ + "--verbose" + "--tag systemd.timer" + "--keep-daily 7" + "--keep-weekly 4" + "--keep-monthly 12" + "--keep-yearly 3" + ]; + timerConfig = { + OnCalendar = "00:05"; + Persistent = true; + RandomizedDelaySec = "5h"; }; - } + }; +} diff --git a/modules/virtualization/docker.nix b/modules/virtualization/docker.nix index e1bf5f4..49a6198 100644 --- a/modules/virtualization/docker.nix +++ b/modules/virtualization/docker.nix @@ -1,25 +1,12 @@ { pkgs, config, - lib, + mkOizysModule, ... -}: let - inherit (lib) mkOizysModule; -in - mkOizysModule config "docker" { - virtualisation.docker.enable = true; - environment.systemPackages = with pkgs; [ - lazydocker - ]; - } -# in { -# options.oizys.docker.enable = mkEnableOption "enable docker support"; -# -# config = mkIf cfg.enable { -# virtualisation.docker.enable = true; -# environment.systemPackages = with pkgs; [ -# lazydocker -# ]; -# }; -# } - +}: +mkOizysModule config "docker" { + virtualisation.docker.enable = true; + environment.systemPackages = with pkgs; [ + lazydocker + ]; +} diff --git a/modules/virtualization/virtualbox.nix b/modules/virtualization/virtualbox.nix index 5e3f3c8..bac5a29 100644 --- a/modules/virtualization/virtualbox.nix +++ b/modules/virtualization/virtualbox.nix @@ -1,13 +1,11 @@ { config, - lib, + mkOizysModule, ... -}: let - inherit (lib) mkOizysModule; -in - mkOizysModule config "vbox" { - virtualisation.virtualbox = { - host.enable = true; - }; - users.extraGroups.vboxusers.members = ["daylin"]; - } +}: +mkOizysModule config "vbox" { + virtualisation.virtualbox = { + host.enable = true; + }; + users.extraGroups.vboxusers.members = ["daylin"]; +}