-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
128 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,46 @@ | ||
{ lib, pkgs }: | ||
# https://github.com/nix-community/home-manager/blob/master/modules/lib/file-type.nix | ||
let | ||
inherit (lib) hasPrefix literalExpression mkDefault mkIf mkOption removePrefix types; | ||
{ name, config, lib, pkgs, ... }: | ||
with lib; let | ||
inherit (import ./lib.nix { inherit lib; }) storeFileName; | ||
in | ||
types.attrsOf (types.submodule ( | ||
{ name, config, ... }: { | ||
options = { | ||
enable = mkOption { | ||
type = types.bool; | ||
default = true; | ||
description = '' | ||
Whether this file should be generated. This option allows specific | ||
files to be disabled. | ||
''; | ||
}; | ||
|
||
target = mkOption { | ||
type = types.str; | ||
defaultText = literalExpression "<name>"; | ||
description = '' | ||
Path to target file. | ||
''; | ||
}; | ||
in { | ||
options = { | ||
enable = mkOption { | ||
type = types.bool; | ||
default = true; | ||
description = '' | ||
Whether this file should be generated. This option allows specific | ||
files to be disabled. | ||
''; | ||
}; | ||
|
||
text = mkOption { | ||
default = null; | ||
type = types.nullOr types.lines; | ||
description = '' | ||
Text of the file. If this option is null then | ||
<xref linkend="opt-home.file._name_.source"/> | ||
must be set. | ||
''; | ||
}; | ||
target = mkOption { | ||
type = types.str; | ||
default = name; | ||
defaultText = literalExpression "<name>"; | ||
description = '' | ||
Path to target file. | ||
''; | ||
}; | ||
|
||
source = mkOption { | ||
type = types.path; | ||
description = '' | ||
Path of the source file or directory. If | ||
<xref linkend="opt-home.file._name_.text"/> | ||
is non-null then this option will automatically point to a file | ||
containing that text. | ||
''; | ||
}; | ||
text = mkOption { | ||
type = types.lines; | ||
default = ""; | ||
description = '' | ||
Text of the file. If this option is null then | ||
<xref linkend="opt-home.file._name_.source"/> | ||
must be set. | ||
''; | ||
}; | ||
|
||
config = { | ||
target = mkDefault name; | ||
source = mkIf (config.text != null) ( | ||
mkDefault (pkgs.writeTextFile { | ||
inherit (config) text; | ||
executable = true; # can be null | ||
name = storeFileName name; | ||
}) | ||
); | ||
source = mkOption { | ||
type = types.path; | ||
default = pkgs.writeText (storeFileName name) config.text; | ||
description = '' | ||
Path of the source file or directory. If | ||
<xref linkend="opt-home.file._name_.text"/> | ||
is non-null then this option will automatically point to a file | ||
containing that text. | ||
''; | ||
}; | ||
} | ||
)) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.