aboutsummaryrefslogtreecommitdiff
path: root/modules/lib/file-type.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/lib/file-type.nix')
-rw-r--r--modules/lib/file-type.nix22
1 files changed, 17 insertions, 5 deletions
diff --git a/modules/lib/file-type.nix b/modules/lib/file-type.nix
index c95c0d4..f02daa1 100644
--- a/modules/lib/file-type.nix
+++ b/modules/lib/file-type.nix
@@ -1,4 +1,4 @@
-{ writeTextFile, lib, ... }:
+{ writeTextFile, linkFarm, lib, ... }:
{ name, config, ... }:
with builtins // lib;
let
@@ -6,7 +6,7 @@ let
let
safeChars = [ "+" "." "_" "?" "=" ] ++ lowerChars ++ upperChars ++ stringToCharacters "0123456789";
empties = l: genList (_: "") (length l);
- unsafeInName = stringToCharacters (replaceStrings safeChars (empties safeChars) p;
+ unsafeInName = stringToCharacters (replaceStrings safeChars (empties safeChars) p);
in "kobo_" + replaceStrings unsafeInName (empties unsafeInName) p;
in {
options = {
@@ -17,7 +17,7 @@ in {
target = mkOption {
type = types.str;
default = name;
- apply = x: if isPrefix "/" x then x else "/${x}";
+ apply = x: if hasPrefix "/" x then x else "/${x}";
};
executable = mkOption {
type = with types; nullOr bool;
@@ -30,12 +30,24 @@ in {
source = mkOption {
type = types.path;
};
+ _package = mkOption {
+ type = types.path;
+ readOnly = true;
+ internal = true;
+ default = linkFarm (sanitize name) [{
+ name = removePrefix "/" config.target;
+ # let
+ # t = config.target;
+ # in if
+ path = config.source;
+ }];
+ };
};
config = {
- source = mkIf (cfg.text != null) (mkDefault (writeTextFile {
+ source = mkIf (config.text != null) (mkDefault (writeTextFile {
inherit (config) text;
- name = sanitieze name;
+ name = sanitize name;
executable = config.executable == true;
}));
};