File tree Expand file tree Collapse file tree
tests/modules/programs/flake-edit Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ time = "2026-07-25T14:39:10+00:00" ;
3+ condition = true ;
4+ message = ''
5+ A new module is available: 'programs.flake-edit',
6+ featuring a '.settings' option to generate {file}`$XDG_CONFIG_HOME/flake-edit/config.toml`
7+ '' ;
8+ }
Original file line number Diff line number Diff line change 1+ {
2+ config ,
3+ lib ,
4+ pkgs ,
5+ ...
6+ } :
7+ let
8+ name = "flake-edit" ;
9+ cfg = config . programs . ${ name } ;
10+ tomlFormat = pkgs . formats . toml { } ;
11+ configFile = "config.toml" ;
12+ configDir =
13+ if pkgs . stdenv . hostPlatform . isDarwin then "Library/Application Support" else config . xdg . configHome ;
14+ configPath = "${ name } /${ configFile } " ;
15+ in
16+ {
17+ meta . maintainers = with lib . maintainers ; [ malix ] ;
18+
19+ options . programs . ${ name } = {
20+ enable = lib . mkEnableOption name ;
21+
22+ package = lib . mkPackageOption pkgs name { nullable = true ; } ;
23+
24+ settings = lib . mkOption {
25+ inherit ( tomlFormat ) type ;
26+ default = { } ;
27+ example = {
28+ follow = {
29+ ignore = [
30+ "systems"
31+ "crane.flake-utils"
32+ ] ;
33+ transitive_min = 2 ;
34+ aliases = {
35+ nixpkgs = [ "nixpkgs-lib" ] ;
36+ } ;
37+ max_depth = 1 ;
38+ } ;
39+ } ;
40+ description = ''
41+ Configuration written to {file}`$XDG_CONFIG_HOME/${ configPath } ` on Linux or
42+ {file}`$HOME/Library/Application Support/${ configPath } ` on Darwin.
43+ See <https://github.com/a-kenji/${ name } #configuration> for documentation.
44+ '' ;
45+ } ;
46+ } ;
47+
48+ config = lib . mkIf cfg . enable {
49+ home . packages = lib . mkIf ( cfg . package != null ) [ cfg . package ] ;
50+
51+ home . file . "${ configDir } /${ configPath } " = lib . mkIf ( cfg . settings != { } ) {
52+ source = tomlFormat . generate configFile cfg . settings ;
53+ } ;
54+ } ;
55+ }
Original file line number Diff line number Diff line change 1+ {
2+ flake-edit-basic-settings =
3+ {
4+ lib ,
5+ pkgs ,
6+ ...
7+ } :
8+ let
9+ configDir = if pkgs . stdenv . hostPlatform . isDarwin then "Library/Application Support" else ".config" ;
10+ configFile = "home-files/${ configDir } /flake-edit/config.toml" ;
11+ in
12+ {
13+ programs . flake-edit = {
14+ enable = true ;
15+ settings = {
16+ follow = {
17+ ignore = [
18+ "systems"
19+ "crane.flake-utils"
20+ ] ;
21+ transitive_min = 2 ;
22+ aliases = {
23+ nixpkgs = [ "nixpkgs-lib" ] ;
24+ } ;
25+ max_depth = 1 ;
26+ } ;
27+ } ;
28+ } ;
29+
30+ nmt . script = ''
31+ assertFileExists ${ lib . escapeShellArg configFile }
32+ assertFileContent ${ lib . escapeShellArg configFile } \
33+ ${ pkgs . writeText "flake-edit-expected.toml" ''
34+ [follow]
35+ ignore = ["systems", "crane.flake-utils"]
36+ max_depth = 1
37+ transitive_min = 2
38+
39+ [follow.aliases]
40+ nixpkgs = ["nixpkgs-lib"]
41+ '' }
42+ '' ;
43+ } ;
44+ }
You can’t perform that action at this time.
0 commit comments