diff --git a/lib/contracts.ncl b/lib/contracts.ncl index d81cc72f..705a2024 100644 --- a/lib/contracts.ncl +++ b/lib/contracts.ncl @@ -14,10 +14,6 @@ let predicate | doc "Various predicates used to define contracts" std.is_record x && std.record.has_field type_field x && x."%{type_field}" == "nixInput", - is_nix_string = fun value => - std.is_record value - && std.record.has_field type_field value - && value."%{type_field}" == "nixString", is_nickel_derivation = fun x => std.is_record x && std.record.has_field type_field x @@ -33,13 +29,6 @@ let predicate | doc "Various predicates used to define contracts" } in -let mk_nix_string = fun fs => - { - "%{type_field}" = "nixString", - fragments = fs, - } -in - { # Nix may require name, version, etc. to have a certain format, but we're not sure. # TODO: refine those contracts @@ -148,20 +137,10 @@ from the Nix world) or a derivation defined in Nickel. `lib.import_file`), pure Nickel strings, and maybe more in the future. "%% = fun label value => - # A contract must always be idempotent (be a no-op if applied a second - # time), so we accept something that is already a NixString - if predicate.is_nix_string value then - value - # We accept a single string fragment (a plain string, a derivation or a - # Nix path). We normalize it by wrapping it as a one-element array - else if predicate.is_string_fragment value then - mk_nix_string [std.contract.apply NixStringFragment label value] + if predicate.is_string_fragment value then + std.contract.apply NixStringFragment label value else - # TODO: it's for debugging, but we should remove the serializing at some - # point. - let label = std.contract.label.append_note (std.serialize 'Json value) label in - let { fragments, .. } = std.contract.apply NixSymbolicString label value in - mk_nix_string fragments, + std.contract.apply NixSymbolicString label value, NixDerivation | doc m%" diff --git a/lib/lib.nix b/lib/lib.nix index 19b33dc7..6748c0d4 100644 --- a/lib/lib.nix +++ b/lib/lib.nix @@ -94,8 +94,6 @@ value.nix_drv); in derivation prepared - else if organistType == "nixString" - then builtins.concatStringsSep "" (builtins.map importFromNickel_ value.fragments) else if organistType == "nixPath" then baseDir + "/${value.path}" else if organistType == "nixInput" @@ -116,6 +114,8 @@ lib.getAttrFromPath chosenAttrPath flakeInputs else if organistType == "nixPlaceholder" then builtins.placeholder value.output + else if value.tag or "" == "SymbolicString" && value.prefix or "" == "nix" + then builtins.concatStringsSep "" (builtins.map importFromNickel_ value.fragments) else builtins.mapAttrs (_: importFromNickel_) value ) else if (type == "list")