From 5cb16c34a8c5b803ec723934c1dc828c0e8e3bad Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Tue, 10 Sep 2024 11:52:55 -0500 Subject: Trying to get everything to actually work --- modules/lib/file-type.nix | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'modules/lib/file-type.nix') 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; })); }; -- cgit v1.2.3