This commit is contained in:
parent
703ac28f52
commit
d4b98b4475
6 changed files with 63 additions and 74 deletions
39
lib/commands/ritual.ml
Normal file
39
lib/commands/ritual.ml
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue