You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: Many programs don't support the XDG Base Directory specification. These programs often pollute a user's $HOME directory or other directories with unwanted files that would be better placed in the appropriate XDG directories.
Solution: Many of these programs can be configured to use alternate files/directories by running the program with CLI options passed, environment variables set, or config files/options set. Wrap these programs with whatever is necessary to get these programs closer to the XDG Base Directory spec.
List of Programs
ArchLinux Wiki: XDG Base Directory: List of programs, XDG Base Directory spec support status, & configuration to make them adhere to the spec.
Create wrapped packages with included env vars, cmdline options, and/or config files.
Overlay original packages w/ wrapped version, so no other NixOS / home-manager config is necessary.
Create new packages and set NixOS / home-manager options like program.<name>.package = pkgs.<name>-xdg-compliant (or whatever name) to use the wrapped versions while keeping the original programs.
writeShellScriptBinAndSymlink = name: text: super.symlinkJoin {
name = name;
paths = [
super."${name}"
(super.writeShellScriptBin name text)
];
};
pkgs.writeShellScriptBin "hello" ''
# Call hello with a traditional greeting
exec ${pkgs.hello}/bin/hello -t
''
pkgs.runCommand "hello" {
buildInputs = [ pkgs.makeWrapper ];
} ''
mkdir $out
# Link every top-level folder from pkgs.hello to our new target
ln -s ${pkgs.hello}/* $out
# Except the bin folder
rm $out/bin
mkdir $out/bin
# We create the bin folder ourselves and link every binary in it
ln -s ${pkgs.hello}/bin/* $out/bin
# Except the hello binary
rm $out/bin/hello
# Because we create this ourself, by creating a wrapper
makeWrapper ${pkgs.hello}/bin/hello $out/bin/hello \
--add-flags "-t"
''
Problem: Many programs don't support the XDG Base Directory specification. These programs often pollute a user's
$HOME
directory or other directories with unwanted files that would be better placed in the appropriate XDG directories.Solution: Many of these programs can be configured to use alternate files/directories by running the program with CLI options passed, environment variables set, or config files/options set. Wrap these programs with whatever is necessary to get these programs closer to the XDG Base Directory spec.
List of Programs
antidot
rulesantidot
CSVxdg-ninja
program/*.json
filesPossibilities
program.<name>.package = pkgs.<name>-xdg-compliant
(or whatever name) to use the wrapped versions while keeping the original programs.Docs
xdg-ninja
package / repo / source codeantidot
package / repo / source codeNix Libs / Examples
Trivial Builders
pkgs.wrapShellScriptBin
pkgs.wrapShellScript
pkgs.runCommand
pkgs.writeText
pkgs.writeTextFile
Functions available in
pkgs.stdenv
makeWrapper <executable> <wrapperfile> <args>
wrapProgram <executable> <makeWrapperArgs>
Example Snippets
The text was updated successfully, but these errors were encountered: