From 86535623cfcf948ade9674f82f5eecec57f25238 Mon Sep 17 00:00:00 2001 From: Emmet Date: Thu, 22 Jun 2023 15:48:09 -0500 Subject: [PATCH] More user config variables set in flake --- flake.nix | 29 +++++++++++++++++++++++------ profiles/personal/home.nix | 2 +- profiles/work/home.nix | 11 +++++++++-- user/wm/xmonad/xmonad.hs | 9 +++++---- user/wm/xmonad/xmonad.org | 9 +++++---- 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/flake.nix b/flake.nix index 2777f74..0001504 100644 --- a/flake.nix +++ b/flake.nix @@ -14,27 +14,39 @@ username = "emmet"; # username name = "Emmet"; # name/identifier email = "librephoenix3@pm.me"; # email (used for certain configurations) - dotfilesDir = "~/.dotfiles"; # absolute path of the repo locally - theme = "ayu-dark"; # selcted theme from my themes directory - wm = "xmonad"; # Selected window manager or desktop environment + dotfilesDir = "~/.dotfiles"; # absolute path of the local repo + theme = "ayu-dark"; # selcted theme from my themes directory (./themes/) + wm = "xmonad"; # Selected window manager or desktop environment; must select one in both ./user/wm/ and ./system/wm/ + browser = "librewolf"; # Default browser; must select one from ./user/app/browser/ + editor = "emacsclient"; # Default editor; + term = "alacritty -o font.size=20"; # Default terminal command; font = "Inconsolata"; # Selected font fontPkg = pkgs.inconsolata; # Font package - # set pkgs to correct type + # editor spawning translator + # generates a command that can be used to spawn editor inside a gui + # EDITOR and TERM session variables must be set in home.nix or other module + # I set the session variable SPAWNEDITOR to this in my home.nix for convenience + spawnEditor = if (editor == "emacsclient") then "emacsclient -c -a 'emacs'" + else (if (editor == ("vim" || "nvim" || "nano")) then "$TERM -e $EDITOR" else editor); + + # configure pkgs pkgs = import nixpkgs { inherit system; config = { allowUnfree = true; }; overlays = [ rust-overlay.overlays.default ]; }; + # configure lib lib = nixpkgs.lib; in { homeConfigurations = { emmet = home-manager.lib.homeManagerConfiguration { inherit pkgs; - modules = [ (./. + "/profiles"+("/"+profile)+"/home.nix") ]; # load home.nix from profile + modules = [ (./. + "/profiles"+("/"+profile)+"/home.nix") ]; # load home.nix from selected PROFILE extraSpecialArgs = { + # pass config variables from above inherit username; inherit name; inherit hostname; @@ -44,6 +56,10 @@ inherit font; inherit fontPkg; inherit wm; + inherit browser; + inherit editor; + inherit term; + inherit spawnEditor; inherit (inputs) nix-doom-emacs; inherit (inputs) stylix; inherit (inputs) eaf; @@ -55,8 +71,9 @@ nixosConfigurations = { snowfire = lib.nixosSystem { inherit system; - modules = [ (./. + "/profiles"+("/"+profile)+"/configuration.nix") ]; # load configuration.nix from profile + modules = [ (./. + "/profiles"+("/"+profile)+"/configuration.nix") ]; # load configuration.nix from selected PROFILE specialArgs = { + # pass config variables from above inherit username; inherit name; inherit hostname; diff --git a/profiles/personal/home.nix b/profiles/personal/home.nix index efedf8c..7b9af93 100644 --- a/profiles/personal/home.nix +++ b/profiles/personal/home.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, python3Packages, nix-doom-emacs, stylix, username, email, dotfilesDir, theme, ... }: +{ config, lib, pkgs, python3Packages, nix-doom-emacs, stylix, username, email, dotfilesDir, theme, wm, browser, editor, spawnEditor, term, ... }: { # Home Manager needs a bit of information about you and the paths it should diff --git a/profiles/work/home.nix b/profiles/work/home.nix index fec6bfd..f59a444 100644 --- a/profiles/work/home.nix +++ b/profiles/work/home.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, python3Packages, nix-doom-emacs, stylix, username, email, dotfilesDir, theme, wm, ... }: +{ config, lib, pkgs, python3Packages, nix-doom-emacs, stylix, username, email, dotfilesDir, theme, wm, browser, editor, spawnEditor, term, ... }: { # Home Manager needs a bit of information about you and the paths it should @@ -19,7 +19,7 @@ ../../user/app/ranger/ranger.nix # My ranger file manager config ../../user/app/git/git.nix # My git config ../../user/app/keepass/keepass.nix # My password manager - ../../user/app/browser/librewolf.nix # My default browser + (./. + "../../../user/app/browser"+("/"+browser)+".nix") # My default browser selected from flake ../../user/app/virtualization/virtualization.nix # Virtual machines ../../user/app/flatpak/flatpak.nix # Flatpaks ../../user/style/stylix.nix # Styling and themes for my apps @@ -100,4 +100,11 @@ xdg.mime.enable = true; xdg.mimeApps.enable = true; + home.sessionVariables = { + EDITOR = editor; + SPAWNEDITOR = spawnEditor; + TERM = term; + BROWSER = browser; + }; + } diff --git a/user/wm/xmonad/xmonad.hs b/user/wm/xmonad/xmonad.hs index ddf9624..db64d50 100644 --- a/user/wm/xmonad/xmonad.hs +++ b/user/wm/xmonad/xmonad.hs @@ -48,8 +48,10 @@ myFocusedBorderColor = colorFocus -- Default apps myTerminal, myBrowser :: String -myTerminal = "alacritty -o font.size=20" -myBrowser = "librewolf" +myTerminal = "$TERM" +myBrowser = "$BROWSER" +myEditor = "$EDITOR" +mySpawnEditor = "$SPAWNEDITOR" -- Whether focus follows the mouse pointer. myFocusFollowsMouse :: Bool @@ -108,7 +110,6 @@ myScratchPads = w = 0.9 t = 0.95 - h l = 0.95 - w - --spawnRanger = myTerminal ++ " --title ranger-scratchpad -e ranger" spawnRanger = "kitty --title ranger-scratchpad -e ranger" findRanger = title =? "ranger-scratchpad" manageRanger = customFloating $ W.RationalRect l t w h @@ -191,7 +192,7 @@ myKeys conf@(XConfig {XMonad.modMask = modm}) = ((modm, xK_Return), spawn $ XMonad.terminal conf), -- launch emacsclient - ((modm, xK_a), spawn "emacsclient -c -a 'emacs'"), + ((modm, xK_a), spawn mySpawnEditor), -- launch browser ((modm, xK_s), spawn myBrowser), diff --git a/user/wm/xmonad/xmonad.org b/user/wm/xmonad/xmonad.org index 00fc3e6..a8f460d 100644 --- a/user/wm/xmonad/xmonad.org +++ b/user/wm/xmonad/xmonad.org @@ -89,8 +89,10 @@ myFocusedBorderColor = colorFocus #+BEGIN_SRC haskell :tangle xmonad.hs -- Default apps myTerminal, myBrowser :: String -myTerminal = "alacritty -o font.size=20" -myBrowser = "librewolf" +myTerminal = "$TERM" +myBrowser = "$BROWSER" +myEditor = "$EDITOR" +mySpawnEditor = "$SPAWNEDITOR" #+END_SRC *** Mouse Focus @@ -167,7 +169,6 @@ myScratchPads = w = 0.9 t = 0.95 - h l = 0.95 - w - --spawnRanger = myTerminal ++ " --title ranger-scratchpad -e ranger" spawnRanger = "kitty --title ranger-scratchpad -e ranger" findRanger = title =? "ranger-scratchpad" manageRanger = customFloating $ W.RationalRect l t w h @@ -268,7 +269,7 @@ The following binds the following: ((modm, xK_Return), spawn $ XMonad.terminal conf), -- launch emacsclient - ((modm, xK_a), spawn "emacsclient -c -a 'emacs'"), + ((modm, xK_a), spawn mySpawnEditor), -- launch browser ((modm, xK_s), spawn myBrowser),