From 9d90e3a822474eb3b19a23a024ade9358d2e2445 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 1 Mar 2021 20:43:12 -0500 Subject: [PATCH] Replace lib.paths with config.dotfiles.* --- default.nix | 11 ++++------- lib/paths.nix | 12 ------------ modules/agenix.nix | 2 +- modules/desktop/apps/rofi.nix | 21 +++++---------------- modules/desktop/browsers/qutebrowser.nix | 1 + modules/desktop/bspwm.nix | 1 + modules/desktop/media/graphics.nix | 1 + modules/desktop/media/ncmpcpp.nix | 1 + modules/desktop/stumpwm.nix | 1 + modules/editors/emacs.nix | 1 + modules/options.nix | 12 ++++++++++++ modules/services/docker.nix | 1 + modules/shell/git.nix | 1 + modules/shell/tmux.nix | 1 + modules/shell/zsh.nix | 1 + 15 files changed, 32 insertions(+), 36 deletions(-) delete mode 100644 lib/paths.nix diff --git a/default.nix b/default.nix index af2d6694..b53b235b 100644 --- a/default.nix +++ b/default.nix @@ -11,11 +11,8 @@ with lib.my; # Common config for all nixos machines; and to ensure the flake operates # soundly - environment.variables.DOTFILES = findFirst pathExists dotFilesDir [ - "${config.user.home}/.config/dotfiles" - "/etc/dotfiles" - ]; - environment.variables.DOTFILES_BIN = "$DOTFILES/bin"; + environment.variables.DOTFILES = config.dotfiles.dir; + environment.variables.DOTFILES_BIN = config.dotfiles.binDir; # Configure nix and nixpkgs environment.variables.NIXPKGS_ALLOW_UNFREE = "1"; @@ -27,8 +24,8 @@ with lib.my; package = pkgs.nixFlakes; extraOptions = "experimental-features = nix-command flakes"; nixPath = nixPathInputs ++ [ - "nixpkgs-overlays=${dotFilesDir}/overlays" - "dotfiles=${dotFilesDir}" + "nixpkgs-overlays=${config.dotfiles.dir}/overlays" + "dotfiles=${config.dotfiles.dir}" ]; binaryCaches = [ "https://nix-community.cachix.org" diff --git a/lib/paths.nix b/lib/paths.nix deleted file mode 100644 index ace93620..00000000 --- a/lib/paths.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ self, lib, ... }: - -with builtins; -with lib; -rec { - # ... - dotFilesDir = toString ../.; - modulesDir = "${dotFilesDir}/modules"; - configDir = "${dotFilesDir}/config"; - binDir = "${dotFilesDir}/bin"; - themesDir = "${modulesDir}/themes"; -} diff --git a/modules/agenix.nix b/modules/agenix.nix index 7aab72c2..826752aa 100644 --- a/modules/agenix.nix +++ b/modules/agenix.nix @@ -6,7 +6,7 @@ with builtins; with lib; with lib.my; let inherit (inputs) agenix; - secretsDir = "${dotFilesDir}/hosts/${config.networking.hostName}/secrets"; + secretsDir = "${config.dotfiles.dir}/hosts/${config.networking.hostName}/secrets"; secretsFile = "${secretsDir}/secrets.nix"; in { imports = [ agenix.nixosModules.age ]; diff --git a/modules/desktop/apps/rofi.nix b/modules/desktop/apps/rofi.nix index dade0e96..4b1f4916 100644 --- a/modules/desktop/apps/rofi.nix +++ b/modules/desktop/apps/rofi.nix @@ -21,48 +21,37 @@ in { exec ${pkgs.rofi}/bin/rofi -terminal xst -m -1 "$@" '') - # For rapidly test changes to rofi's stylesheets - # (writeScriptBin "rofi-test" '' - # #!${stdenv.shell} - # themefile=$1 - # themename=${my.theme.name} - # shift - # exec rofi \ - # -theme ${themesDir}/$themename/rofi/$themefile \ - # "$@" - # '') - # Fake rofi dmenu entries (makeDesktopItem { name = "rofi-browsermenu"; desktopName = "Open Bookmark in Browser"; icon = "bookmark-new-symbolic"; - exec = "$DOTFILES_BIN/rofi/browsermenu"; + exec = "${config.dotfiles.binDir}/rofi/browsermenu"; }) (makeDesktopItem { name = "rofi-browsermenu-history"; desktopName = "Open Browser History"; icon = "accessories-clock"; - exec = "$DOTFILES_BIN/rofi/browsermenu history"; + exec = "${config.dotfiles.binDir}/rofi/browsermenu history"; }) (makeDesktopItem { name = "rofi-filemenu"; desktopName = "Open Directory in Terminal"; icon = "folder"; - exec = "$DOTFILES_BIN/rofi/filemenu"; + exec = "${config.dotfiles.binDir}/rofi/filemenu"; }) (makeDesktopItem { name = "rofi-filemenu-scratch"; desktopName = "Open Directory in Scratch Terminal"; icon = "folder"; - exec = "$DOTFILES_BIN/rofi/filemenu -x"; + exec = "${config.dotfiles.binDir}/rofi/filemenu -x"; }) (makeDesktopItem { name = "lock-display"; desktopName = "Lock screen"; icon = "system-lock-screen"; - exec = "$DOTFILES_BIN/zzz"; + exec = "${config.dotfiles.binDir}/zzz"; }) ]; }; diff --git a/modules/desktop/browsers/qutebrowser.nix b/modules/desktop/browsers/qutebrowser.nix index 00cdf355..8421feea 100644 --- a/modules/desktop/browsers/qutebrowser.nix +++ b/modules/desktop/browsers/qutebrowser.nix @@ -9,6 +9,7 @@ with lib; with lib.my; let cfg = config.modules.desktop.browsers.qutebrowser; pkg = pkgs.unstable.qutebrowser; + configDir = config.dotfiles.configDir; in { options.modules.desktop.browsers.qutebrowser = with types; { enable = mkBoolOpt false; diff --git a/modules/desktop/bspwm.nix b/modules/desktop/bspwm.nix index 6b5a3380..3c0c9c84 100644 --- a/modules/desktop/bspwm.nix +++ b/modules/desktop/bspwm.nix @@ -3,6 +3,7 @@ with lib; with lib.my; let cfg = config.modules.desktop.bspwm; + configDir = config.dotfiles.configDir; in { options.modules.desktop.bspwm = { enable = mkBoolOpt false; diff --git a/modules/desktop/media/graphics.nix b/modules/desktop/media/graphics.nix index 07b0e71c..2b0f5387 100644 --- a/modules/desktop/media/graphics.nix +++ b/modules/desktop/media/graphics.nix @@ -10,6 +10,7 @@ with lib; with lib.my; let cfg = config.modules.desktop.media.graphics; + configDir = config.dotfiles.configDir; in { options.modules.desktop.media.graphics = { enable = mkBoolOpt false; diff --git a/modules/desktop/media/ncmpcpp.nix b/modules/desktop/media/ncmpcpp.nix index d65b05d4..449f069d 100644 --- a/modules/desktop/media/ncmpcpp.nix +++ b/modules/desktop/media/ncmpcpp.nix @@ -3,6 +3,7 @@ with lib; with lib.my; let cfg = config.modules.desktop.media.ncmpcpp; + configDir = config.dotfiles.configDir; in { options.modules.desktop.media.ncmpcpp = { enable = mkBoolOpt false; diff --git a/modules/desktop/stumpwm.nix b/modules/desktop/stumpwm.nix index 1f0472e3..18bacfff 100644 --- a/modules/desktop/stumpwm.nix +++ b/modules/desktop/stumpwm.nix @@ -3,6 +3,7 @@ with lib; with lib.my; let cfg = config.modules.desktop.stumpwm; + configDir = config.dotfiles.configDir; in { options.modules.desktop.stumpwm = { enable = mkBoolOpt false; diff --git a/modules/editors/emacs.nix b/modules/editors/emacs.nix index 506c5bbc..a7b77e30 100644 --- a/modules/editors/emacs.nix +++ b/modules/editors/emacs.nix @@ -7,6 +7,7 @@ with lib; with lib.my; let cfg = config.modules.editors.emacs; + configDir = config.dotfiles.configDir; in { options.modules.editors.emacs = { enable = mkBoolOpt false; diff --git a/modules/options.nix b/modules/options.nix index dcaee854..77d1df25 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -6,6 +6,18 @@ with lib.my; options = with types; { user = mkOpt attrs {}; + dotfiles = let t = either str path; in { + dir = mkOpt t + (findFirst pathExists (toString ../.) [ + "${config.user.home}/.config/dotfiles" + "/etc/dotfiles" + ]); + binDir = mkOpt t "${config.dotfiles.dir}/bin"; + configDir = mkOpt t "${config.dotfiles.dir}/config"; + modulesDir = mkOpt t "${config.dotfiles.dir}/modules"; + themesDir = mkOpt t "${config.dotfiles.modulesDir}/themes"; + }; + home = { file = mkOpt' attrs {} "Files to place directly in $HOME"; configFile = mkOpt' attrs {} "Files to place in $XDG_CONFIG_HOME"; diff --git a/modules/services/docker.nix b/modules/services/docker.nix index 5e854576..1c037243 100644 --- a/modules/services/docker.nix +++ b/modules/services/docker.nix @@ -3,6 +3,7 @@ with lib; with lib.my; let cfg = config.modules.services.docker; + configDir = config.dotfiles.configDir; in { options.modules.services.docker = { enable = mkBoolOpt false; diff --git a/modules/shell/git.nix b/modules/shell/git.nix index 3429d21e..bce956fe 100644 --- a/modules/shell/git.nix +++ b/modules/shell/git.nix @@ -3,6 +3,7 @@ with lib; with lib.my; let cfg = config.modules.shell.git; + configDir = config.dotfiles.configDir; in { options.modules.shell.git = { enable = mkBoolOpt false; diff --git a/modules/shell/tmux.nix b/modules/shell/tmux.nix index 0b0f8d58..0b5e0891 100644 --- a/modules/shell/tmux.nix +++ b/modules/shell/tmux.nix @@ -10,6 +10,7 @@ let cfg = config.modules.shell.tmux; #!${pkgs.stdenv.shell} exec ${pkgs.tmux}/bin/tmux -f "$TMUX_HOME/config" "$@" ''); + configDir = config.dotfiles.configDir; in { options.modules.shell.tmux = with types; { enable = mkBoolOpt false; diff --git a/modules/shell/zsh.nix b/modules/shell/zsh.nix index 68982c44..edbf1cd5 100644 --- a/modules/shell/zsh.nix +++ b/modules/shell/zsh.nix @@ -3,6 +3,7 @@ with lib; with lib.my; let cfg = config.modules.shell.zsh; + configDir = config.dotfiles.configDir; in { options.modules.shell.zsh = with types; { enable = mkBoolOpt false;