From 7ceb585db2b48fc35519baa207fc804748f395cc Mon Sep 17 00:00:00 2001 From: atagen Date: Tue, 24 Mar 2026 21:48:12 +1100 Subject: [PATCH] ritual --- bin/main.ml | 1 + flake.lock | 93 +++++++++--------------------------------- lib/commands/ritual.ml | 39 ++++++++++++++++++ lib/common.ml | 1 + lib/meat.ml | 1 + nix/default.nix | 2 +- 6 files changed, 63 insertions(+), 74 deletions(-) create mode 100644 lib/commands/ritual.ml diff --git a/bin/main.ml b/bin/main.ml index 6aa19f9..11c0cca 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -13,6 +13,7 @@ let () = | "look" -> look () | "fresh" -> fresh () | "hunt" -> hunt () + | "ritual" -> ritual () | _ -> help () else help () | None -> diff --git a/flake.lock b/flake.lock index 2964faf..843a72b 100644 --- a/flake.lock +++ b/flake.lock @@ -1,50 +1,15 @@ { "nodes": { - "flake-compat": { - "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1743550720, - "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "c621e8422220273271f52058f618c94e405bb0f5", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "ndg": { "inputs": { - "flake-compat": "flake-compat", - "flake-parts": "flake-parts", "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1748103964, - "narHash": "sha256-aRFl6I3x1aKzeOBaD/OJHYv+OQ+qE+3FR9uKhIvfW+A=", + "lastModified": 1773478949, + "narHash": "sha256-8rMpSs2OWGaDlDFO5FS6Pf9WutHBXxM2omPr6hfKydI=", "owner": "feel-co", "repo": "ndg", - "rev": "c556c4cbcba61474bf8a342a31a2d94cbefd8986", + "rev": "c3bc1541668e6f6632a7005c7e4963c0a5dedc7b", "type": "github" }, "original": { @@ -70,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1748217807, - "narHash": "sha256-P3u2PXxMlo49PutQLnk2PhI/imC69hFl1yY4aT5Nax8=", + "lastModified": 1774078191, + "narHash": "sha256-nyxxxW1/2ouu9dU0I02ul5pHrmUrE1JVFhfFlmYe3Lw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3108eaa516ae22c2360928589731a4f1581526ef", + "rev": "09061f748ee21f68a089cd5d91ec1859cd93d0be", "type": "github" }, "original": { @@ -84,44 +49,26 @@ "type": "github" } }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1743296961, - "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, "nixpkgs_2": { "locked": { - "lastModified": 1745930157, - "narHash": "sha256-y3h3NLnzRSiUkYpnfvnS669zWZLoqqI6NprtLQ+5dck=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "46e634be05ce9dc6d4db8e664515ba10b78151ae", - "type": "github" + "lastModified": 1773282481, + "narHash": "sha256-oFe06TmOy8UUT1f7xMHqDpSYq2Fy1mkIsXZUvdnyfeY=", + "rev": "fe416aaedd397cacb33a610b33d60ff2b431b127", + "type": "tarball", + "url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre962285.fe416aaedd39/nixexprs.tar.xz?lastModified=1773282481&rev=fe416aaedd397cacb33a610b33d60ff2b431b127" }, "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "tarball", + "url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz" } }, "nixpkgs_3": { "locked": { - "lastModified": 1748217807, - "narHash": "sha256-P3u2PXxMlo49PutQLnk2PhI/imC69hFl1yY4aT5Nax8=", + "lastModified": 1774078191, + "narHash": "sha256-nyxxxW1/2ouu9dU0I02ul5pHrmUrE1JVFhfFlmYe3Lw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3108eaa516ae22c2360928589731a4f1581526ef", + "rev": "09061f748ee21f68a089cd5d91ec1859cd93d0be", "type": "github" }, "original": { @@ -144,11 +91,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1748163740, - "narHash": "sha256-WOK9w5gtdpy4RefaiRtr6YqFaPxR0OrmI2PleZnn4O4=", + "lastModified": 1760178630, + "narHash": "sha256-oxRMTQtzIO1yFRhY++Ss8+ea1cTH40bD/+FAE+m5NFk=", "ref": "refs/heads/main", - "rev": "4d711e5002bd22adbe6d786560be0fde6cbcf81e", - "revCount": 1, + "rev": "8a6aa536039f1b207888b1369c5cabf0b131e07b", + "revCount": 5, "type": "git", "url": "https://git.atagen.co/atagen/unf" }, diff --git a/lib/commands/ritual.ml b/lib/commands/ritual.ml new file mode 100644 index 0000000..1646f51 --- /dev/null +++ b/lib/commands/ritual.ml @@ -0,0 +1,39 @@ +let run () = + print_string Common.header; + Common.meat_print "PREPARING RITUAL GROUND.."; + let ( >>= ) = Result.bind in + let ( >|= ) = Fun.flip Result.map in + let tmpdir = Filename.temp_dir "meat-chew" "" in + let meats = Unix.getenv "MEATS" in + let hostname = Unix.gethostname () in + let nix_conf_target = + meats ^ "/entry.nix -A nixosConfigurations." ^ hostname + ^ {|'.config.environment.etc."nix/nix.conf"'|} + in + let build_target = + meats ^ "/entry.nix -A nixosConfigurations." ^ hostname + ^ ".config.system.build.toplevel" + in + ( Common.do_cmd ~args:false + @@ "nix-build --log-format internal-json -v --out-link " ^ tmpdir + ^ "/nix.conf " ^ nix_conf_target ^ " |& nom --json" + >>= fun () -> + Common.meat_print "CONSUMING MEATS.."; + Common.do_cmd ~args:false + @@ "NIX_USER_CONF_FILES=" ^ tmpdir + ^ "/nix.conf nix-build --log-format internal-json -v --out-link " ^ tmpdir + ^ "/build " ^ build_target ^ " |& nom --json" + >>= fun () -> + Common.do_cmd ~args:false @@ "dix /nix/var/nix/profiles/system " ^ tmpdir + ^ "/build" + >>= fun () -> + Common.do_cmd ~args:false + @@ "sudo nix-env --set -p /nix/var/nix/profiles/system " ^ tmpdir + ^ "/build && " ^ tmpdir ^ "/build/bin/switch-to-configuration switch" + >|= fun () -> + Unix.unlink @@ tmpdir ^ "/nix-conf"; + Unix.unlink @@ tmpdir ^ "/build" ) + |> ( function + | Error _ -> print_string "FAILED TO CONSUME MEATS." + | _ -> () ); + print_string Common.footer diff --git a/lib/common.ml b/lib/common.ml index c8a87b9..b0f4d9e 100644 --- a/lib/common.ml +++ b/lib/common.ml @@ -10,6 +10,7 @@ let help_text = FRESH - HUNT FRESH MEATS LOOK - LOOK FOR FRESHER MEATS HUNT - HUNT FOR MEATS IN NIXPKGS + RITUAL - PERFORM RITUAL THEN CONSUME TRADE - SEND MEATS FAR AWAY ..-A - ..ALL MEATS|} open Sys diff --git a/lib/meat.ml b/lib/meat.ml index 2d481e1..29a35d1 100644 --- a/lib/meat.ml +++ b/lib/meat.ml @@ -6,5 +6,6 @@ let trade = Commands.Trade.run let look = Commands.Look.run let fresh = Commands.Fresh.run let hunt = Commands.Hunt.run +let ritual = Commands.Ritual.run let help = Commands.Help.run let meat_print = Common.meat_print diff --git a/nix/default.nix b/nix/default.nix index f5274ad..a6004a4 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -13,5 +13,5 @@ ocamlPackages.buildDunePackage { src = ./..; nativeBuildInputs = [ git ]; - inherit buildInputs; + buildInputs = buildInputs; }