Skip to content

Commit

Permalink
xdg: add option 'xdg.stateFile'
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisie authored Sep 6, 2024
1 parent 03b4918 commit b00bdf5
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions modules/misc/xdg.nix
Original file line number Diff line number Diff line change
@@ -70,6 +70,16 @@ in {
'';
};

stateFile = mkOption {
type = fileType "xdg.stateFile" "<varname>xdg.stateHome</varname>"
cfg.stateHome;
default = { };
description = ''
Attribute set of files to link into the user's XDG
state home.
'';
};

stateHome = mkOption {
type = types.path;
defaultText = "~/.local/state";
@@ -122,6 +132,8 @@ in {
cfg.configFile)
(mapAttrs' (name: file: nameValuePair "${cfg.dataHome}/${name}" file)
cfg.dataFile)
(mapAttrs' (name: file: nameValuePair "${cfg.stateHome}/${name}" file)
cfg.stateFile)
{ "${cfg.cacheHome}/.keep".text = ""; }
];
}
2 changes: 1 addition & 1 deletion tests/modules/misc/xdg/file-gen.nix
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ with lib;

xdg.configFile.test.text = "config";
xdg.dataFile.test.text = "data";
xdg.stateFile.test.text = "state";
home.file."${config.xdg.cacheHome}/test".text = "cache";
home.file."${config.xdg.stateHome}/test".text = "state";

nmt.script = ''
assertFileExists home-files/.dummy-config/test

0 comments on commit b00bdf5

Please sign in to comment.