diff --git a/README.org b/README.org index 9a12a64..93e6c64 100644 --- a/README.org +++ b/README.org @@ -590,6 +590,7 @@ nixos = nixpkgs.lib.nixosSystem { modules = [ ./hosts/nixos <> + <> <> <> <> @@ -614,6 +615,7 @@ Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#nixo ]; modules.x11.enable = true; + modules.xdg.enable = true; modules.ssh.enable = true; modules.hugo.enable = true; modules.flakes.enable = true; @@ -723,13 +725,6 @@ in { 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 @@ -756,6 +751,50 @@ in { } #+END_SRC +** XDG + +#+NAME: module-xdg +#+BEGIN_SRC nix +./modules/x11.nix +#+END_SRC + +The [[https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html][XDG Base Directory Specification]] is based on the following concepts: + +| Environment Variable | Default | Purpose | +|----------------------+--------------------+---------------------------------------------------------------------------| +| XDG_CONFIG_HOME | $HOME/.config | Where user-specific configurations should be written | +| XDG_CACHE_HOME | $HOME/.cache | Where user-specific non essential date should be written | +| XDG_DATA_HOME | $HOME/.local/share | Where user-specific data files should be written | +| XDG_STATE_HOME | $HOME/.local/state | Where user-sspecific state files should be written | +| XDG_RUNTIME_DIR | /run/user/$UID | Non-essential, user-specific date files such as sockets, named pipes, etc | + +#+BEGIN_SRC nix :noweb yes :tangle modules/xdg.nix +< +{ config, options, lib, pkgs, ... }: + +with lib; +with lib.types; +let cfg = config.modules.xdg; +in { + options.modules.xdg = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + 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"; + }; + }; +} +#+END_SRC + ** SSH #+NAME: module-ssh diff --git a/flake.nix b/flake.nix index bdab0b6..edea5d0 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,7 @@ modules = [ ./hosts/nixos ./modules/x11.nix + ./modules/x11.nix ./modules/ssh.nix ./modules/hugo.nix ./modules/docker.nix diff --git a/hosts/nixos/default.nix b/hosts/nixos/default.nix index 1281028..7e00cc1 100644 --- a/hosts/nixos/default.nix +++ b/hosts/nixos/default.nix @@ -8,6 +8,7 @@ ]; modules.x11.enable = true; + modules.xdg.enable = true; modules.ssh.enable = true; modules.hugo.enable = true; modules.flakes.enable = true; diff --git a/modules/x11.nix b/modules/x11.nix index 8473876..bf896b2 100644 --- a/modules/x11.nix +++ b/modules/x11.nix @@ -19,13 +19,6 @@ in { 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 diff --git a/modules/xdg.nix b/modules/xdg.nix new file mode 100644 index 0000000..d19dda1 --- /dev/null +++ b/modules/xdg.nix @@ -0,0 +1,24 @@ +< +{ config, options, lib, pkgs, ... }: + +with lib; +with lib.types; +let cfg = config.modules.xdg; +in { + options.modules.xdg = { + enable = mkOption { + type = bool; + default = false; + }; + }; + + config = mkIf cfg.enable { + 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"; + }; + }; +}