diff --git a/README.org b/README.org index 6413058..098ae79 100644 --- a/README.org +++ b/README.org @@ -605,13 +605,22 @@ Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#nixo #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/default.nix # <> -{ ... }: +{ config, ... }: { imports = [ ./configuration.nix ./hardware.nix ]; + + modules.x11.enable = true; + modules.ssh.enable = true; + modules.hugo.enable = true; + modules.godot.enable = true; + modules.flakes.enable = true; + modules.cachix.enable = true; + modules.docker.enable = true; + modules.firefox.enable = true; } #+END_SRC @@ -695,44 +704,56 @@ Modules are files combined by [[https://nixos.org/][NixOS]] to produce the full #+BEGIN_SRC nix :noweb yes :tangle modules/x11.nix # <> -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - services.xserver.enable = true; - services.xserver.layout = "us"; - services.xserver.libinput.enable = true; - services.xserver.displayManager.startx.enable = true; - - environment = { - variables = { - XDG_DESKTOP_DIR = "$HOME/"; - XDG_CACHE_HOME = "$HOME/.cache"; - XDG_CONFIG_HOME = "$HOME/.config"; - XDG_DATA_HOME = "$HOME/.local/share"; - XDG_BIN_HOME = "$HOME/.local/bin"; +with lib; +with lib.types; +let cfg = config.modules.x11; +in { + options.modules.x11 = { + enable = mkOption { + type = bool; + default = false; }; - systemPackages = with pkgs; [ - pkgs.sqlite - pkgs.pfetch - pkgs.cmatrix - pkgs.asciiquarium - ]; - extraInit = '' - export XAUTHORITY=/tmp/Xauthority - export xserverauthfile=/tmp/xserverauth - [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY" - [ -e ~/.serverauth.* ] && mv -f ~/.serverauth.* "$xserverauthfile" - ''; }; - services.picom.enable = true; - services.printing.enable = true; + config = mkIf cfg.enable { + services.xserver.enable = true; + services.xserver.layout = "us"; + services.xserver.libinput.enable = true; + services.xserver.displayManager.startx.enable = true; + + environment = { + variables = { + XDG_DESKTOP_DIR = "$HOME/"; + XDG_CACHE_HOME = "$HOME/.cache"; + XDG_CONFIG_HOME = "$HOME/.config"; + XDG_DATA_HOME = "$HOME/.local/share"; + XDG_BIN_HOME = "$HOME/.local/bin"; + }; + systemPackages = with pkgs; [ + pkgs.sqlite + pkgs.pfetch + pkgs.cmatrix + pkgs.asciiquarium + ]; + extraInit = '' + export XAUTHORITY=/tmp/Xauthority + export xserverauthfile=/tmp/xserverauth + [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY" + [ -e ~/.serverauth.* ] && mv -f ~/.serverauth.* "$xserverauthfile" + ''; + }; + + services.picom.enable = true; + services.printing.enable = true; - fonts.fonts = with pkgs; [ - iosevka-bin - fira-code-symbols - emacs-all-the-icons-fonts - ]; + fonts.fonts = with pkgs; [ + iosevka-bin + fira-code-symbols + emacs-all-the-icons-fonts + ]; + }; } #+END_SRC @@ -752,14 +773,26 @@ Apply some configuration to the default settings: #+BEGIN_SRC nix :noweb yes :tangle modules/ssh.nix # <> -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - services.openssh = { - enable = true; - settings = { - PermitRootLogin = "no"; - PasswordAuthentication = false; +with lib; +with lib.types; +let cfg = config.modules.ssh; +in { + options.modules.ssh = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + services.openssh = { + enable = true; + settings = { + PermitRootLogin = "no"; + PasswordAuthentication = false; + }; }; }; } @@ -776,9 +809,12 @@ Apply some configuration to the default settings: #+BEGIN_SRC nix :noweb yes :tangle modules/hugo.nix # <> -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; +with lib.types; let + cfg = config.modules.hugo; mySiteDir = "/etc/dotfiles/docs/public/"; mySiteTgt = "ubuntu@chrishayward.xyz:/var/www/chrishayward"; mySiteBuild = pkgs.writeShellScriptBin "site-build" '' @@ -791,11 +827,20 @@ let ''; in { - environment.systemPackages = [ - pkgs.hugo - mySiteBuild - mySiteUpdate - ]; + options.modules.hugo = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ + pkgs.hugo + mySiteBuild + mySiteUpdate + ]; + }; } #+END_SRC @@ -810,16 +855,30 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/godot.nix # <> -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - environment.systemPackages = [ - pkgs.tiled - pkgs.godot - pkgs.godot-server - pkgs.godot-headless - pkgs.gdtoolkit - ]; +with lib; +with lib.types; +let + cfg = config.modules.godot; + +in { + options.modules.godot = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ + pkgs.tiled + pkgs.godot + pkgs.godot-server + pkgs.godot-headless + pkgs.gdtoolkit + ]; + }; } #+END_SRC @@ -834,19 +893,31 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/flakes.nix # <> -{ config, pkgs, inputs, ... }: +{ config, options, lib, pkgs, inputs, ... }: -{ - nix = { - package = pkgs.nixUnstable; - extraOptions = '' - experimental-features = nix-command flakes - ''; +with lib; +with lib.types; +let cfg = config.modules.flakes; +in { + options.modules.flakes = { + enable = mkOption { + type = bool; + default = false; + }; }; - nixpkgs = { - config = { allowUnfree = true; }; - overlays = [ inputs.emacs-overlay.overlay ]; + config = mkIf cfg.enable { + nix = { + package = pkgs.nixUnstable; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + + nixpkgs = { + config = { allowUnfree = true; }; + overlays = [ inputs.emacs-overlay.overlay ]; + }; }; } #+END_SRC @@ -862,17 +933,31 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/cachix.nix # <> -{ config, ... }: +{ config, options, lib, pkgs, ... }: -{ - nix = { - settings = { - substituters = [ - "https://nix-community.cachix.org" - ]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; +with lib; +with lib.types; +let + cfg = config.modules.cachix; + +in { + options.modules.cachix = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + nix = { + settings = { + substituters = [ + "https://nix-community.cachix.org" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; }; }; } @@ -889,24 +974,36 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/docker.nix # <> -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - # Enable the docker virutalization platform. - virtualisation.docker = { - enable = true; - enableOnBoot = true; - autoPrune.enable = true; +with lib; +with lib.types; +let cfg = config.modules.docker; +in { + options.modules.docker = { + enable = mkOption { + type = bool; + default = false; + }; }; - # Required for the `docker' command. - users.users.chris.extraGroups = [ "docker" ]; - - # Add docker extensions. - environment.systemPackages = [ - pkgs.docker-compose - pkgs.docker-machine - ]; + config = mkIf cfg.enable { + # Enable the docker virutalization platform. + virtualisation.docker = { + enable = true; + enableOnBoot = true; + autoPrune.enable = true; + }; + + # Required for the `docker' command. + users.users.chris.extraGroups = [ "docker" ]; + + # Add docker extensions. + environment.systemPackages = [ + pkgs.docker-compose + pkgs.docker-machine + ]; + }; } #+END_SRC @@ -921,18 +1018,30 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/firefox.nix # <> -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; +with lib.types; let + cfg = config.modules.firefox; myFirefox = pkgs.writeShellScriptBin "firefox" '' HOME=~/.local/share/mozilla ${pkgs.firefox-bin}/bin/firefox ''; in { - # NOTE: Use the binary until module is developed. - environment.systemPackages = [ - myFirefox - ]; + options.modules.firefox = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + # NOTE: Use the binary until module is developed. + environment.systemPackages = [ + myFirefox + ]; + }; } #+END_SRC @@ -947,6 +1056,7 @@ inputs.home-manager.nixosModules.home-manager { home-manager.useUserPackages = true; home-manager.users.chris = { home.stateVersion = "23.05"; + imports = [ <> <> @@ -954,6 +1064,18 @@ inputs.home-manager.nixosModules.home-manager { <> <> ]; + + modules.git = { + enable = true; + name = "Christopher James Hayward"; + email = "chris@chrishayward.xyz"; + key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F"; + }; + + modules.gpg.enable = true; + modules.vim.enable = true; + modules.gtk.enable = true; + modules.emacs.enable = true; }; } #+END_SRC @@ -977,9 +1099,13 @@ This module MUST be included within home manager #+BEGIN_SRC nix :noweb yes :tangle modules/git.nix # <> # <> -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; +with lib.types; let + cfg = config.modules.git; + # Fix any corruptions in the local copy. myGitFix = pkgs.writeShellScriptBin "git-fix" '' if [ -d .git/objects/ ]; then @@ -991,16 +1117,40 @@ let ''; in { - home.packages = [ myGitFix ]; + options.modules.git = { + enable = mkOption { + type = bool; + default = false; + }; - programs.git = { - enable = true; - userName = "Christopher James Hayward"; - userEmail = "chris@chrishayward.xyz"; + name = mkOption { + type = str; + default = "Anon"; + }; - signing = { - key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F"; - signByDefault = true; + email = mkOption { + type = str; + default = "anon@devnull.com"; + }; + + key = mkOption { + type = str; + default = "ABCD1234"; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ myGitFix ]; + + programs.git = { + enable = true; + userName = cfg.name; + userEmail = cfg.email; + + signing = { + key = cfg.key; + signByDefault = true; + }; }; }; } @@ -1018,14 +1168,27 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/gpg.nix # <> # <> -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - services.gpg-agent = { - enable = true; - defaultCacheTtl = 1800; - enableSshSupport = true; - pinentryFlavor = "gtk2"; +with lib; +with lib.types; +let + cfg = config.modules.gpg; +in { + options.modules.gpg = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + services.gpg-agent = { + enable = true; + defaultCacheTtl = 1800; + enableSshSupport = true; + pinentryFlavor = "gtk2"; + }; }; } #+END_SRC @@ -1047,26 +1210,38 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/vim.nix # <> # <> -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - extraConfig = '' - set number relativenumber - set nobackup - ''; - extraPackages = [ - pkgs.nixfmt - ]; - plugins = with pkgs.vimPlugins; [ - vim-nix - vim-airline - vim-polyglot - ]; +with lib; +with lib.types; +let cfg = config.modules.vim; +in { + options.modules.vim = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + extraConfig = '' + set number relativenumber + set nobackup + ''; + extraPackages = [ + pkgs.nixfmt + ]; + plugins = with pkgs.vimPlugins; [ + vim-nix + vim-airline + vim-polyglot + ]; + }; }; } #+END_SRC @@ -1083,66 +1258,78 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/gtk.nix # <> # <> -{ pkgs, ... }: - -{ - home.packages = [ - pkgs.nordic - pkgs.arc-icon-theme - pkgs.lxappearance - ]; +{ config, options, lib, pkgs, ... }: - home.file.".gtkrc-2.0" = { - text = '' - gtk-theme-name="Nordic-darker" - gtk-icon-theme-name="Arc" - gtk-font-name="Iosevka 11" - gtk-cursor-theme-size=0 - gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ - gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR - gtk-button-images=0 - gtk-menu-images=0 - gtk-enable-event-sounds=1 - gtk-enable-input-feedback-sounds=1 - gtk-xft-antialias=1 - gtk-xft-hinting=1 - gtk-xft-hintstyle="hintmedium" - ''; +with lib; +with lib.types; +let cfg = config.modules.gtk; +in { + options.modules.gtk = { + enable = mkOption { + type = bool; + default = false; + }; }; - home.file.".config/gtk-2.0/gtkfilechooser.ini" = { - text = '' - [Filechooser Settings] - LocationMode=path-bar - ShowHidden=false - ShowSizeColumn=true - GeometryX=442 - GeometryY=212 - GeometryWidth=1036 - GeometryHeight=609 - SortColumn=name - SortOrder=ascending - StartupMode=recent - ''; - }; + config = mkIf cfg.enable { + home.packages = [ + pkgs.nordic + pkgs.arc-icon-theme + pkgs.lxappearance + ]; + + home.file.".gtkrc-2.0" = { + text = '' + gtk-theme-name="Nordic-darker" + gtk-icon-theme-name="Arc" + gtk-font-name="Iosevka 11" + gtk-cursor-theme-size=0 + gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ + gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR + gtk-button-images=0 + gtk-menu-images=0 + gtk-enable-event-sounds=1 + gtk-enable-input-feedback-sounds=1 + gtk-xft-antialias=1 + gtk-xft-hinting=1 + gtk-xft-hintstyle="hintmedium" + ''; + }; + + home.file.".config/gtk-2.0/gtkfilechooser.ini" = { + text = '' + [Filechooser Settings] + LocationMode=path-bar + ShowHidden=false + ShowSizeColumn=true + GeometryX=442 + GeometryY=212 + GeometryWidth=1036 + GeometryHeight=609 + SortColumn=name + SortOrder=ascending + StartupMode=recent + ''; + }; - home.file.".config/gtk-3.0/settings.ini" = { - text = '' - [Settings] - gtk-theme-name=Nordic-darker - gtk-icon-theme-name=Arc - gtk-font-name=Iosevka 11 - gtk-cursor-theme-size=0 - gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ - gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR - gtk-button-images=0 - gtk-menu-images=0 - gtk-enable-event-sounds=1 - gtk-enable-input-feedback-sounds=1 - gtk-xft-antialias=1 - gtk-xft-hinting=1 - gtk-xft-hintstyle=hintmedium - ''; + home.file.".config/gtk-3.0/settings.ini" = { + text = '' + [Settings] + gtk-theme-name=Nordic-darker + gtk-icon-theme-name=Arc + gtk-font-name=Iosevka 11 + gtk-cursor-theme-size=0 + gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ + gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR + gtk-button-images=0 + gtk-menu-images=0 + gtk-enable-event-sounds=1 + gtk-enable-input-feedback-sounds=1 + gtk-xft-antialias=1 + gtk-xft-hinting=1 + gtk-xft-hintstyle=hintmedium + ''; + }; }; } #+END_SRC @@ -1170,9 +1357,13 @@ in { #+BEGIN_SRC nix :noweb yes :tangle modules/emacs.nix # <> # <> -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; +with lib.types; let + cfg = config.modules.emacs; + myEmacs = pkgs.emacsWithPackagesFromUsePackage { config = ../README.org; package = <> @@ -1231,26 +1422,35 @@ let }; in { - home.packages = [ - <> - <> - <> - <> - <> - <> - <> - <> - <> - ]; - - programs.emacs = { - enable = true; - package = myEmacs; + options.modules.emacs = { + enable = mkOption { + type = bool; + default = false; + }; }; - <> - <> - <> + config = mkIf cfg.enable { + home.packages = [ + <> + <> + <> + <> + <> + <> + <> + <> + <> + ]; + + programs.emacs = { + enable = true; + package = myEmacs; + }; + + <> + <> + <> + }; } #+END_SRC @@ -1809,7 +2009,7 @@ epkgs.hydra #+BEGIN_SRC emacs-lisp ;; Configure the font when running as `emacs-server'. (custom-set-faces - '(default ((t (:inherit nil :height 120 :family "Iosevka"))))) + '(default ((t (:inherit nil :height 120 :family "Iosevka Term"))))) ;; Define a `hydra' function for scaling the text interactively. (defhydra hydra-text-scale (:timeout 4) diff --git a/flake.nix b/flake.nix index 4032fb1..53e5c38 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,7 @@ home-manager.useUserPackages = true; home-manager.users.chris = { home.stateVersion = "23.05"; + imports = [ ./modules/git.nix ./modules/gpg.nix @@ -39,6 +40,18 @@ ./modules/gtk.nix ./modules/emacs.nix ]; + + modules.git = { + enable = true; + name = "Christopher James Hayward"; + email = "chris@chrishayward.xyz"; + key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F"; + }; + + modules.gpg.enable = true; + modules.vim.enable = true; + modules.gtk.enable = true; + modules.emacs.enable = true; }; } ]; diff --git a/hosts/nixos/default.nix b/hosts/nixos/default.nix index 8454369..e5b41c3 100644 --- a/hosts/nixos/default.nix +++ b/hosts/nixos/default.nix @@ -1,9 +1,18 @@ # This file is controlled by /etc/dotfiles/README.org -{ ... }: +{ config, ... }: { imports = [ ./configuration.nix ./hardware.nix ]; + + modules.x11.enable = true; + modules.ssh.enable = true; + modules.hugo.enable = true; + modules.godot.enable = true; + modules.flakes.enable = true; + modules.cachix.enable = true; + modules.docker.enable = true; + modules.firefox.enable = true; } diff --git a/modules/cachix.nix b/modules/cachix.nix index b3ddb25..9591f6a 100644 --- a/modules/cachix.nix +++ b/modules/cachix.nix @@ -1,15 +1,29 @@ # This file is controlled by /etc/dotfiles/README.org -{ config, ... }: +{ config, options, lib, pkgs, ... }: -{ - nix = { - settings = { - substituters = [ - "https://nix-community.cachix.org" - ]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; +with lib; +with lib.types; +let + cfg = config.modules.cachix; + +in { + options.modules.cachix = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + nix = { + settings = { + substituters = [ + "https://nix-community.cachix.org" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; }; }; } diff --git a/modules/docker.nix b/modules/docker.nix index 7f800bb..1df6719 100644 --- a/modules/docker.nix +++ b/modules/docker.nix @@ -1,20 +1,32 @@ # This file is controlled by /etc/dotfiles/README.org -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - # Enable the docker virutalization platform. - virtualisation.docker = { - enable = true; - enableOnBoot = true; - autoPrune.enable = true; +with lib; +with lib.types; +let cfg = config.modules.docker; +in { + options.modules.docker = { + enable = mkOption { + type = bool; + default = false; + }; }; - # Required for the `docker' command. - users.users.chris.extraGroups = [ "docker" ]; - - # Add docker extensions. - environment.systemPackages = [ - pkgs.docker-compose - pkgs.docker-machine - ]; + config = mkIf cfg.enable { + # Enable the docker virutalization platform. + virtualisation.docker = { + enable = true; + enableOnBoot = true; + autoPrune.enable = true; + }; + + # Required for the `docker' command. + users.users.chris.extraGroups = [ "docker" ]; + + # Add docker extensions. + environment.systemPackages = [ + pkgs.docker-compose + pkgs.docker-machine + ]; + }; } diff --git a/modules/emacs.nix b/modules/emacs.nix index 1aae27b..0912b1f 100644 --- a/modules/emacs.nix +++ b/modules/emacs.nix @@ -1,8 +1,12 @@ # This file is controlled by /etc/dotfiles/README.org # This module MUST be included within home manager -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; +with lib.types; let + cfg = config.modules.emacs; + myEmacs = pkgs.emacsWithPackagesFromUsePackage { config = ../README.org; package = pkgs.emacs-unstable; @@ -78,80 +82,89 @@ let }; in { - home.packages = [ - pkgs.arandr - pkgs.nitrogen - pkgs.autorandr - pkgs.pass - (pkgs.writeShellScriptBin "pass-init" '' - ${pkgs.git}/bin/git clone git@git.chrishayward.xyz:chris/passwords /home/chris/.password-store - ${pkgs.pass}/bin/pass init - '') - pkgs.mu - pkgs.isync - (pkgs.writeShellScriptBin "mail-init" '' - ${pkgs.mu}/bin/mu init --maildir="/home/chris/.cache/mail" --my-address="chris@chrishayward.xyz" - ${pkgs.mu}/bin/mu index - '') - (pkgs.writeShellScriptBin "mail-sync" '' - ${pkgs.isync}/bin/mbsync -a - '') - pkgs.aspell - pkgs.aspellDicts.en - pkgs.aspellDicts.en-science - pkgs.aspellDicts.en-computers - # pkgs.texlive.combined.scheme-full - pkgs.brightnessctl - pkgs.plantuml - pkgs.nixfmt - pkgs.rnix-lsp - (pkgs.writeShellScriptBin "dotfiles-theme" '' - ${myEmacs}/bin/emacsclient --no-wait --eval '(json-encode (dotfiles/theme))' | sed "s/\\\\//g" | sed -e 's/^"//' -e 's/"$//' - '') - ]; - - programs.emacs = { - enable = true; - package = myEmacs; + options.modules.emacs = { + enable = mkOption { + type = bool; + default = false; + }; }; - xsession = { - enable = true; - windowManager.command = '' - ${pkgs.nitrogen}/bin/nitrogen --restore - ${myEmacs}/bin/emacs --daemon -f exwm-enable - ${myEmacs}/bin/emacsclient -c - ''; - }; - home.file.".xinitrc" = { - text = '' - exec ./.xsession - ''; - }; - # Deploy the authinfo file. - home.file.".authinfo.gpg".source = ../config/authinfo.gpg; - - # Deploy the isync configuration file. - home.file.".mbsyncrc" = { - text = '' - IMAPStore xyz-remote - Host mail.chrishayward.xyz - User chris@chrishayward.xyz - PassCmd "pass chrishayward.xyz/chris" - SSLType IMAPS - - MaildirStore xyz-local - Path ~/.cache/mail/ - Inbox ~/.cache/mail/inbox - SubFolders Verbatim - - Channel xyz - Far :xyz-remote: - Near :xyz-local: - Patterns * !Archives - Create Both - Expunge Both - SyncState * - ''; + config = mkIf cfg.enable { + home.packages = [ + pkgs.arandr + pkgs.nitrogen + pkgs.autorandr + pkgs.pass + (pkgs.writeShellScriptBin "pass-init" '' + ${pkgs.git}/bin/git clone git@git.chrishayward.xyz:chris/passwords /home/chris/.password-store + ${pkgs.pass}/bin/pass init + '') + pkgs.mu + pkgs.isync + (pkgs.writeShellScriptBin "mail-init" '' + ${pkgs.mu}/bin/mu init --maildir="/home/chris/.cache/mail" --my-address="chris@chrishayward.xyz" + ${pkgs.mu}/bin/mu index + '') + (pkgs.writeShellScriptBin "mail-sync" '' + ${pkgs.isync}/bin/mbsync -a + '') + pkgs.aspell + pkgs.aspellDicts.en + pkgs.aspellDicts.en-science + pkgs.aspellDicts.en-computers + # pkgs.texlive.combined.scheme-full + pkgs.brightnessctl + pkgs.plantuml + pkgs.nixfmt + pkgs.rnix-lsp + (pkgs.writeShellScriptBin "dotfiles-theme" '' + ${myEmacs}/bin/emacsclient --no-wait --eval '(json-encode (dotfiles/theme))' | sed "s/\\\\//g" | sed -e 's/^"//' -e 's/"$//' + '') + ]; + + programs.emacs = { + enable = true; + package = myEmacs; + }; + + xsession = { + enable = true; + windowManager.command = '' + ${pkgs.nitrogen}/bin/nitrogen --restore + ${myEmacs}/bin/emacs --daemon -f exwm-enable + ${myEmacs}/bin/emacsclient -c + ''; + }; + home.file.".xinitrc" = { + text = '' + exec ./.xsession + ''; + }; + # Deploy the authinfo file. + home.file.".authinfo.gpg".source = ../config/authinfo.gpg; + + # Deploy the isync configuration file. + home.file.".mbsyncrc" = { + text = '' + IMAPStore xyz-remote + Host mail.chrishayward.xyz + User chris@chrishayward.xyz + PassCmd "pass chrishayward.xyz/chris" + SSLType IMAPS + + MaildirStore xyz-local + Path ~/.cache/mail/ + Inbox ~/.cache/mail/inbox + SubFolders Verbatim + + Channel xyz + Far :xyz-remote: + Near :xyz-local: + Patterns * !Archives + Create Both + Expunge Both + SyncState * + ''; + }; }; } diff --git a/modules/firefox.nix b/modules/firefox.nix index 10560f7..c847b5f 100644 --- a/modules/firefox.nix +++ b/modules/firefox.nix @@ -1,14 +1,26 @@ # This file is controlled by /etc/dotfiles/README.org -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; +with lib.types; let + cfg = config.modules.firefox; myFirefox = pkgs.writeShellScriptBin "firefox" '' HOME=~/.local/share/mozilla ${pkgs.firefox-bin}/bin/firefox ''; in { - # NOTE: Use the binary until module is developed. - environment.systemPackages = [ - myFirefox - ]; + options.modules.firefox = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + # NOTE: Use the binary until module is developed. + environment.systemPackages = [ + myFirefox + ]; + }; } diff --git a/modules/flakes.nix b/modules/flakes.nix index cf18b9e..71574a6 100644 --- a/modules/flakes.nix +++ b/modules/flakes.nix @@ -1,16 +1,28 @@ # This file is controlled by /etc/dotfiles/README.org -{ config, pkgs, inputs, ... }: +{ config, options, lib, pkgs, inputs, ... }: -{ - nix = { - package = pkgs.nixUnstable; - extraOptions = '' - experimental-features = nix-command flakes - ''; +with lib; +with lib.types; +let cfg = config.modules.flakes; +in { + options.modules.flakes = { + enable = mkOption { + type = bool; + default = false; + }; }; - nixpkgs = { - config = { allowUnfree = true; }; - overlays = [ inputs.emacs-overlay.overlay ]; + config = mkIf cfg.enable { + nix = { + package = pkgs.nixUnstable; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + + nixpkgs = { + config = { allowUnfree = true; }; + overlays = [ inputs.emacs-overlay.overlay ]; + }; }; } diff --git a/modules/git.nix b/modules/git.nix index 5b4355b..d53f5cb 100644 --- a/modules/git.nix +++ b/modules/git.nix @@ -1,8 +1,12 @@ # This file is controlled by /etc/dotfiles/README.org # This module MUST be included within home manager -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; +with lib.types; let + cfg = config.modules.git; + # Fix any corruptions in the local copy. myGitFix = pkgs.writeShellScriptBin "git-fix" '' if [ -d .git/objects/ ]; then @@ -14,16 +18,40 @@ let ''; in { - home.packages = [ myGitFix ]; + options.modules.git = { + enable = mkOption { + type = bool; + default = false; + }; + + name = mkOption { + type = str; + default = "Anon"; + }; - programs.git = { - enable = true; - userName = "Christopher James Hayward"; - userEmail = "chris@chrishayward.xyz"; + email = mkOption { + type = str; + default = "anon@devnull.com"; + }; + + key = mkOption { + type = str; + default = "ABCD1234"; + }; + }; - signing = { - key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F"; - signByDefault = true; + config = mkIf cfg.enable { + home.packages = [ myGitFix ]; + + programs.git = { + enable = true; + userName = cfg.name; + userEmail = cfg.email; + + signing = { + key = cfg.key; + signByDefault = true; + }; }; }; } diff --git a/modules/godot.nix b/modules/godot.nix index 58a5318..05f4fb3 100644 --- a/modules/godot.nix +++ b/modules/godot.nix @@ -1,12 +1,26 @@ # This file is controlled by /etc/dotfiles/README.org -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - environment.systemPackages = [ - pkgs.tiled - pkgs.godot - pkgs.godot-server - pkgs.godot-headless - pkgs.gdtoolkit - ]; +with lib; +with lib.types; +let + cfg = config.modules.godot; + +in { + options.modules.godot = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ + pkgs.tiled + pkgs.godot + pkgs.godot-server + pkgs.godot-headless + pkgs.gdtoolkit + ]; + }; } diff --git a/modules/gpg.nix b/modules/gpg.nix index 1b72008..277ba3e 100644 --- a/modules/gpg.nix +++ b/modules/gpg.nix @@ -1,12 +1,25 @@ # This file is controlled by /etc/dotfiles/README.org # This module MUST be included within home manager -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - services.gpg-agent = { - enable = true; - defaultCacheTtl = 1800; - enableSshSupport = true; - pinentryFlavor = "gtk2"; +with lib; +with lib.types; +let + cfg = config.modules.gpg; +in { + options.modules.gpg = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + services.gpg-agent = { + enable = true; + defaultCacheTtl = 1800; + enableSshSupport = true; + pinentryFlavor = "gtk2"; + }; }; } diff --git a/modules/gtk.nix b/modules/gtk.nix index 8aef6bf..66d15f6 100644 --- a/modules/gtk.nix +++ b/modules/gtk.nix @@ -1,64 +1,76 @@ # This file is controlled by /etc/dotfiles/README.org # This module MUST be included within home manager -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - home.packages = [ - pkgs.nordic - pkgs.arc-icon-theme - pkgs.lxappearance - ]; - - home.file.".gtkrc-2.0" = { - text = '' - gtk-theme-name="Nordic-darker" - gtk-icon-theme-name="Arc" - gtk-font-name="Iosevka 11" - gtk-cursor-theme-size=0 - gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ - gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR - gtk-button-images=0 - gtk-menu-images=0 - gtk-enable-event-sounds=1 - gtk-enable-input-feedback-sounds=1 - gtk-xft-antialias=1 - gtk-xft-hinting=1 - gtk-xft-hintstyle="hintmedium" - ''; +with lib; +with lib.types; +let cfg = config.modules.gtk; +in { + options.modules.gtk = { + enable = mkOption { + type = bool; + default = false; + }; }; - home.file.".config/gtk-2.0/gtkfilechooser.ini" = { - text = '' - [Filechooser Settings] - LocationMode=path-bar - ShowHidden=false - ShowSizeColumn=true - GeometryX=442 - GeometryY=212 - GeometryWidth=1036 - GeometryHeight=609 - SortColumn=name - SortOrder=ascending - StartupMode=recent - ''; - }; + config = mkIf cfg.enable { + home.packages = [ + pkgs.nordic + pkgs.arc-icon-theme + pkgs.lxappearance + ]; + + home.file.".gtkrc-2.0" = { + text = '' + gtk-theme-name="Nordic-darker" + gtk-icon-theme-name="Arc" + gtk-font-name="Iosevka 11" + gtk-cursor-theme-size=0 + gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ + gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR + gtk-button-images=0 + gtk-menu-images=0 + gtk-enable-event-sounds=1 + gtk-enable-input-feedback-sounds=1 + gtk-xft-antialias=1 + gtk-xft-hinting=1 + gtk-xft-hintstyle="hintmedium" + ''; + }; + + home.file.".config/gtk-2.0/gtkfilechooser.ini" = { + text = '' + [Filechooser Settings] + LocationMode=path-bar + ShowHidden=false + ShowSizeColumn=true + GeometryX=442 + GeometryY=212 + GeometryWidth=1036 + GeometryHeight=609 + SortColumn=name + SortOrder=ascending + StartupMode=recent + ''; + }; - home.file.".config/gtk-3.0/settings.ini" = { - text = '' - [Settings] - gtk-theme-name=Nordic-darker - gtk-icon-theme-name=Arc - gtk-font-name=Iosevka 11 - gtk-cursor-theme-size=0 - gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ - gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR - gtk-button-images=0 - gtk-menu-images=0 - gtk-enable-event-sounds=1 - gtk-enable-input-feedback-sounds=1 - gtk-xft-antialias=1 - gtk-xft-hinting=1 - gtk-xft-hintstyle=hintmedium - ''; + home.file.".config/gtk-3.0/settings.ini" = { + text = '' + [Settings] + gtk-theme-name=Nordic-darker + gtk-icon-theme-name=Arc + gtk-font-name=Iosevka 11 + gtk-cursor-theme-size=0 + gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ + gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR + gtk-button-images=0 + gtk-menu-images=0 + gtk-enable-event-sounds=1 + gtk-enable-input-feedback-sounds=1 + gtk-xft-antialias=1 + gtk-xft-hinting=1 + gtk-xft-hintstyle=hintmedium + ''; + }; }; } diff --git a/modules/hugo.nix b/modules/hugo.nix index 566c53b..e792cb9 100644 --- a/modules/hugo.nix +++ b/modules/hugo.nix @@ -1,7 +1,10 @@ # This file is controlled by /etc/dotfiles/README.org -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; +with lib.types; let + cfg = config.modules.hugo; mySiteDir = "/etc/dotfiles/docs/public/"; mySiteTgt = "ubuntu@chrishayward.xyz:/var/www/chrishayward"; mySiteBuild = pkgs.writeShellScriptBin "site-build" '' @@ -14,9 +17,18 @@ let ''; in { - environment.systemPackages = [ - pkgs.hugo - mySiteBuild - mySiteUpdate - ]; + options.modules.hugo = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ + pkgs.hugo + mySiteBuild + mySiteUpdate + ]; + }; } diff --git a/modules/ssh.nix b/modules/ssh.nix index c7dfdae..7cc476c 100644 --- a/modules/ssh.nix +++ b/modules/ssh.nix @@ -1,12 +1,24 @@ # This file is controlled by /etc/dotfiles/README.org -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - services.openssh = { - enable = true; - settings = { - PermitRootLogin = "no"; - PasswordAuthentication = false; +with lib; +with lib.types; +let cfg = config.modules.ssh; +in { + options.modules.ssh = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + services.openssh = { + enable = true; + settings = { + PermitRootLogin = "no"; + PasswordAuthentication = false; + }; }; }; } diff --git a/modules/vim.nix b/modules/vim.nix index df11dfa..2a1893b 100644 --- a/modules/vim.nix +++ b/modules/vim.nix @@ -1,24 +1,36 @@ # This file is controlled by /etc/dotfiles/README.org # This module MUST be included within home manager -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - extraConfig = '' - set number relativenumber - set nobackup - ''; - extraPackages = [ - pkgs.nixfmt - ]; - plugins = with pkgs.vimPlugins; [ - vim-nix - vim-airline - vim-polyglot - ]; +with lib; +with lib.types; +let cfg = config.modules.vim; +in { + options.modules.vim = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + extraConfig = '' + set number relativenumber + set nobackup + ''; + extraPackages = [ + pkgs.nixfmt + ]; + plugins = with pkgs.vimPlugins; [ + vim-nix + vim-airline + vim-polyglot + ]; + }; }; } diff --git a/modules/x11.nix b/modules/x11.nix index acf8339..68e90ca 100644 --- a/modules/x11.nix +++ b/modules/x11.nix @@ -1,40 +1,52 @@ # This file is controlled by /etc/dotfiles/README.org -{ config, pkgs, ... }: +{ config, options, lib, pkgs, ... }: -{ - services.xserver.enable = true; - services.xserver.layout = "us"; - services.xserver.libinput.enable = true; - services.xserver.displayManager.startx.enable = true; - - environment = { - variables = { - XDG_DESKTOP_DIR = "$HOME/"; - XDG_CACHE_HOME = "$HOME/.cache"; - XDG_CONFIG_HOME = "$HOME/.config"; - XDG_DATA_HOME = "$HOME/.local/share"; - XDG_BIN_HOME = "$HOME/.local/bin"; +with lib; +with lib.types; +let cfg = config.modules.x11; +in { + options.modules.x11 = { + enable = mkOption { + type = bool; + default = false; }; - systemPackages = with pkgs; [ - pkgs.sqlite - pkgs.pfetch - pkgs.cmatrix - pkgs.asciiquarium - ]; - extraInit = '' - export XAUTHORITY=/tmp/Xauthority - export xserverauthfile=/tmp/xserverauth - [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY" - [ -e ~/.serverauth.* ] && mv -f ~/.serverauth.* "$xserverauthfile" - ''; }; - services.picom.enable = true; - services.printing.enable = true; + config = mkIf cfg.enable { + services.xserver.enable = true; + services.xserver.layout = "us"; + services.xserver.libinput.enable = true; + services.xserver.displayManager.startx.enable = true; + + environment = { + variables = { + XDG_DESKTOP_DIR = "$HOME/"; + XDG_CACHE_HOME = "$HOME/.cache"; + XDG_CONFIG_HOME = "$HOME/.config"; + XDG_DATA_HOME = "$HOME/.local/share"; + XDG_BIN_HOME = "$HOME/.local/bin"; + }; + systemPackages = with pkgs; [ + pkgs.sqlite + pkgs.pfetch + pkgs.cmatrix + pkgs.asciiquarium + ]; + extraInit = '' + export XAUTHORITY=/tmp/Xauthority + export xserverauthfile=/tmp/xserverauth + [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY" + [ -e ~/.serverauth.* ] && mv -f ~/.serverauth.* "$xserverauthfile" + ''; + }; - fonts.fonts = with pkgs; [ - iosevka-bin - fira-code-symbols - emacs-all-the-icons-fonts - ]; + services.picom.enable = true; + services.printing.enable = true; + + fonts.fonts = with pkgs; [ + iosevka-bin + fira-code-symbols + emacs-all-the-icons-fonts + ]; + }; }