diff options
| -rw-r--r-- | nix/tamal/.editorconfig | 8 | ||||
| -rw-r--r-- | nix/tamal/default.nix | 97 | ||||
| -rw-r--r-- | nix/tamal/lock.json | 1 | ||||
| -rw-r--r-- | nix/tamal/manifest.kdl | 13 | ||||
| -rw-r--r-- | release.nix | 7 |
5 files changed, 121 insertions, 5 deletions
diff --git a/nix/tamal/.editorconfig b/nix/tamal/.editorconfig new file mode 100644 index 0000000..d029f52 --- /dev/null +++ b/nix/tamal/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/nix/tamal/default.nix b/nix/tamal/default.nix new file mode 100644 index 0000000..dcebfbd --- /dev/null +++ b/nix/tamal/default.nix @@ -0,0 +1,97 @@ +/* +SPDX-FileCopyrightText: 2025 toastal +SPDX-License-Identifier: ISC + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice & this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED “AS IS” & ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY & +FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, +OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. + +────────────────────────────────────────────────────────────────────────────── +This file was generated by Nixtamal. Do not edit as it will be overwritten. +────────────────────────────────────────────────────────────────────────────── +*/ +{ + system ? builtins.currentSystem, + nixpkgs ? null, + bootstrap-nixpkgs-lock-name ? null, +}: + +let lock = builtins.fromJSON (builtins.readFile ./lock.json); in +assert (lock.v == "0.1.0"); +let + try-fetch = name: fetcher: + let + try-fetch' = failed-urls: url: urls: + let result = builtins.tryEval (fetcher url); in + if result.success then + result.value + else + let failed-urls' = [ url ] ++ failed-urls; in + if builtins.length urls <= 0 then + let fus = builtins.concatStringsSep " " failed-urls'; in + builtins.throw "Input 「${name}」 fetchable +[ ${fus} ]" + else + try-fetch' failed-urls' (builtins.head urls) (builtins.tail urls); + in + try-fetch' [ ]; + + builtin-fetch-tarball = {name, kind, hash}: + try-fetch name (url: + builtins.fetchTarball { + inherit url; + ${hash.al} = hash.vl; + } + ) kind.ur kind.ms; + + builtin-to-input = name: input: + let k = builtins.head input.kd; in + if k == 1 then + builtin-fetch-tarball { + inherit name; + kind = builtins.elemAt input.kd 1; + hash = input.ha; + } + else + throw "Unsupported input kind “${builtins.toString k}”."; + + nixpkgs' = if builtins.isNull nixpkgs then + builtin-to-input "nixpkgs-for-nixtamal" ( + if builtins.isString bootstrap-nixpkgs-lock-name then + lock.i.${bootstrap-nixpkgs-lock-name} + else + lock.i.nixpkgs-nixtamal or lock.i.nixpkgs + ) + else + nixpkgs; + + pkgs = import nixpkgs' {inherit system;}; + + inherit (pkgs) lib; + + fetch-zip = {name, kind, hash}: pkgs.fetchzip { + inherit name; + url = kind.ur; + ${hash.al} = hash.vl; + } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; }; + + to-input = name: input: + let k = builtins.head input.kd; in + if k == 1 then + fetch-zip { + inherit name; + kind = builtins.elemAt input.kd 1; + hash = input.ha; + } + else + throw "Unsupported input kind “${builtins.toString k}”."; +in +builtins.mapAttrs to-input lock.i diff --git a/nix/tamal/lock.json b/nix/tamal/lock.json new file mode 100644 index 0000000..a4dffa1 --- /dev/null +++ b/nix/tamal/lock.json @@ -0,0 +1 @@ +{"v":"0.1.0","i":{"nixpkgs":{"kd":[1,{"ur":"https://github.com/NixOS/nixpkgs/archive/677fbe97984e7af3175b6c121f3c39ee5c8d62c9.tar.gz","ms":[]}],"ha":{"al":"sha256","vl":"1cfnwpvk5x3p5vxkvykzgffy9r3a7via6w4c8yk8rfsa2hrbhrl3"},"lv":"677fbe97984e7af3175b6c121f3c39ee5c8d62c9"}}}
\ No newline at end of file diff --git a/nix/tamal/manifest.kdl b/nix/tamal/manifest.kdl new file mode 100644 index 0000000..236392a --- /dev/null +++ b/nix/tamal/manifest.kdl @@ -0,0 +1,13 @@ +version "0.1.0" +inputs { + nixpkgs { + archive { + url "https://github.com/NixOS/nixpkgs/archive/{{cmd_value}}.tar.gz" + } + latest-cmd { + $ git ls-remote --heads "https://github.com/NixOS/nixpkgs.git" --refs "refs/heads/nixpkgs-unstable" + | cut -f1 + } + } +} + diff --git a/release.nix b/release.nix index 4d9b6b9..0e2ad6a 100644 --- a/release.nix +++ b/release.nix @@ -3,12 +3,9 @@ # SPDX-License-Identifier: LGPL-2.1-or-later │ #──────────────────────────────────────────────────────────────────────────────┘ let - pkgs_src = builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/bd88d6c13ab85cc842b93d53f68d6d40412e5a18.tar.gz"; - sha256 = "0nxk7d12y1zq7rbfjkspprbh2wac61cjsjaidc94gpv9bd0pbsja"; - }; + inputs = import ./nix/tamal { }; - pkgs = import pkgs_src { + pkgs = import inputs.nixpkgs { overlays = [ (import ./nix/overlay/default.nix) (import ./nix/overlay/development.nix) |
