New patches: [unrevert anon**20260430213800 Ignore-this: 76ddbf3c57f0582a0d73d5e791b5d9d9bf291d82f93b0c6c8ce49174cc9ce4d0b1f6601786c5b17a ] conflictor [ hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; hunk ./lib/lock_loader.ml 15 - let maker = "toastal" - and maker_year_range = year_range 2025 - (* needs a more legally-defined term vs. a fun one :( *) - and hackmates = "Nixtamal contributors" - and hackmates_year_range = year_range 2026 - and margin = Format.pp_get_margin ppf () - in - let hr = - (*──────────────────────────────*) - let uchar = Uchar.of_int 0x2500 - and buf = Buffer.create (margin * 3) - in - for _ = 1 to margin do - Buffer.add_utf_8_uchar buf uchar - done; - Buffer.contents buf - in - pf ppf "/*@."; - pf ppf "SPDX-FileCopyrightText: %s %s@." maker_year_range maker; - pf ppf "SPDX-FileCopyrightText: %s %s@." hackmates_year_range hackmates; - pf ppf "SPDX-License-Identifier: ISC@."; - pf ppf "@."; - pf ppf "@[Permission@ to@ use,@ copy,@ modify,@ and/or@ distribute@ "; - pf ppf "this@ software@ for@ any@ purpose@ with@ or@ without@ fee@ is@ "; - pf ppf "hereby@ granted,@ provided@ that@ the@ above@ copyright@ notice@ &@ "; - pf ppf "this@ permission@ notice@ appear@ in@ all@ copies.@]@."; - pf ppf "@."; - pf ppf "@[THE@ SOFTWARE@ IS@ PROVIDED@ “AS@ IS”@ &@ ISC@ DISCLAIMS@ "; - pf ppf "ALL@ WARRANTIES@ WITH@ REGARD@ TO@ THIS@ SOFTWARE@ INCLUDING@ ALL@ "; - pf ppf "IMPLIED@ WARRANTIES@ OF@ MERCHANTABILITY@ &@ FITNESS.@ IN@ NO@ "; - pf ppf "EVENT@ SHALL@ ISC@ BE@ LIABLE@ FOR@ ANY@ SPECIAL,@ DIRECT,@ "; - pf ppf "INDIRECT,@ OR@ CONSEQUENTIAL@ DAMAGES@ OR@ ANY@ DAMAGES@ WHATSOEVER@ "; - pf ppf "RESULTING@ FROM@ LOSS@ OF@ USE,@ DATA@ OR@ PROFITS,@ WHETHER@ IN@ "; - pf ppf "AN@ ACTION@ OF@ CONTRACT,@ NEGLIGENCE@ OR@ OTHER@ TORTIOUS@ ACTION,@ "; - pf ppf "ARISING@ OUT@ OF@ OR@ IN@ CONNECTION@ WITH@ THE@ USE@ OR@ "; - pf ppf "PERFORMANCE@ OF@ THIS@ SOFTWARE.@]@."; - pf ppf "@."; - pf ppf "%s@." hr; - pf ppf "┏┓╻+╻ ╱┏┳┓┏┓┏┳┓┏┓╻@."; - pf ppf "┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃ This file was generated by Nixtamal.@."; - pf ppf "╹┗┛╹╱ ╹ ╹ ╹╹╹ ╹╹╹┗┛ Do not edit as it will be overwritten.@."; - pf ppf "%s@." hr; - pf ppf "*/@." - -let pp_nix_named_arg (ppf : Format.formatter) ((name, default): (string * string option)) = - pf ppf "%s%a" name (option (fun ppf v -> pf ppf " ? %s" v)) default - -let pp_nix_named_args fmt args = - let pp_args = list ~sep: (any ",@;") pp_nix_named_arg in - let break = Format.pp_print_custom_break ~fits: ("", 0, "") ~breaks: (",", 0, "") in - pf fmt "@[{@;<0 1>@[@[%a@]@]%t@]}:" pp_args args break - -let pp_cfg (ppf : Format.formatter) = - pp_nix_named_args ppf [ - ("system", Some "builtins.currentSystem"); - ("bootstrap-nixpkgs", Some "null"); - ("bootstrap-nixpkgs-lock-name", Some "null"); - ("bootstrap-pkgs", Some "null"); - ] - -(* TODO: consider *not* doing manually as this is ugly AF, but would probably - involve building a Nix AST to do properly, but even a Buffer.add_string or - Jingoo templates could improve this. *) -let pp_body ~version ~features (ppf : Format.formatter) () = - let feats = features in - pf ppf {|let lock = builtins.fromJSON (builtins.readFile ./lock.json); in@.|}; - pf ppf {|assert (lock.v == "%s");@.|} (Schema.Version.to_string version); - pf ppf {|let@.|}; - if Features.(has Flag.patches feats) then - begin - match Foreman.local_patches () with - | [] -> - pf ppf {| local-patches = {};@.|}; - | local_patches -> - pf ppf {| local-patches = {@.|}; - List.iter - (fun (patch_name, path) -> - pf ppf {| "%s" = %s;@.|} (Name.Patch.take patch_name) path - ) - local_patches; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| hash-token = {@.|}; - begin - let open Input.Hash in - for idx = - min_algorithm to max_algorithm do - match algorithm_of_enum idx with - | Some algo -> - pf - ppf - {| "%d" = "%s";@.|} - idx - (algorithm_to_hash_token algo) - | None -> () - done - end; - pf ppf {| };@.|}; - pf ppf {|@.|}; - pf ppf {| try-fetch = input-name: fetcher:@.|}; - pf ppf {| let@.|}; - pf ppf {| try-fetch' = failed-urls: url: urls:@.|}; - pf ppf {| let result = builtins.tryEval (fetcher url); in@.|}; - pf ppf {| if result.success then@.|}; - pf ppf {| result.value@.|}; - pf ppf {| else@.|}; - pf ppf {| let failed-urls' = [ url ] ++ failed-urls; in@.|}; - pf ppf {| if builtins.length urls <= 0 then@.|}; - pf ppf {| let fus = builtins.concatStringsSep " " failed-urls'; in@.|}; - pf ppf {| throw "Input 「${input-name}」fetchable @@ [ ${fus} ]"@.|}; - pf ppf {| else@.|}; - pf ppf {| try-fetch' failed-urls' (builtins.head urls) (builtins.tail urls);@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch' [ ];@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| builtin-fetch-url = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchurl ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|}; - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| builtin-fetch-tarball = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchTarball ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| builtin-fetch-git = {input-name, name, kind}:@.|}; - pf ppf {| let@.|}; - pf ppf {| ref =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| valu = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then # ref@.|}; - pf ppf {| valu@.|}; - pf ppf {| else if type == 1 then # branch@.|}; - pf ppf {| "refs/heads/${valu}"@.|}; - pf ppf {| else if type == 2 then # tag@.|}; - pf ppf {| "refs/tags/${valu}"@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported reference type “${builtins.toString type}”.";@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| let@.|}; - pf ppf {| args = {@.|}; - pf ppf {| inherit url ref;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| submodules = kind.sm;@.|}; - pf ppf {| lfs = kind.lf;@.|}; - pf ppf {| shallow = true;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {});@.|}; - pf ppf {| args' =@.|}; - pf ppf {| if builtins.compareVersions builtins.nixVersion "2.26" < 0 then@.|}; - pf ppf {| builtins.removeAttrs args [ "lfs" ]@.|}; - pf ppf {| else@.|}; - pf ppf {| args;@.|}; - pf ppf {| in@.|}; - pf ppf {| builtins.fetchGit args'@.|}; - pf ppf {| ) kind.rp kind.ms;@.|}; - pf ppf {|@.|} - end; - pf ppf {| builtin-to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| in@.|}; - pf ppf {| |}; - let builtin_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| builtin-fetch-url {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| builtin-fetch-tarball {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| builtin-fetch-git {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| }|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| fetch-darcs {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - pf ppf "@[%a@]@." (list ~sep: (any "@.\t\telse ") string) (Dynarray.to_list builtin_fetch_ifs); - Dynarray.clear builtin_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {|@.|}; - pf ppf {| nixpkgs' =@.|}; - pf ppf {| if builtins.isNull bootstrap-nixpkgs then@.|}; - pf ppf {| builtin-to-input "nixpkgs-for-nixtamal" (@.|}; - pf ppf {| if builtins.isString bootstrap-nixpkgs-lock-name then@.|}; - pf ppf {| lock.i.${bootstrap-nixpkgs-lock-name}@.|}; - pf ppf {| else@.|}; - pf ppf {| lock.i.nixpkgs-nixtamal or lock.i.nixpkgs@.|}; - pf ppf {| )@.|}; - pf ppf {| else@.|}; - pf ppf {| bootstrap-nixpkgs;@.|}; - pf ppf {|@.|}; - pf ppf {| pkgs =@.|}; - pf ppf {| if builtins.isAttrs bootstrap-pkgs then@.|}; - pf ppf {| bootstrap-pkgs@.|}; - pf ppf {| else@.|}; - pf ppf {| import nixpkgs' {inherit system;};@.|}; - pf ppf {|@.|}; - pf ppf {| inherit (pkgs) lib;@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; - pf ppf {| # base gnutar doesn’t support Zstandard@.|}; - pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| fetch-git = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchgit.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchgit ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| fetchSubmodules = kind.sm;@.|}; - pf ppf {| fetchLFS = kind.lf;@.|}; - pf ppf {| deepClone = false;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.darcs feats) then - begin - pf ppf {| fetch-darcs = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchdarcs.__functionArgs ? "mirrors";@.|}; - pf ppf {| reference =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| value = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then@.|}; - pf ppf {| let ctx_path = builtins.elemAt value 1; in@.|}; - pf ppf {| assert (lib.hasSuffix ".txt" ctx_path);@.|}; - pf ppf {| let@.|}; - pf ppf {| txt-files = lib.sourceFilesBySuffices ./. [ ".txt" ];@.|}; - pf ppf {| dir = lib.fileset.toSource {@.|}; - pf ppf {| root = ./.;@.|}; - pf ppf {| fileset = lib.fileset.fromSource txt-files;@.|}; - pf ppf {| };@.|}; - pf ppf {| in@.|}; - pf ppf {| {context = "${dir}/${ctx_path}";}@.|}; - pf ppf {| else if type == 1 then@.|}; - pf ppf {| {rev = value;}@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Invalid Darcs reference";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchdarcs doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchdarcs ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // reference // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.pijul feats) then - begin - pf ppf {| fetch-pijul = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchpijul.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchpijul doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchpijul ({@.|}; - pf ppf {| url = kind.rm;@.|}; - pf ppf {| state = kind.ls;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.fossil feats) then - begin - pf ppf {| fetch-fossil = {input-name, name, kind, hash}:@.|}; - pf ppf {| pkgs.fetchfossil ({@.|}; - pf ppf {| inherit name;@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lc;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.patches feats) then - begin - pf ppf {| fetch-patch = patch-name: {ur, ha}:@.|}; - pf ppf {| pkgs.fetchpatch2 {@.|}; - pf ppf {| url = ur;@.|}; - pf ppf {| hash = ha.vl;@.|}; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| raw-input =@.|}; - pf ppf {| |}; - let pkgs_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-url {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-url {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-zip {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-tarball {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-git {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-git {inherit input-name name kind;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-darcs {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.pijul feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 4 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-pijul {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.fossil feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 5 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-fossil {inherit input-name name kind hash;}|}; - ] - ); - pf - ppf - "@[%a@]@." - (list ~sep: (any "@. else ") string) - (Dynarray.to_list pkgs_fetch_ifs); - Dynarray.clear pkgs_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {| in@.|}; - if Features.(has Flag.patches feats) then - begin - pf ppf {| if builtins.length input.ps == 0 then@.|}; - pf ppf {| raw-input@.|}; - pf ppf {| else@.|}; - pf ppf {| pkgs.applyPatches {@.|}; - pf ppf {| src = raw-input;@.|}; - pf ppf {| name = "${if name != null then name else "src"}-patched";@.|}; - pf ppf {| patches = map (p:@.|}; - pf ppf {| if local-patches ? "${p}" then@.|}; - pf ppf {| local-patches."${p}"@.|}; - pf ppf {| else@.|}; - pf ppf {| fetch-patch p lock.p."${p}"@.|}; - pf ppf {| ) input.ps;@.|}; - pf ppf {| };@.|}; - end - else - begin - pf ppf {| raw-input;@.|}; - end; - pf ppf {|in@.|}; - pf ppf {|builtins.mapAttrs to-input lock.i@.|} - -let pp ~version ~features (ppf : Format.formatter) = - Logs.debug (fun m -> m "pp features: %a" Features.pp features); - set_utf_8 ppf true; - let custom_formatter_functions : Format.formatter_out_functions = - let sf = Format.pp_get_formatter_out_functions ppf () in - {sf with out_indent = fun n -> sf.out_string (String.make n '\t') 0 n} - in - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - Format.pp_set_margin Format.std_formatter 80; - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - pp_banner ppf; - pp_cfg ppf; - pf ppf "@.@."; - pp_body ~version ~features ppf () - -let write ?(version = Lazy.(force Schema.Version.latest)) () = - Logs.info (fun m -> m "Lock_loader.write: starting"); - let working_dir = Working_directory.get () in - let filepath = Eio.Path.(working_dir / filename) in ] : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; + pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl ({@.|}; conflictor {{ hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 15 - let maker = "toastal" - and maker_year_range = year_range 2025 - (* needs a more legally-defined term vs. a fun one :( *) - and hackmates = "Nixtamal contributors" - and hackmates_year_range = year_range 2026 - and margin = Format.pp_get_margin ppf () - in - let hr = - (*──────────────────────────────*) - let uchar = Uchar.of_int 0x2500 - and buf = Buffer.create (margin * 3) - in - for _ = 1 to margin do - Buffer.add_utf_8_uchar buf uchar - done; - Buffer.contents buf - in - pf ppf "/*@."; - pf ppf "SPDX-FileCopyrightText: %s %s@." maker_year_range maker; - pf ppf "SPDX-FileCopyrightText: %s %s@." hackmates_year_range hackmates; - pf ppf "SPDX-License-Identifier: ISC@."; - pf ppf "@."; - pf ppf "@[Permission@ to@ use,@ copy,@ modify,@ and/or@ distribute@ "; - pf ppf "this@ software@ for@ any@ purpose@ with@ or@ without@ fee@ is@ "; - pf ppf "hereby@ granted,@ provided@ that@ the@ above@ copyright@ notice@ &@ "; - pf ppf "this@ permission@ notice@ appear@ in@ all@ copies.@]@."; - pf ppf "@."; - pf ppf "@[THE@ SOFTWARE@ IS@ PROVIDED@ “AS@ IS”@ &@ ISC@ DISCLAIMS@ "; - pf ppf "ALL@ WARRANTIES@ WITH@ REGARD@ TO@ THIS@ SOFTWARE@ INCLUDING@ ALL@ "; - pf ppf "IMPLIED@ WARRANTIES@ OF@ MERCHANTABILITY@ &@ FITNESS.@ IN@ NO@ "; - pf ppf "EVENT@ SHALL@ ISC@ BE@ LIABLE@ FOR@ ANY@ SPECIAL,@ DIRECT,@ "; - pf ppf "INDIRECT,@ OR@ CONSEQUENTIAL@ DAMAGES@ OR@ ANY@ DAMAGES@ WHATSOEVER@ "; - pf ppf "RESULTING@ FROM@ LOSS@ OF@ USE,@ DATA@ OR@ PROFITS,@ WHETHER@ IN@ "; - pf ppf "AN@ ACTION@ OF@ CONTRACT,@ NEGLIGENCE@ OR@ OTHER@ TORTIOUS@ ACTION,@ "; - pf ppf "ARISING@ OUT@ OF@ OR@ IN@ CONNECTION@ WITH@ THE@ USE@ OR@ "; - pf ppf "PERFORMANCE@ OF@ THIS@ SOFTWARE.@]@."; - pf ppf "@."; - pf ppf "%s@." hr; - pf ppf "┏┓╻+╻ ╱┏┳┓┏┓┏┳┓┏┓╻@."; - pf ppf "┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃ This file was generated by Nixtamal.@."; - pf ppf "╹┗┛╹╱ ╹ ╹ ╹╹╹ ╹╹╹┗┛ Do not edit as it will be overwritten.@."; - pf ppf "%s@." hr; - pf ppf "*/@." - -let pp_nix_named_arg (ppf : Format.formatter) ((name, default): (string * string option)) = - pf ppf "%s%a" name (option (fun ppf v -> pf ppf " ? %s" v)) default - -let pp_nix_named_args fmt args = - let pp_args = list ~sep: (any ",@;") pp_nix_named_arg in - let break = Format.pp_print_custom_break ~fits: ("", 0, "") ~breaks: (",", 0, "") in - pf fmt "@[{@;<0 1>@[@[%a@]@]%t@]}:" pp_args args break - -let pp_cfg (ppf : Format.formatter) = - pp_nix_named_args ppf [ - ("system", Some "builtins.currentSystem"); - ("bootstrap-nixpkgs", Some "null"); - ("bootstrap-nixpkgs-lock-name", Some "null"); - ("bootstrap-pkgs", Some "null"); - ] - -(* TODO: consider *not* doing manually as this is ugly AF, but would probably - involve building a Nix AST to do properly, but even a Buffer.add_string or - Jingoo templates could improve this. *) -let pp_body ~version ~features (ppf : Format.formatter) () = - let feats = features in - pf ppf {|let lock = builtins.fromJSON (builtins.readFile ./lock.json); in@.|}; - pf ppf {|assert (lock.v == "%s");@.|} (Schema.Version.to_string version); - pf ppf {|let@.|}; - if Features.(has Flag.patches feats) then - begin - match Foreman.local_patches () with - | [] -> - pf ppf {| local-patches = {};@.|}; - | local_patches -> - pf ppf {| local-patches = {@.|}; - List.iter - (fun (patch_name, path) -> - pf ppf {| "%s" = %s;@.|} (Name.Patch.take patch_name) path - ) - local_patches; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| hash-token = {@.|}; - begin - let open Input.Hash in - for idx = - min_algorithm to max_algorithm do - match algorithm_of_enum idx with - | Some algo -> - pf - ppf - {| "%d" = "%s";@.|} - idx - (algorithm_to_hash_token algo) - | None -> () - done - end; - pf ppf {| };@.|}; - pf ppf {|@.|}; - pf ppf {| try-fetch = input-name: fetcher:@.|}; - pf ppf {| let@.|}; - pf ppf {| try-fetch' = failed-urls: url: urls:@.|}; - pf ppf {| let result = builtins.tryEval (fetcher url); in@.|}; - pf ppf {| if result.success then@.|}; - pf ppf {| result.value@.|}; - pf ppf {| else@.|}; - pf ppf {| let failed-urls' = [ url ] ++ failed-urls; in@.|}; - pf ppf {| if builtins.length urls <= 0 then@.|}; - pf ppf {| let fus = builtins.concatStringsSep " " failed-urls'; in@.|}; - pf ppf {| throw "Input 「${input-name}」fetchable @@ [ ${fus} ]"@.|}; - pf ppf {| else@.|}; - pf ppf {| try-fetch' failed-urls' (builtins.head urls) (builtins.tail urls);@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch' [ ];@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| builtin-fetch-url = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchurl ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|}; - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| builtin-fetch-tarball = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchTarball ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| builtin-fetch-git = {input-name, name, kind}:@.|}; - pf ppf {| let@.|}; - pf ppf {| ref =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| valu = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then # ref@.|}; - pf ppf {| valu@.|}; - pf ppf {| else if type == 1 then # branch@.|}; - pf ppf {| "refs/heads/${valu}"@.|}; - pf ppf {| else if type == 2 then # tag@.|}; - pf ppf {| "refs/tags/${valu}"@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported reference type “${builtins.toString type}”.";@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| let@.|}; - pf ppf {| args = {@.|}; - pf ppf {| inherit url ref;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| submodules = kind.sm;@.|}; - pf ppf {| lfs = kind.lf;@.|}; - pf ppf {| shallow = true;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {});@.|}; - pf ppf {| args' =@.|}; - pf ppf {| if builtins.compareVersions builtins.nixVersion "2.26" < 0 then@.|}; - pf ppf {| builtins.removeAttrs args [ "lfs" ]@.|}; - pf ppf {| else@.|}; - pf ppf {| args;@.|}; - pf ppf {| in@.|}; - pf ppf {| builtins.fetchGit args'@.|}; - pf ppf {| ) kind.rp kind.ms;@.|}; - pf ppf {|@.|} - end; - pf ppf {| builtin-to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| in@.|}; - pf ppf {| |}; - let builtin_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| builtin-fetch-url {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| builtin-fetch-tarball {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| builtin-fetch-git {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| }|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| fetch-darcs {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - pf ppf "@[%a@]@." (list ~sep: (any "@.\t\telse ") string) (Dynarray.to_list builtin_fetch_ifs); - Dynarray.clear builtin_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {|@.|}; - pf ppf {| nixpkgs' =@.|}; - pf ppf {| if builtins.isNull bootstrap-nixpkgs then@.|}; - pf ppf {| builtin-to-input "nixpkgs-for-nixtamal" (@.|}; - pf ppf {| if builtins.isString bootstrap-nixpkgs-lock-name then@.|}; - pf ppf {| lock.i.${bootstrap-nixpkgs-lock-name}@.|}; - pf ppf {| else@.|}; - pf ppf {| lock.i.nixpkgs-nixtamal or lock.i.nixpkgs@.|}; - pf ppf {| )@.|}; - pf ppf {| else@.|}; - pf ppf {| bootstrap-nixpkgs;@.|}; - pf ppf {|@.|}; - pf ppf {| pkgs =@.|}; - pf ppf {| if builtins.isAttrs bootstrap-pkgs then@.|}; - pf ppf {| bootstrap-pkgs@.|}; - pf ppf {| else@.|}; - pf ppf {| import nixpkgs' {inherit system;};@.|}; - pf ppf {|@.|}; - pf ppf {| inherit (pkgs) lib;@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; - pf ppf {| # base gnutar doesn’t support Zstandard@.|}; - pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| fetch-git = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchgit.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchgit ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| fetchSubmodules = kind.sm;@.|}; - pf ppf {| fetchLFS = kind.lf;@.|}; - pf ppf {| deepClone = false;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.darcs feats) then - begin - pf ppf {| fetch-darcs = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchdarcs.__functionArgs ? "mirrors";@.|}; - pf ppf {| reference =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| value = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then@.|}; - pf ppf {| let ctx_path = builtins.elemAt value 1; in@.|}; - pf ppf {| assert (lib.hasSuffix ".txt" ctx_path);@.|}; - pf ppf {| let@.|}; - pf ppf {| txt-files = lib.sourceFilesBySuffices ./. [ ".txt" ];@.|}; - pf ppf {| dir = lib.fileset.toSource {@.|}; - pf ppf {| root = ./.;@.|}; - pf ppf {| fileset = lib.fileset.fromSource txt-files;@.|}; - pf ppf {| };@.|}; - pf ppf {| in@.|}; - pf ppf {| {context = "${dir}/${ctx_path}";}@.|}; - pf ppf {| else if type == 1 then@.|}; - pf ppf {| {rev = value;}@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Invalid Darcs reference";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchdarcs doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchdarcs ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // reference // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.pijul feats) then - begin - pf ppf {| fetch-pijul = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchpijul.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchpijul doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchpijul ({@.|}; - pf ppf {| url = kind.rm;@.|}; - pf ppf {| state = kind.ls;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.fossil feats) then - begin - pf ppf {| fetch-fossil = {input-name, name, kind, hash}:@.|}; - pf ppf {| pkgs.fetchfossil ({@.|}; - pf ppf {| inherit name;@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lc;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.patches feats) then - begin - pf ppf {| fetch-patch = patch-name: {ur, ha}:@.|}; - pf ppf {| pkgs.fetchpatch2 {@.|}; - pf ppf {| url = ur;@.|}; - pf ppf {| hash = ha.vl;@.|}; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| raw-input =@.|}; - pf ppf {| |}; - let pkgs_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-url {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-url {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-zip {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-tarball {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-git {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-git {inherit input-name name kind;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-darcs {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.pijul feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 4 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-pijul {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.fossil feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 5 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-fossil {inherit input-name name kind hash;}|}; - ] - ); - pf - ppf - "@[%a@]@." - (list ~sep: (any "@. else ") string) - (Dynarray.to_list pkgs_fetch_ifs); - Dynarray.clear pkgs_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {| in@.|}; - if Features.(has Flag.patches feats) then - begin - pf ppf {| if builtins.length input.ps == 0 then@.|}; - pf ppf {| raw-input@.|}; - pf ppf {| else@.|}; - pf ppf {| pkgs.applyPatches {@.|}; - pf ppf {| src = raw-input;@.|}; - pf ppf {| name = "${if name != null then name else "src"}-patched";@.|}; - pf ppf {| patches = map (p:@.|}; - pf ppf {| if local-patches ? "${p}" then@.|}; - pf ppf {| local-patches."${p}"@.|}; - pf ppf {| else@.|}; - pf ppf {| fetch-patch p lock.p."${p}"@.|}; - pf ppf {| ) input.ps;@.|}; - pf ppf {| };@.|}; - end - else - begin - pf ppf {| raw-input;@.|}; - end; - pf ppf {|in@.|}; - pf ppf {|builtins.mapAttrs to-input lock.i@.|} - -let pp ~version ~features (ppf : Format.formatter) = - Logs.debug (fun m -> m "pp features: %a" Features.pp features); - set_utf_8 ppf true; - let custom_formatter_functions : Format.formatter_out_functions = - let sf = Format.pp_get_formatter_out_functions ppf () in - {sf with out_indent = fun n -> sf.out_string (String.make n '\t') 0 n} - in - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - Format.pp_set_margin Format.std_formatter 80; - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - pp_banner ppf; - pp_cfg ppf; - pf ppf "@.@."; - pp_body ~version ~features ppf () - -let write ?(version = Lazy.(force Schema.Version.latest)) () = - Logs.info (fun m -> m "Lock_loader.write: starting"); - let working_dir = Working_directory.get () in - let filepath = Eio.Path.(working_dir / filename) in : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; + pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; }} [ hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; ] : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; });@.|}; conflictor {{ hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; hunk ./lib/lock_loader.ml 284 + pf ppf {| # base gnutar doesn’t support Zstandard@.|}; + pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 15 - let maker = "toastal" - and maker_year_range = year_range 2025 - (* needs a more legally-defined term vs. a fun one :( *) - and hackmates = "Nixtamal contributors" - and hackmates_year_range = year_range 2026 - and margin = Format.pp_get_margin ppf () - in - let hr = - (*──────────────────────────────*) - let uchar = Uchar.of_int 0x2500 - and buf = Buffer.create (margin * 3) - in - for _ = 1 to margin do - Buffer.add_utf_8_uchar buf uchar - done; - Buffer.contents buf - in - pf ppf "/*@."; - pf ppf "SPDX-FileCopyrightText: %s %s@." maker_year_range maker; - pf ppf "SPDX-FileCopyrightText: %s %s@." hackmates_year_range hackmates; - pf ppf "SPDX-License-Identifier: ISC@."; - pf ppf "@."; - pf ppf "@[Permission@ to@ use,@ copy,@ modify,@ and/or@ distribute@ "; - pf ppf "this@ software@ for@ any@ purpose@ with@ or@ without@ fee@ is@ "; - pf ppf "hereby@ granted,@ provided@ that@ the@ above@ copyright@ notice@ &@ "; - pf ppf "this@ permission@ notice@ appear@ in@ all@ copies.@]@."; - pf ppf "@."; - pf ppf "@[THE@ SOFTWARE@ IS@ PROVIDED@ “AS@ IS”@ &@ ISC@ DISCLAIMS@ "; - pf ppf "ALL@ WARRANTIES@ WITH@ REGARD@ TO@ THIS@ SOFTWARE@ INCLUDING@ ALL@ "; - pf ppf "IMPLIED@ WARRANTIES@ OF@ MERCHANTABILITY@ &@ FITNESS.@ IN@ NO@ "; - pf ppf "EVENT@ SHALL@ ISC@ BE@ LIABLE@ FOR@ ANY@ SPECIAL,@ DIRECT,@ "; - pf ppf "INDIRECT,@ OR@ CONSEQUENTIAL@ DAMAGES@ OR@ ANY@ DAMAGES@ WHATSOEVER@ "; - pf ppf "RESULTING@ FROM@ LOSS@ OF@ USE,@ DATA@ OR@ PROFITS,@ WHETHER@ IN@ "; - pf ppf "AN@ ACTION@ OF@ CONTRACT,@ NEGLIGENCE@ OR@ OTHER@ TORTIOUS@ ACTION,@ "; - pf ppf "ARISING@ OUT@ OF@ OR@ IN@ CONNECTION@ WITH@ THE@ USE@ OR@ "; - pf ppf "PERFORMANCE@ OF@ THIS@ SOFTWARE.@]@."; - pf ppf "@."; - pf ppf "%s@." hr; - pf ppf "┏┓╻+╻ ╱┏┳┓┏┓┏┳┓┏┓╻@."; - pf ppf "┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃ This file was generated by Nixtamal.@."; - pf ppf "╹┗┛╹╱ ╹ ╹ ╹╹╹ ╹╹╹┗┛ Do not edit as it will be overwritten.@."; - pf ppf "%s@." hr; - pf ppf "*/@." - -let pp_nix_named_arg (ppf : Format.formatter) ((name, default): (string * string option)) = - pf ppf "%s%a" name (option (fun ppf v -> pf ppf " ? %s" v)) default - -let pp_nix_named_args fmt args = - let pp_args = list ~sep: (any ",@;") pp_nix_named_arg in - let break = Format.pp_print_custom_break ~fits: ("", 0, "") ~breaks: (",", 0, "") in - pf fmt "@[{@;<0 1>@[@[%a@]@]%t@]}:" pp_args args break - -let pp_cfg (ppf : Format.formatter) = - pp_nix_named_args ppf [ - ("system", Some "builtins.currentSystem"); - ("bootstrap-nixpkgs", Some "null"); - ("bootstrap-nixpkgs-lock-name", Some "null"); - ("bootstrap-pkgs", Some "null"); - ] - -(* TODO: consider *not* doing manually as this is ugly AF, but would probably - involve building a Nix AST to do properly, but even a Buffer.add_string or - Jingoo templates could improve this. *) -let pp_body ~version ~features (ppf : Format.formatter) () = - let feats = features in - pf ppf {|let lock = builtins.fromJSON (builtins.readFile ./lock.json); in@.|}; - pf ppf {|assert (lock.v == "%s");@.|} (Schema.Version.to_string version); - pf ppf {|let@.|}; - if Features.(has Flag.patches feats) then - begin - match Foreman.local_patches () with - | [] -> - pf ppf {| local-patches = {};@.|}; - | local_patches -> - pf ppf {| local-patches = {@.|}; - List.iter - (fun (patch_name, path) -> - pf ppf {| "%s" = %s;@.|} (Name.Patch.take patch_name) path - ) - local_patches; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| hash-token = {@.|}; - begin - let open Input.Hash in - for idx = - min_algorithm to max_algorithm do - match algorithm_of_enum idx with - | Some algo -> - pf - ppf - {| "%d" = "%s";@.|} - idx - (algorithm_to_hash_token algo) - | None -> () - done - end; - pf ppf {| };@.|}; - pf ppf {|@.|}; - pf ppf {| try-fetch = input-name: fetcher:@.|}; - pf ppf {| let@.|}; - pf ppf {| try-fetch' = failed-urls: url: urls:@.|}; - pf ppf {| let result = builtins.tryEval (fetcher url); in@.|}; - pf ppf {| if result.success then@.|}; - pf ppf {| result.value@.|}; - pf ppf {| else@.|}; - pf ppf {| let failed-urls' = [ url ] ++ failed-urls; in@.|}; - pf ppf {| if builtins.length urls <= 0 then@.|}; - pf ppf {| let fus = builtins.concatStringsSep " " failed-urls'; in@.|}; - pf ppf {| throw "Input 「${input-name}」fetchable @@ [ ${fus} ]"@.|}; - pf ppf {| else@.|}; - pf ppf {| try-fetch' failed-urls' (builtins.head urls) (builtins.tail urls);@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch' [ ];@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| builtin-fetch-url = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchurl ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|}; - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| builtin-fetch-tarball = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchTarball ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| builtin-fetch-git = {input-name, name, kind}:@.|}; - pf ppf {| let@.|}; - pf ppf {| ref =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| valu = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then # ref@.|}; - pf ppf {| valu@.|}; - pf ppf {| else if type == 1 then # branch@.|}; - pf ppf {| "refs/heads/${valu}"@.|}; - pf ppf {| else if type == 2 then # tag@.|}; - pf ppf {| "refs/tags/${valu}"@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported reference type “${builtins.toString type}”.";@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| let@.|}; - pf ppf {| args = {@.|}; - pf ppf {| inherit url ref;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| submodules = kind.sm;@.|}; - pf ppf {| lfs = kind.lf;@.|}; - pf ppf {| shallow = true;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {});@.|}; - pf ppf {| args' =@.|}; - pf ppf {| if builtins.compareVersions builtins.nixVersion "2.26" < 0 then@.|}; - pf ppf {| builtins.removeAttrs args [ "lfs" ]@.|}; - pf ppf {| else@.|}; - pf ppf {| args;@.|}; - pf ppf {| in@.|}; - pf ppf {| builtins.fetchGit args'@.|}; - pf ppf {| ) kind.rp kind.ms;@.|}; - pf ppf {|@.|} - end; - pf ppf {| builtin-to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| in@.|}; - pf ppf {| |}; - let builtin_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| builtin-fetch-url {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| builtin-fetch-tarball {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| builtin-fetch-git {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| }|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| fetch-darcs {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - pf ppf "@[%a@]@." (list ~sep: (any "@.\t\telse ") string) (Dynarray.to_list builtin_fetch_ifs); - Dynarray.clear builtin_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {|@.|}; - pf ppf {| nixpkgs' =@.|}; - pf ppf {| if builtins.isNull bootstrap-nixpkgs then@.|}; - pf ppf {| builtin-to-input "nixpkgs-for-nixtamal" (@.|}; - pf ppf {| if builtins.isString bootstrap-nixpkgs-lock-name then@.|}; - pf ppf {| lock.i.${bootstrap-nixpkgs-lock-name}@.|}; - pf ppf {| else@.|}; - pf ppf {| lock.i.nixpkgs-nixtamal or lock.i.nixpkgs@.|}; - pf ppf {| )@.|}; - pf ppf {| else@.|}; - pf ppf {| bootstrap-nixpkgs;@.|}; - pf ppf {|@.|}; - pf ppf {| pkgs =@.|}; - pf ppf {| if builtins.isAttrs bootstrap-pkgs then@.|}; - pf ppf {| bootstrap-pkgs@.|}; - pf ppf {| else@.|}; - pf ppf {| import nixpkgs' {inherit system;};@.|}; - pf ppf {|@.|}; - pf ppf {| inherit (pkgs) lib;@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; - pf ppf {| # base gnutar doesn’t support Zstandard@.|}; - pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| fetch-git = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchgit.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchgit ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| fetchSubmodules = kind.sm;@.|}; - pf ppf {| fetchLFS = kind.lf;@.|}; - pf ppf {| deepClone = false;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.darcs feats) then - begin - pf ppf {| fetch-darcs = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchdarcs.__functionArgs ? "mirrors";@.|}; - pf ppf {| reference =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| value = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then@.|}; - pf ppf {| let ctx_path = builtins.elemAt value 1; in@.|}; - pf ppf {| assert (lib.hasSuffix ".txt" ctx_path);@.|}; - pf ppf {| let@.|}; - pf ppf {| txt-files = lib.sourceFilesBySuffices ./. [ ".txt" ];@.|}; - pf ppf {| dir = lib.fileset.toSource {@.|}; - pf ppf {| root = ./.;@.|}; - pf ppf {| fileset = lib.fileset.fromSource txt-files;@.|}; - pf ppf {| };@.|}; - pf ppf {| in@.|}; - pf ppf {| {context = "${dir}/${ctx_path}";}@.|}; - pf ppf {| else if type == 1 then@.|}; - pf ppf {| {rev = value;}@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Invalid Darcs reference";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchdarcs doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchdarcs ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // reference // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.pijul feats) then - begin - pf ppf {| fetch-pijul = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchpijul.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchpijul doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchpijul ({@.|}; - pf ppf {| url = kind.rm;@.|}; - pf ppf {| state = kind.ls;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.fossil feats) then - begin - pf ppf {| fetch-fossil = {input-name, name, kind, hash}:@.|}; - pf ppf {| pkgs.fetchfossil ({@.|}; - pf ppf {| inherit name;@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lc;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.patches feats) then - begin - pf ppf {| fetch-patch = patch-name: {ur, ha}:@.|}; - pf ppf {| pkgs.fetchpatch2 {@.|}; - pf ppf {| url = ur;@.|}; - pf ppf {| hash = ha.vl;@.|}; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| raw-input =@.|}; - pf ppf {| |}; - let pkgs_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-url {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-url {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-zip {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-tarball {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-git {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-git {inherit input-name name kind;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-darcs {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.pijul feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 4 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-pijul {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.fossil feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 5 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-fossil {inherit input-name name kind hash;}|}; - ] - ); - pf - ppf - "@[%a@]@." - (list ~sep: (any "@. else ") string) - (Dynarray.to_list pkgs_fetch_ifs); - Dynarray.clear pkgs_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {| in@.|}; - if Features.(has Flag.patches feats) then - begin - pf ppf {| if builtins.length input.ps == 0 then@.|}; - pf ppf {| raw-input@.|}; - pf ppf {| else@.|}; - pf ppf {| pkgs.applyPatches {@.|}; - pf ppf {| src = raw-input;@.|}; - pf ppf {| name = "${if name != null then name else "src"}-patched";@.|}; - pf ppf {| patches = map (p:@.|}; - pf ppf {| if local-patches ? "${p}" then@.|}; - pf ppf {| local-patches."${p}"@.|}; - pf ppf {| else@.|}; - pf ppf {| fetch-patch p lock.p."${p}"@.|}; - pf ppf {| ) input.ps;@.|}; - pf ppf {| };@.|}; - end - else - begin - pf ppf {| raw-input;@.|}; - end; - pf ppf {|in@.|}; - pf ppf {|builtins.mapAttrs to-input lock.i@.|} - -let pp ~version ~features (ppf : Format.formatter) = - Logs.debug (fun m -> m "pp features: %a" Features.pp features); - set_utf_8 ppf true; - let custom_formatter_functions : Format.formatter_out_functions = - let sf = Format.pp_get_formatter_out_functions ppf () in - {sf with out_indent = fun n -> sf.out_string (String.make n '\t') 0 n} - in - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - Format.pp_set_margin Format.std_formatter 80; - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - pp_banner ppf; - pp_cfg ppf; - pf ppf "@.@."; - pp_body ~version ~features ppf () - -let write ?(version = Lazy.(force Schema.Version.latest)) () = - Logs.info (fun m -> m "Lock_loader.write: starting"); - let working_dir = Working_directory.get () in - let filepath = Eio.Path.(working_dir / filename) in : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; });@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; + pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; }} [ hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; hunk ./lib/lock_loader.ml 284 + pf ppf {| # base gnutar doesn’t support Zstandard@.|}; + pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; ] : hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; + pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip ({@.|}; conflictor {{ hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 289 - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; hunk ./lib/lock_loader.ml 284 + pf ppf {| # base gnutar doesn’t support Zstandard@.|}; + pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 15 - let maker = "toastal" - and maker_year_range = year_range 2025 - (* needs a more legally-defined term vs. a fun one :( *) - and hackmates = "Nixtamal contributors" - and hackmates_year_range = year_range 2026 - and margin = Format.pp_get_margin ppf () - in - let hr = - (*──────────────────────────────*) - let uchar = Uchar.of_int 0x2500 - and buf = Buffer.create (margin * 3) - in - for _ = 1 to margin do - Buffer.add_utf_8_uchar buf uchar - done; - Buffer.contents buf - in - pf ppf "/*@."; - pf ppf "SPDX-FileCopyrightText: %s %s@." maker_year_range maker; - pf ppf "SPDX-FileCopyrightText: %s %s@." hackmates_year_range hackmates; - pf ppf "SPDX-License-Identifier: ISC@."; - pf ppf "@."; - pf ppf "@[Permission@ to@ use,@ copy,@ modify,@ and/or@ distribute@ "; - pf ppf "this@ software@ for@ any@ purpose@ with@ or@ without@ fee@ is@ "; - pf ppf "hereby@ granted,@ provided@ that@ the@ above@ copyright@ notice@ &@ "; - pf ppf "this@ permission@ notice@ appear@ in@ all@ copies.@]@."; - pf ppf "@."; - pf ppf "@[THE@ SOFTWARE@ IS@ PROVIDED@ “AS@ IS”@ &@ ISC@ DISCLAIMS@ "; - pf ppf "ALL@ WARRANTIES@ WITH@ REGARD@ TO@ THIS@ SOFTWARE@ INCLUDING@ ALL@ "; - pf ppf "IMPLIED@ WARRANTIES@ OF@ MERCHANTABILITY@ &@ FITNESS.@ IN@ NO@ "; - pf ppf "EVENT@ SHALL@ ISC@ BE@ LIABLE@ FOR@ ANY@ SPECIAL,@ DIRECT,@ "; - pf ppf "INDIRECT,@ OR@ CONSEQUENTIAL@ DAMAGES@ OR@ ANY@ DAMAGES@ WHATSOEVER@ "; - pf ppf "RESULTING@ FROM@ LOSS@ OF@ USE,@ DATA@ OR@ PROFITS,@ WHETHER@ IN@ "; - pf ppf "AN@ ACTION@ OF@ CONTRACT,@ NEGLIGENCE@ OR@ OTHER@ TORTIOUS@ ACTION,@ "; - pf ppf "ARISING@ OUT@ OF@ OR@ IN@ CONNECTION@ WITH@ THE@ USE@ OR@ "; - pf ppf "PERFORMANCE@ OF@ THIS@ SOFTWARE.@]@."; - pf ppf "@."; - pf ppf "%s@." hr; - pf ppf "┏┓╻+╻ ╱┏┳┓┏┓┏┳┓┏┓╻@."; - pf ppf "┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃ This file was generated by Nixtamal.@."; - pf ppf "╹┗┛╹╱ ╹ ╹ ╹╹╹ ╹╹╹┗┛ Do not edit as it will be overwritten.@."; - pf ppf "%s@." hr; - pf ppf "*/@." - -let pp_nix_named_arg (ppf : Format.formatter) ((name, default): (string * string option)) = - pf ppf "%s%a" name (option (fun ppf v -> pf ppf " ? %s" v)) default - -let pp_nix_named_args fmt args = - let pp_args = list ~sep: (any ",@;") pp_nix_named_arg in - let break = Format.pp_print_custom_break ~fits: ("", 0, "") ~breaks: (",", 0, "") in - pf fmt "@[{@;<0 1>@[@[%a@]@]%t@]}:" pp_args args break - -let pp_cfg (ppf : Format.formatter) = - pp_nix_named_args ppf [ - ("system", Some "builtins.currentSystem"); - ("bootstrap-nixpkgs", Some "null"); - ("bootstrap-nixpkgs-lock-name", Some "null"); - ("bootstrap-pkgs", Some "null"); - ] - -(* TODO: consider *not* doing manually as this is ugly AF, but would probably - involve building a Nix AST to do properly, but even a Buffer.add_string or - Jingoo templates could improve this. *) -let pp_body ~version ~features (ppf : Format.formatter) () = - let feats = features in - pf ppf {|let lock = builtins.fromJSON (builtins.readFile ./lock.json); in@.|}; - pf ppf {|assert (lock.v == "%s");@.|} (Schema.Version.to_string version); - pf ppf {|let@.|}; - if Features.(has Flag.patches feats) then - begin - match Foreman.local_patches () with - | [] -> - pf ppf {| local-patches = {};@.|}; - | local_patches -> - pf ppf {| local-patches = {@.|}; - List.iter - (fun (patch_name, path) -> - pf ppf {| "%s" = %s;@.|} (Name.Patch.take patch_name) path - ) - local_patches; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| hash-token = {@.|}; - begin - let open Input.Hash in - for idx = - min_algorithm to max_algorithm do - match algorithm_of_enum idx with - | Some algo -> - pf - ppf - {| "%d" = "%s";@.|} - idx - (algorithm_to_hash_token algo) - | None -> () - done - end; - pf ppf {| };@.|}; - pf ppf {|@.|}; - pf ppf {| try-fetch = input-name: fetcher:@.|}; - pf ppf {| let@.|}; - pf ppf {| try-fetch' = failed-urls: url: urls:@.|}; - pf ppf {| let result = builtins.tryEval (fetcher url); in@.|}; - pf ppf {| if result.success then@.|}; - pf ppf {| result.value@.|}; - pf ppf {| else@.|}; - pf ppf {| let failed-urls' = [ url ] ++ failed-urls; in@.|}; - pf ppf {| if builtins.length urls <= 0 then@.|}; - pf ppf {| let fus = builtins.concatStringsSep " " failed-urls'; in@.|}; - pf ppf {| throw "Input 「${input-name}」fetchable @@ [ ${fus} ]"@.|}; - pf ppf {| else@.|}; - pf ppf {| try-fetch' failed-urls' (builtins.head urls) (builtins.tail urls);@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch' [ ];@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| builtin-fetch-url = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchurl ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|}; - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| builtin-fetch-tarball = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchTarball ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| builtin-fetch-git = {input-name, name, kind}:@.|}; - pf ppf {| let@.|}; - pf ppf {| ref =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| valu = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then # ref@.|}; - pf ppf {| valu@.|}; - pf ppf {| else if type == 1 then # branch@.|}; - pf ppf {| "refs/heads/${valu}"@.|}; - pf ppf {| else if type == 2 then # tag@.|}; - pf ppf {| "refs/tags/${valu}"@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported reference type “${builtins.toString type}”.";@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| let@.|}; - pf ppf {| args = {@.|}; - pf ppf {| inherit url ref;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| submodules = kind.sm;@.|}; - pf ppf {| lfs = kind.lf;@.|}; - pf ppf {| shallow = true;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {});@.|}; - pf ppf {| args' =@.|}; - pf ppf {| if builtins.compareVersions builtins.nixVersion "2.26" < 0 then@.|}; - pf ppf {| builtins.removeAttrs args [ "lfs" ]@.|}; - pf ppf {| else@.|}; - pf ppf {| args;@.|}; - pf ppf {| in@.|}; - pf ppf {| builtins.fetchGit args'@.|}; - pf ppf {| ) kind.rp kind.ms;@.|}; - pf ppf {|@.|} - end; - pf ppf {| builtin-to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| in@.|}; - pf ppf {| |}; - let builtin_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| builtin-fetch-url {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| builtin-fetch-tarball {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| builtin-fetch-git {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| }|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| fetch-darcs {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - pf ppf "@[%a@]@." (list ~sep: (any "@.\t\telse ") string) (Dynarray.to_list builtin_fetch_ifs); - Dynarray.clear builtin_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {|@.|}; - pf ppf {| nixpkgs' =@.|}; - pf ppf {| if builtins.isNull bootstrap-nixpkgs then@.|}; - pf ppf {| builtin-to-input "nixpkgs-for-nixtamal" (@.|}; - pf ppf {| if builtins.isString bootstrap-nixpkgs-lock-name then@.|}; - pf ppf {| lock.i.${bootstrap-nixpkgs-lock-name}@.|}; - pf ppf {| else@.|}; - pf ppf {| lock.i.nixpkgs-nixtamal or lock.i.nixpkgs@.|}; - pf ppf {| )@.|}; - pf ppf {| else@.|}; - pf ppf {| bootstrap-nixpkgs;@.|}; - pf ppf {|@.|}; - pf ppf {| pkgs =@.|}; - pf ppf {| if builtins.isAttrs bootstrap-pkgs then@.|}; - pf ppf {| bootstrap-pkgs@.|}; - pf ppf {| else@.|}; - pf ppf {| import nixpkgs' {inherit system;};@.|}; - pf ppf {|@.|}; - pf ppf {| inherit (pkgs) lib;@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; - pf ppf {| # base gnutar doesn’t support Zstandard@.|}; - pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| fetch-git = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchgit.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchgit ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| fetchSubmodules = kind.sm;@.|}; - pf ppf {| fetchLFS = kind.lf;@.|}; - pf ppf {| deepClone = false;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.darcs feats) then - begin - pf ppf {| fetch-darcs = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchdarcs.__functionArgs ? "mirrors";@.|}; - pf ppf {| reference =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| value = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then@.|}; - pf ppf {| let ctx_path = builtins.elemAt value 1; in@.|}; - pf ppf {| assert (lib.hasSuffix ".txt" ctx_path);@.|}; - pf ppf {| let@.|}; - pf ppf {| txt-files = lib.sourceFilesBySuffices ./. [ ".txt" ];@.|}; - pf ppf {| dir = lib.fileset.toSource {@.|}; - pf ppf {| root = ./.;@.|}; - pf ppf {| fileset = lib.fileset.fromSource txt-files;@.|}; - pf ppf {| };@.|}; - pf ppf {| in@.|}; - pf ppf {| {context = "${dir}/${ctx_path}";}@.|}; - pf ppf {| else if type == 1 then@.|}; - pf ppf {| {rev = value;}@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Invalid Darcs reference";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchdarcs doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchdarcs ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // reference // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.pijul feats) then - begin - pf ppf {| fetch-pijul = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchpijul.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchpijul doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchpijul ({@.|}; - pf ppf {| url = kind.rm;@.|}; - pf ppf {| state = kind.ls;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.fossil feats) then - begin - pf ppf {| fetch-fossil = {input-name, name, kind, hash}:@.|}; - pf ppf {| pkgs.fetchfossil ({@.|}; - pf ppf {| inherit name;@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lc;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.patches feats) then - begin - pf ppf {| fetch-patch = patch-name: {ur, ha}:@.|}; - pf ppf {| pkgs.fetchpatch2 {@.|}; - pf ppf {| url = ur;@.|}; - pf ppf {| hash = ha.vl;@.|}; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| raw-input =@.|}; - pf ppf {| |}; - let pkgs_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-url {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-url {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-zip {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-tarball {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-git {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-git {inherit input-name name kind;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-darcs {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.pijul feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 4 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-pijul {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.fossil feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 5 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-fossil {inherit input-name name kind hash;}|}; - ] - ); - pf - ppf - "@[%a@]@." - (list ~sep: (any "@. else ") string) - (Dynarray.to_list pkgs_fetch_ifs); - Dynarray.clear pkgs_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {| in@.|}; - if Features.(has Flag.patches feats) then - begin - pf ppf {| if builtins.length input.ps == 0 then@.|}; - pf ppf {| raw-input@.|}; - pf ppf {| else@.|}; - pf ppf {| pkgs.applyPatches {@.|}; - pf ppf {| src = raw-input;@.|}; - pf ppf {| name = "${if name != null then name else "src"}-patched";@.|}; - pf ppf {| patches = map (p:@.|}; - pf ppf {| if local-patches ? "${p}" then@.|}; - pf ppf {| local-patches."${p}"@.|}; - pf ppf {| else@.|}; - pf ppf {| fetch-patch p lock.p."${p}"@.|}; - pf ppf {| ) input.ps;@.|}; - pf ppf {| };@.|}; - end - else - begin - pf ppf {| raw-input;@.|}; - end; - pf ppf {|in@.|}; - pf ppf {|builtins.mapAttrs to-input lock.i@.|} - -let pp ~version ~features (ppf : Format.formatter) = - Logs.debug (fun m -> m "pp features: %a" Features.pp features); - set_utf_8 ppf true; - let custom_formatter_functions : Format.formatter_out_functions = - let sf = Format.pp_get_formatter_out_functions ppf () in - {sf with out_indent = fun n -> sf.out_string (String.make n '\t') 0 n} - in - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - Format.pp_set_margin Format.std_formatter 80; - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - pp_banner ppf; - pp_cfg ppf; - pf ppf "@.@."; - pp_body ~version ~features ppf () - -let write ?(version = Lazy.(force Schema.Version.latest)) () = - Logs.info (fun m -> m "Lock_loader.write: starting"); - let working_dir = Working_directory.get () in - let filepath = Eio.Path.(working_dir / filename) in : hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; + pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip ({@.|}; : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; });@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; + pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; : hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; : hunk ./lib/lock_loader.ml 284 + pf ppf {| # base gnutar doesn’t support Zstandard@.|}; + pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; }} [ hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 289 - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; ] : hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; });@.|}; conflictor {{ hunk ./lib/lock_loader.ml 298 - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${name}」"@.|}; - pf ppf {| pkgs.fetchgit {@.|}; + pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; + pf ppf {| pkgs.fetchgit ({@.|}; hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 289 - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; hunk ./lib/lock_loader.ml 284 + pf ppf {| # base gnutar doesn’t support Zstandard@.|}; + pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 15 - let maker = "toastal" - and maker_year_range = year_range 2025 - (* needs a more legally-defined term vs. a fun one :( *) - and hackmates = "Nixtamal contributors" - and hackmates_year_range = year_range 2026 - and margin = Format.pp_get_margin ppf () - in - let hr = - (*──────────────────────────────*) - let uchar = Uchar.of_int 0x2500 - and buf = Buffer.create (margin * 3) - in - for _ = 1 to margin do - Buffer.add_utf_8_uchar buf uchar - done; - Buffer.contents buf - in - pf ppf "/*@."; - pf ppf "SPDX-FileCopyrightText: %s %s@." maker_year_range maker; - pf ppf "SPDX-FileCopyrightText: %s %s@." hackmates_year_range hackmates; - pf ppf "SPDX-License-Identifier: ISC@."; - pf ppf "@."; - pf ppf "@[Permission@ to@ use,@ copy,@ modify,@ and/or@ distribute@ "; - pf ppf "this@ software@ for@ any@ purpose@ with@ or@ without@ fee@ is@ "; - pf ppf "hereby@ granted,@ provided@ that@ the@ above@ copyright@ notice@ &@ "; - pf ppf "this@ permission@ notice@ appear@ in@ all@ copies.@]@."; - pf ppf "@."; - pf ppf "@[THE@ SOFTWARE@ IS@ PROVIDED@ “AS@ IS”@ &@ ISC@ DISCLAIMS@ "; - pf ppf "ALL@ WARRANTIES@ WITH@ REGARD@ TO@ THIS@ SOFTWARE@ INCLUDING@ ALL@ "; - pf ppf "IMPLIED@ WARRANTIES@ OF@ MERCHANTABILITY@ &@ FITNESS.@ IN@ NO@ "; - pf ppf "EVENT@ SHALL@ ISC@ BE@ LIABLE@ FOR@ ANY@ SPECIAL,@ DIRECT,@ "; - pf ppf "INDIRECT,@ OR@ CONSEQUENTIAL@ DAMAGES@ OR@ ANY@ DAMAGES@ WHATSOEVER@ "; - pf ppf "RESULTING@ FROM@ LOSS@ OF@ USE,@ DATA@ OR@ PROFITS,@ WHETHER@ IN@ "; - pf ppf "AN@ ACTION@ OF@ CONTRACT,@ NEGLIGENCE@ OR@ OTHER@ TORTIOUS@ ACTION,@ "; - pf ppf "ARISING@ OUT@ OF@ OR@ IN@ CONNECTION@ WITH@ THE@ USE@ OR@ "; - pf ppf "PERFORMANCE@ OF@ THIS@ SOFTWARE.@]@."; - pf ppf "@."; - pf ppf "%s@." hr; - pf ppf "┏┓╻+╻ ╱┏┳┓┏┓┏┳┓┏┓╻@."; - pf ppf "┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃ This file was generated by Nixtamal.@."; - pf ppf "╹┗┛╹╱ ╹ ╹ ╹╹╹ ╹╹╹┗┛ Do not edit as it will be overwritten.@."; - pf ppf "%s@." hr; - pf ppf "*/@." - -let pp_nix_named_arg (ppf : Format.formatter) ((name, default): (string * string option)) = - pf ppf "%s%a" name (option (fun ppf v -> pf ppf " ? %s" v)) default - -let pp_nix_named_args fmt args = - let pp_args = list ~sep: (any ",@;") pp_nix_named_arg in - let break = Format.pp_print_custom_break ~fits: ("", 0, "") ~breaks: (",", 0, "") in - pf fmt "@[{@;<0 1>@[@[%a@]@]%t@]}:" pp_args args break - -let pp_cfg (ppf : Format.formatter) = - pp_nix_named_args ppf [ - ("system", Some "builtins.currentSystem"); - ("bootstrap-nixpkgs", Some "null"); - ("bootstrap-nixpkgs-lock-name", Some "null"); - ("bootstrap-pkgs", Some "null"); - ] - -(* TODO: consider *not* doing manually as this is ugly AF, but would probably - involve building a Nix AST to do properly, but even a Buffer.add_string or - Jingoo templates could improve this. *) -let pp_body ~version ~features (ppf : Format.formatter) () = - let feats = features in - pf ppf {|let lock = builtins.fromJSON (builtins.readFile ./lock.json); in@.|}; - pf ppf {|assert (lock.v == "%s");@.|} (Schema.Version.to_string version); - pf ppf {|let@.|}; - if Features.(has Flag.patches feats) then - begin - match Foreman.local_patches () with - | [] -> - pf ppf {| local-patches = {};@.|}; - | local_patches -> - pf ppf {| local-patches = {@.|}; - List.iter - (fun (patch_name, path) -> - pf ppf {| "%s" = %s;@.|} (Name.Patch.take patch_name) path - ) - local_patches; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| hash-token = {@.|}; - begin - let open Input.Hash in - for idx = - min_algorithm to max_algorithm do - match algorithm_of_enum idx with - | Some algo -> - pf - ppf - {| "%d" = "%s";@.|} - idx - (algorithm_to_hash_token algo) - | None -> () - done - end; - pf ppf {| };@.|}; - pf ppf {|@.|}; - pf ppf {| try-fetch = input-name: fetcher:@.|}; - pf ppf {| let@.|}; - pf ppf {| try-fetch' = failed-urls: url: urls:@.|}; - pf ppf {| let result = builtins.tryEval (fetcher url); in@.|}; - pf ppf {| if result.success then@.|}; - pf ppf {| result.value@.|}; - pf ppf {| else@.|}; - pf ppf {| let failed-urls' = [ url ] ++ failed-urls; in@.|}; - pf ppf {| if builtins.length urls <= 0 then@.|}; - pf ppf {| let fus = builtins.concatStringsSep " " failed-urls'; in@.|}; - pf ppf {| throw "Input 「${input-name}」fetchable @@ [ ${fus} ]"@.|}; - pf ppf {| else@.|}; - pf ppf {| try-fetch' failed-urls' (builtins.head urls) (builtins.tail urls);@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch' [ ];@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| builtin-fetch-url = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchurl ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|}; - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| builtin-fetch-tarball = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchTarball ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| builtin-fetch-git = {input-name, name, kind}:@.|}; - pf ppf {| let@.|}; - pf ppf {| ref =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| valu = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then # ref@.|}; - pf ppf {| valu@.|}; - pf ppf {| else if type == 1 then # branch@.|}; - pf ppf {| "refs/heads/${valu}"@.|}; - pf ppf {| else if type == 2 then # tag@.|}; - pf ppf {| "refs/tags/${valu}"@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported reference type “${builtins.toString type}”.";@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| let@.|}; - pf ppf {| args = {@.|}; - pf ppf {| inherit url ref;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| submodules = kind.sm;@.|}; - pf ppf {| lfs = kind.lf;@.|}; - pf ppf {| shallow = true;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {});@.|}; - pf ppf {| args' =@.|}; - pf ppf {| if builtins.compareVersions builtins.nixVersion "2.26" < 0 then@.|}; - pf ppf {| builtins.removeAttrs args [ "lfs" ]@.|}; - pf ppf {| else@.|}; - pf ppf {| args;@.|}; - pf ppf {| in@.|}; - pf ppf {| builtins.fetchGit args'@.|}; - pf ppf {| ) kind.rp kind.ms;@.|}; - pf ppf {|@.|} - end; - pf ppf {| builtin-to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| in@.|}; - pf ppf {| |}; - let builtin_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| builtin-fetch-url {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| builtin-fetch-tarball {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| builtin-fetch-git {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| }|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| fetch-darcs {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - pf ppf "@[%a@]@." (list ~sep: (any "@.\t\telse ") string) (Dynarray.to_list builtin_fetch_ifs); - Dynarray.clear builtin_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {|@.|}; - pf ppf {| nixpkgs' =@.|}; - pf ppf {| if builtins.isNull bootstrap-nixpkgs then@.|}; - pf ppf {| builtin-to-input "nixpkgs-for-nixtamal" (@.|}; - pf ppf {| if builtins.isString bootstrap-nixpkgs-lock-name then@.|}; - pf ppf {| lock.i.${bootstrap-nixpkgs-lock-name}@.|}; - pf ppf {| else@.|}; - pf ppf {| lock.i.nixpkgs-nixtamal or lock.i.nixpkgs@.|}; - pf ppf {| )@.|}; - pf ppf {| else@.|}; - pf ppf {| bootstrap-nixpkgs;@.|}; - pf ppf {|@.|}; - pf ppf {| pkgs =@.|}; - pf ppf {| if builtins.isAttrs bootstrap-pkgs then@.|}; - pf ppf {| bootstrap-pkgs@.|}; - pf ppf {| else@.|}; - pf ppf {| import nixpkgs' {inherit system;};@.|}; - pf ppf {|@.|}; - pf ppf {| inherit (pkgs) lib;@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; - pf ppf {| # base gnutar doesn’t support Zstandard@.|}; - pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| fetch-git = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchgit.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchgit ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| fetchSubmodules = kind.sm;@.|}; - pf ppf {| fetchLFS = kind.lf;@.|}; - pf ppf {| deepClone = false;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.darcs feats) then - begin - pf ppf {| fetch-darcs = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchdarcs.__functionArgs ? "mirrors";@.|}; - pf ppf {| reference =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| value = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then@.|}; - pf ppf {| let ctx_path = builtins.elemAt value 1; in@.|}; - pf ppf {| assert (lib.hasSuffix ".txt" ctx_path);@.|}; - pf ppf {| let@.|}; - pf ppf {| txt-files = lib.sourceFilesBySuffices ./. [ ".txt" ];@.|}; - pf ppf {| dir = lib.fileset.toSource {@.|}; - pf ppf {| root = ./.;@.|}; - pf ppf {| fileset = lib.fileset.fromSource txt-files;@.|}; - pf ppf {| };@.|}; - pf ppf {| in@.|}; - pf ppf {| {context = "${dir}/${ctx_path}";}@.|}; - pf ppf {| else if type == 1 then@.|}; - pf ppf {| {rev = value;}@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Invalid Darcs reference";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchdarcs doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchdarcs ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // reference // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.pijul feats) then - begin - pf ppf {| fetch-pijul = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchpijul.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchpijul doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchpijul ({@.|}; - pf ppf {| url = kind.rm;@.|}; - pf ppf {| state = kind.ls;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.fossil feats) then - begin - pf ppf {| fetch-fossil = {input-name, name, kind, hash}:@.|}; - pf ppf {| pkgs.fetchfossil ({@.|}; - pf ppf {| inherit name;@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lc;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.patches feats) then - begin - pf ppf {| fetch-patch = patch-name: {ur, ha}:@.|}; - pf ppf {| pkgs.fetchpatch2 {@.|}; - pf ppf {| url = ur;@.|}; - pf ppf {| hash = ha.vl;@.|}; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| raw-input =@.|}; - pf ppf {| |}; - let pkgs_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-url {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-url {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-zip {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-tarball {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-git {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-git {inherit input-name name kind;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-darcs {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.pijul feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 4 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-pijul {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.fossil feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 5 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-fossil {inherit input-name name kind hash;}|}; - ] - ); - pf - ppf - "@[%a@]@." - (list ~sep: (any "@. else ") string) - (Dynarray.to_list pkgs_fetch_ifs); - Dynarray.clear pkgs_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {| in@.|}; - if Features.(has Flag.patches feats) then - begin - pf ppf {| if builtins.length input.ps == 0 then@.|}; - pf ppf {| raw-input@.|}; - pf ppf {| else@.|}; - pf ppf {| pkgs.applyPatches {@.|}; - pf ppf {| src = raw-input;@.|}; - pf ppf {| name = "${if name != null then name else "src"}-patched";@.|}; - pf ppf {| patches = map (p:@.|}; - pf ppf {| if local-patches ? "${p}" then@.|}; - pf ppf {| local-patches."${p}"@.|}; - pf ppf {| else@.|}; - pf ppf {| fetch-patch p lock.p."${p}"@.|}; - pf ppf {| ) input.ps;@.|}; - pf ppf {| };@.|}; - end - else - begin - pf ppf {| raw-input;@.|}; - end; - pf ppf {|in@.|}; - pf ppf {|builtins.mapAttrs to-input lock.i@.|} - -let pp ~version ~features (ppf : Format.formatter) = - Logs.debug (fun m -> m "pp features: %a" Features.pp features); - set_utf_8 ppf true; - let custom_formatter_functions : Format.formatter_out_functions = - let sf = Format.pp_get_formatter_out_functions ppf () in - {sf with out_indent = fun n -> sf.out_string (String.make n '\t') 0 n} - in - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - Format.pp_set_margin Format.std_formatter 80; - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - pp_banner ppf; - pp_cfg ppf; - pf ppf "@.@."; - pp_body ~version ~features ppf () - -let write ?(version = Lazy.(force Schema.Version.latest)) () = - Logs.info (fun m -> m "Lock_loader.write: starting"); - let working_dir = Working_directory.get () in - let filepath = Eio.Path.(working_dir / filename) in : hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; });@.|}; : hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; + pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip ({@.|}; : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; });@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; + pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; : hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; : hunk ./lib/lock_loader.ml 284 + pf ppf {| # base gnutar doesn’t support Zstandard@.|}; + pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; : hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; : hunk ./lib/lock_loader.ml 289 - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; }} [ hunk ./lib/lock_loader.ml 298 - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${name}」"@.|}; - pf ppf {| pkgs.fetchgit {@.|}; + pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; + pf ppf {| pkgs.fetchgit ({@.|}; ] : hunk ./lib/lock_loader.ml 299 - pf ppf {| pkgs.fetchgit {@.|}; + pf ppf {| pkgs.fetchgit ({@.|}; duplicate rotcilfnoc {{ : hunk ./lib/lock_loader.ml 299 - pf ppf {| pkgs.fetchgit {@.|}; + pf ppf {| pkgs.fetchgit ({@.|}; : hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; });@.|}; : hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; + pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip ({@.|}; : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; });@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; + pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; : hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; : hunk ./lib/lock_loader.ml 284 + pf ppf {| # base gnutar doesn’t support Zstandard@.|}; + pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; : hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; : hunk ./lib/lock_loader.ml 289 - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; : hunk ./lib/lock_loader.ml 298 - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${name}」"@.|}; - pf ppf {| pkgs.fetchgit {@.|}; + pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; + pf ppf {| pkgs.fetchgit ({@.|}; }} [] hunk ./lib/lock_loader.ml 298 - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${name}」"@.|}; - pf ppf {| pkgs.fetchgit {@.|}; + pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; + pf ppf {| pkgs.fetchgit ({@.|}; hunk ./lib/lock_loader.ml 287 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 289 - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; hunk ./lib/lock_loader.ml 283 - pf ppf {| fetch-zip = {name, kind, hash}: pkgs.fetchzip {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; hunk ./lib/lock_loader.ml 284 + pf ppf {| # base gnutar doesn’t support Zstandard@.|}; + pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; hunk ./lib/lock_loader.ml 278 - pf ppf {| } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; };@.|}; + pf ppf {| }@.|}; + pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; + pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; hunk ./lib/lock_loader.ml 274 - pf ppf {| fetch-url = {name, kind, hash}: pkgs.fetchurl {@.|}; - pf ppf {| inherit name;@.|}; + pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; : hunk ./lib/lock_loader.ml 15 - let maker = "toastal" - and maker_year_range = year_range 2025 - (* needs a more legally-defined term vs. a fun one :( *) - and hackmates = "Nixtamal contributors" - and hackmates_year_range = year_range 2026 - and margin = Format.pp_get_margin ppf () - in - let hr = - (*──────────────────────────────*) - let uchar = Uchar.of_int 0x2500 - and buf = Buffer.create (margin * 3) - in - for _ = 1 to margin do - Buffer.add_utf_8_uchar buf uchar - done; - Buffer.contents buf - in - pf ppf "/*@."; - pf ppf "SPDX-FileCopyrightText: %s %s@." maker_year_range maker; - pf ppf "SPDX-FileCopyrightText: %s %s@." hackmates_year_range hackmates; - pf ppf "SPDX-License-Identifier: ISC@."; - pf ppf "@."; - pf ppf "@[Permission@ to@ use,@ copy,@ modify,@ and/or@ distribute@ "; - pf ppf "this@ software@ for@ any@ purpose@ with@ or@ without@ fee@ is@ "; - pf ppf "hereby@ granted,@ provided@ that@ the@ above@ copyright@ notice@ &@ "; - pf ppf "this@ permission@ notice@ appear@ in@ all@ copies.@]@."; - pf ppf "@."; - pf ppf "@[THE@ SOFTWARE@ IS@ PROVIDED@ “AS@ IS”@ &@ ISC@ DISCLAIMS@ "; - pf ppf "ALL@ WARRANTIES@ WITH@ REGARD@ TO@ THIS@ SOFTWARE@ INCLUDING@ ALL@ "; - pf ppf "IMPLIED@ WARRANTIES@ OF@ MERCHANTABILITY@ &@ FITNESS.@ IN@ NO@ "; - pf ppf "EVENT@ SHALL@ ISC@ BE@ LIABLE@ FOR@ ANY@ SPECIAL,@ DIRECT,@ "; - pf ppf "INDIRECT,@ OR@ CONSEQUENTIAL@ DAMAGES@ OR@ ANY@ DAMAGES@ WHATSOEVER@ "; - pf ppf "RESULTING@ FROM@ LOSS@ OF@ USE,@ DATA@ OR@ PROFITS,@ WHETHER@ IN@ "; - pf ppf "AN@ ACTION@ OF@ CONTRACT,@ NEGLIGENCE@ OR@ OTHER@ TORTIOUS@ ACTION,@ "; - pf ppf "ARISING@ OUT@ OF@ OR@ IN@ CONNECTION@ WITH@ THE@ USE@ OR@ "; - pf ppf "PERFORMANCE@ OF@ THIS@ SOFTWARE.@]@."; - pf ppf "@."; - pf ppf "%s@." hr; - pf ppf "┏┓╻+╻ ╱┏┳┓┏┓┏┳┓┏┓╻@."; - pf ppf "┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃ This file was generated by Nixtamal.@."; - pf ppf "╹┗┛╹╱ ╹ ╹ ╹╹╹ ╹╹╹┗┛ Do not edit as it will be overwritten.@."; - pf ppf "%s@." hr; - pf ppf "*/@." - -let pp_nix_named_arg (ppf : Format.formatter) ((name, default): (string * string option)) = - pf ppf "%s%a" name (option (fun ppf v -> pf ppf " ? %s" v)) default - -let pp_nix_named_args fmt args = - let pp_args = list ~sep: (any ",@;") pp_nix_named_arg in - let break = Format.pp_print_custom_break ~fits: ("", 0, "") ~breaks: (",", 0, "") in - pf fmt "@[{@;<0 1>@[@[%a@]@]%t@]}:" pp_args args break - -let pp_cfg (ppf : Format.formatter) = - pp_nix_named_args ppf [ - ("system", Some "builtins.currentSystem"); - ("bootstrap-nixpkgs", Some "null"); - ("bootstrap-nixpkgs-lock-name", Some "null"); - ("bootstrap-pkgs", Some "null"); - ] - -(* TODO: consider *not* doing manually as this is ugly AF, but would probably - involve building a Nix AST to do properly, but even a Buffer.add_string or - Jingoo templates could improve this. *) -let pp_body ~version ~features (ppf : Format.formatter) () = - let feats = features in - pf ppf {|let lock = builtins.fromJSON (builtins.readFile ./lock.json); in@.|}; - pf ppf {|assert (lock.v == "%s");@.|} (Schema.Version.to_string version); - pf ppf {|let@.|}; - if Features.(has Flag.patches feats) then - begin - match Foreman.local_patches () with - | [] -> - pf ppf {| local-patches = {};@.|}; - | local_patches -> - pf ppf {| local-patches = {@.|}; - List.iter - (fun (patch_name, path) -> - pf ppf {| "%s" = %s;@.|} (Name.Patch.take patch_name) path - ) - local_patches; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| hash-token = {@.|}; - begin - let open Input.Hash in - for idx = - min_algorithm to max_algorithm do - match algorithm_of_enum idx with - | Some algo -> - pf - ppf - {| "%d" = "%s";@.|} - idx - (algorithm_to_hash_token algo) - | None -> () - done - end; - pf ppf {| };@.|}; - pf ppf {|@.|}; - pf ppf {| try-fetch = input-name: fetcher:@.|}; - pf ppf {| let@.|}; - pf ppf {| try-fetch' = failed-urls: url: urls:@.|}; - pf ppf {| let result = builtins.tryEval (fetcher url); in@.|}; - pf ppf {| if result.success then@.|}; - pf ppf {| result.value@.|}; - pf ppf {| else@.|}; - pf ppf {| let failed-urls' = [ url ] ++ failed-urls; in@.|}; - pf ppf {| if builtins.length urls <= 0 then@.|}; - pf ppf {| let fus = builtins.concatStringsSep " " failed-urls'; in@.|}; - pf ppf {| throw "Input 「${input-name}」fetchable @@ [ ${fus} ]"@.|}; - pf ppf {| else@.|}; - pf ppf {| try-fetch' failed-urls' (builtins.head urls) (builtins.tail urls);@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch' [ ];@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| builtin-fetch-url = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchurl ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|}; - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| builtin-fetch-tarball = {input-name, name, kind, hash}:@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| builtins.fetchTarball ({@.|}; - pf ppf {| inherit url;@.|}; - pf ppf {| ${hash-token.${builtins.toString hash.al}} = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {}))@.|}; - pf ppf {| ) kind.ur kind.ms;@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| builtin-fetch-git = {input-name, name, kind}:@.|}; - pf ppf {| let@.|}; - pf ppf {| ref =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| valu = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then # ref@.|}; - pf ppf {| valu@.|}; - pf ppf {| else if type == 1 then # branch@.|}; - pf ppf {| "refs/heads/${valu}"@.|}; - pf ppf {| else if type == 2 then # tag@.|}; - pf ppf {| "refs/tags/${valu}"@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported reference type “${builtins.toString type}”.";@.|}; - pf ppf {| in@.|}; - pf ppf {| try-fetch input-name (url:@.|}; - pf ppf {| let@.|}; - pf ppf {| args = {@.|}; - pf ppf {| inherit url ref;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| submodules = kind.sm;@.|}; - pf ppf {| lfs = kind.lf;@.|}; - pf ppf {| shallow = true;@.|}; - pf ppf {| }@.|}; - pf ppf {| // (if name != null then {inherit name;} else {});@.|}; - pf ppf {| args' =@.|}; - pf ppf {| if builtins.compareVersions builtins.nixVersion "2.26" < 0 then@.|}; - pf ppf {| builtins.removeAttrs args [ "lfs" ]@.|}; - pf ppf {| else@.|}; - pf ppf {| args;@.|}; - pf ppf {| in@.|}; - pf ppf {| builtins.fetchGit args'@.|}; - pf ppf {| ) kind.rp kind.ms;@.|}; - pf ppf {|@.|} - end; - pf ppf {| builtin-to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| in@.|}; - pf ppf {| |}; - let builtin_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| builtin-fetch-url {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| builtin-fetch-tarball {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| builtin-fetch-git {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| }|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last builtin_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| fetch-darcs {|}; - {| inherit name;|}; - {| input-name = input-name;|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| hash = input.ha;|}; - {| }|}; - ] - ); - pf ppf "@[%a@]@." (list ~sep: (any "@.\t\telse ") string) (Dynarray.to_list builtin_fetch_ifs); - Dynarray.clear builtin_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {|@.|}; - pf ppf {| nixpkgs' =@.|}; - pf ppf {| if builtins.isNull bootstrap-nixpkgs then@.|}; - pf ppf {| builtin-to-input "nixpkgs-for-nixtamal" (@.|}; - pf ppf {| if builtins.isString bootstrap-nixpkgs-lock-name then@.|}; - pf ppf {| lock.i.${bootstrap-nixpkgs-lock-name}@.|}; - pf ppf {| else@.|}; - pf ppf {| lock.i.nixpkgs-nixtamal or lock.i.nixpkgs@.|}; - pf ppf {| )@.|}; - pf ppf {| else@.|}; - pf ppf {| bootstrap-nixpkgs;@.|}; - pf ppf {|@.|}; - pf ppf {| pkgs =@.|}; - pf ppf {| if builtins.isAttrs bootstrap-pkgs then@.|}; - pf ppf {| bootstrap-pkgs@.|}; - pf ppf {| else@.|}; - pf ppf {| import nixpkgs' {inherit system;};@.|}; - pf ppf {|@.|}; - pf ppf {| inherit (pkgs) lib;@.|}; - pf ppf {|@.|}; - if Features.(has Flag.file feats) then - begin - pf ppf {| fetch-url = {input-name, name, kind, hash}: pkgs.fetchurl ({@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.archive feats) then - begin - pf ppf {| fetch-zip = {input-name, name, kind, hash}: pkgs.fetchzip ({@.|}; - pf ppf {| # base gnutar doesn’t support Zstandard@.|}; - pf ppf {| nativeBuildInputs = [pkgs.zstd];@.|}; - pf ppf {| url = kind.ur;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.length kind.ms > 0) {urls = kind.ms;}@.|}; - pf ppf {| // lib.optionalAttrs (builtins.isString kind.ex) {extension = kind.ex;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.git feats) then - begin - pf ppf {| fetch-git = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchgit.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchgit doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchgit ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lr;@.|}; - pf ppf {| fetchSubmodules = kind.sm;@.|}; - pf ppf {| fetchLFS = kind.lf;@.|}; - pf ppf {| deepClone = false;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.darcs feats) then - begin - pf ppf {| fetch-darcs = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchdarcs.__functionArgs ? "mirrors";@.|}; - pf ppf {| reference =@.|}; - pf ppf {| let@.|}; - pf ppf {| type = builtins.elemAt kind.rf 0;@.|}; - pf ppf {| value = builtins.elemAt kind.rf 1;@.|}; - pf ppf {| in@.|}; - pf ppf {| if type == 0 then@.|}; - pf ppf {| let ctx_path = builtins.elemAt value 1; in@.|}; - pf ppf {| assert (lib.hasSuffix ".txt" ctx_path);@.|}; - pf ppf {| let@.|}; - pf ppf {| txt-files = lib.sourceFilesBySuffices ./. [ ".txt" ];@.|}; - pf ppf {| dir = lib.fileset.toSource {@.|}; - pf ppf {| root = ./.;@.|}; - pf ppf {| fileset = lib.fileset.fromSource txt-files;@.|}; - pf ppf {| };@.|}; - pf ppf {| in@.|}; - pf ppf {| {context = "${dir}/${ctx_path}";}@.|}; - pf ppf {| else if type == 1 then@.|}; - pf ppf {| {rev = value;}@.|}; - pf ppf {| else@.|}; - pf ppf {| throw "Invalid Darcs reference";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchdarcs doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchdarcs ({@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // reference // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.pijul feats) then - begin - pf ppf {| fetch-pijul = {input-name, name, kind, hash}:@.|}; - pf ppf {| let@.|}; - pf ppf {| using-mirrors = kind ? ms && (builtins.length kind.ms) > 0;@.|}; - pf ppf {| mirror-support = pkgs.fetchpijul.__functionArgs ? "mirrors";@.|}; - pf ppf {| in@.|}; - pf ppf {| lib.warnIf (using-mirrors && !mirror-support)@.|}; - pf ppf {| "Upstream pkgs.fetchpijul doesn’t yet support mirrors for 「${input-name}」"@.|}; - pf ppf {| pkgs.fetchpijul ({@.|}; - pf ppf {| url = kind.rm;@.|}; - pf ppf {| state = kind.ls;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;}@.|}; - pf ppf {| // lib.optionalAttrs (using-mirrors && mirror-support) {@.|}; - pf ppf {| mirrors = kind.ms;@.|}; - pf ppf {| });@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.fossil feats) then - begin - pf ppf {| fetch-fossil = {input-name, name, kind, hash}:@.|}; - pf ppf {| pkgs.fetchfossil ({@.|}; - pf ppf {| inherit name;@.|}; - pf ppf {| url = kind.rp;@.|}; - pf ppf {| rev = kind.lc;@.|}; - pf ppf {| hash = hash.vl;@.|}; - pf ppf {| }@.|}; - pf ppf {| // lib.optionalAttrs (name != null) {inherit name;});@.|}; - pf ppf {|@.|} - end; - if Features.(has Flag.patches feats) then - begin - pf ppf {| fetch-patch = patch-name: {ur, ha}:@.|}; - pf ppf {| pkgs.fetchpatch2 {@.|}; - pf ppf {| url = ur;@.|}; - pf ppf {| hash = ha.vl;@.|}; - pf ppf {| };@.|}; - pf ppf {|@.|}; - end; - pf ppf {| to-input = input-name: input:@.|}; - pf ppf {| let@.|}; - pf ppf {| name = input.sn;@.|}; - pf ppf {| hash = input.ha;@.|}; - pf ppf {| k = builtins.head input.kd;@.|}; - pf ppf {| raw-input =@.|}; - pf ppf {| |}; - let pkgs_fetch_ifs = Dynarray.create () in - if Features.(has Flag.file feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 0 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-url {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-url {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.archive feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 1 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-zip {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-tarball {inherit input-name name kind hash;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.git feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 2 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| fetch_time = kind.ft;|}; - {| in|}; - {| if fetch_time == 0 then|}; - {| fetch-git {inherit input-name name kind hash;}|}; - {| else if fetch_time == 1 then|}; - {| builtin-fetch-git {inherit input-name name kind;}|}; - {| else|}; - {| throw "Unsupported fetch time ${fetch_time}."|}; - ] - ); - if Features.(has Flag.darcs feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 3 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-darcs {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.pijul feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 4 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-pijul {inherit input-name name kind hash;}|}; - ] - ); - if Features.(has Flag.fossil feats) then - Dynarray.add_last pkgs_fetch_ifs ( - Fmt.str "@[%a@]" (list ~sep: (any "@.") string) [ - {|if k == 5 then|}; - {| let|}; - {| kind = builtins.elemAt input.kd 1;|}; - {| in|}; - {| fetch-fossil {inherit input-name name kind hash;}|}; - ] - ); - pf - ppf - "@[%a@]@." - (list ~sep: (any "@. else ") string) - (Dynarray.to_list pkgs_fetch_ifs); - Dynarray.clear pkgs_fetch_ifs; - pf ppf {| else@.|}; - pf ppf {| throw "Unsupported input kind “${builtins.toString k}”.";@.|}; - pf ppf {| in@.|}; - if Features.(has Flag.patches feats) then - begin - pf ppf {| if builtins.length input.ps == 0 then@.|}; - pf ppf {| raw-input@.|}; - pf ppf {| else@.|}; - pf ppf {| pkgs.applyPatches {@.|}; - pf ppf {| src = raw-input;@.|}; - pf ppf {| name = "${if name != null then name else "src"}-patched";@.|}; - pf ppf {| patches = map (p:@.|}; - pf ppf {| if local-patches ? "${p}" then@.|}; - pf ppf {| local-patches."${p}"@.|}; - pf ppf {| else@.|}; - pf ppf {| fetch-patch p lock.p."${p}"@.|}; - pf ppf {| ) input.ps;@.|}; - pf ppf {| };@.|}; - end - else - begin - pf ppf {| raw-input;@.|}; - end; - pf ppf {|in@.|}; - pf ppf {|builtins.mapAttrs to-input lock.i@.|} - -let pp ~version ~features (ppf : Format.formatter) = - Logs.debug (fun m -> m "pp features: %a" Features.pp features); - set_utf_8 ppf true; - let custom_formatter_functions : Format.formatter_out_functions = - let sf = Format.pp_get_formatter_out_functions ppf () in - {sf with out_indent = fun n -> sf.out_string (String.make n '\t') 0 n} - in - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - Format.pp_set_margin Format.std_formatter 80; - Format.pp_set_formatter_out_functions ppf custom_formatter_functions; - pp_banner ppf; - pp_cfg ppf; - pf ppf "@.@."; - pp_body ~version ~features ppf () - -let write ?(version = Lazy.(force Schema.Version.latest)) () = - Logs.info (fun m -> m "Lock_loader.write: starting"); - let working_dir = Working_directory.get () in - let filepath = Eio.Path.(working_dir / filename) in hunk ./lib/lock_loader.ml 310 - pf ppf {| });@.|}; + pf ppf {| };@.|}; : hunk ./lib/lock_loader.ml 310 - pf ppf {| };@.|}; + pf ppf {| });@.|}; Context: [add NixOS module ·𐑑𐑴𐑕𐑑𐑩𐑤 **20261028085936 Ignore-this: 7aea3093198ed55977cd15096d9642a50b6c0ee54497e1cb9d957c9bf8b0f2b9ae77602ee8f11852 for now all it does is enable the package but could be helpful in the future if we have a config file ] [nixtamal refresh + update channel def ·𐑑𐑴𐑕𐑑𐑩𐑤 **20261025140704 Ignore-this: 59ea4b60bbe021234dbaa88c82d33ad4c351a5e9b33347f668a99c96a30141a050850f25e0d06e92 ] [add a newline after show ·𐑑𐑴𐑕𐑑𐑩𐑤 **20261024190304 Ignore-this: 6949e4458440d3333a6eaa529928bf10c7845dff440416e03c52c7d06b1ea44f694405b3eadfc8d9 ] [use __functor to point to Nixtamal, the installable ·𐑑𐑴𐑕𐑑𐑩𐑤 **20261024162640 Ignore-this: 76d8293a306e5a744edf4ba129c4ef5d7b1f71d8d93f6d9c54e9fa47438fb8d54595f61fb6438f8d ] [TAG 2.3.0 ·𐑑𐑴𐑕𐑑𐑩𐑤 **20261024112634 Ignore-this: 5ddcdb4ae7e3aa668981e3d1d284700e9c62e059809322f6ae167de8cbb766812036ff9c5ab8e006 • BREAKING: set-up --use-mirrors replaces set-up --use-nixpkgs-git-mirrors; the environment variable is now NIXTAMAL_USE_MIRRORS • Nixpkgs channel inputs use the versioned channel archive as the primary source; --use-mirrors adds the TUNA release mirror as a fallback • set-up --use-mirrors with no Nixpkgs reference or with --nixpkgs-channel uses the channel archive + TUNA mirror. --nixpkgs-ref always keeps the Git path with the known TUNA Git mirror; without either flag still (for now) will default to the archive @ https://github.com in order to have an example to copy+build off of for the newest of comers • Now that the version channels are parsed into a datatype, channel archives prefer Zstandard (.zst) with soon-to-be-deprecated LZMA (.xz) fallback for stable major versions (year) < 26 for compatibility ] Patch bundle hash: 2a304c745f9de47f725cc0174be36691c74c1e98