Compare commits
10 Commits
f30cb60591
...
1a2ca2dcbd
Author | SHA1 | Date | |
---|---|---|---|
1a2ca2dcbd | |||
|
56d0dc028f | ||
|
ec00841899 | ||
|
4bc3176ce6 | ||
|
4490c67de9 | ||
|
ad43326a43 | ||
|
32347132cc | ||
|
fa2b70cfdb | ||
|
abd078ac19 | ||
|
9fc368c2e6 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
_build
|
||||
.direnv/
|
||||
result
|
||||
justfile
|
||||
todo
|
||||
|
@ -1,7 +1,7 @@
|
||||
open Meat
|
||||
|
||||
let () =
|
||||
match Sys.getenv_opt "NH_FLAKE" with
|
||||
match Sys.getenv_opt "MEATS" with
|
||||
| Some _ ->
|
||||
if Array.length Sys.argv >= 2 then
|
||||
match String.lowercase_ascii (Array.get Sys.argv 1) with
|
||||
@ -9,7 +9,7 @@ let () =
|
||||
| "cook" -> cook ()
|
||||
| "poke" -> poke ()
|
||||
| "gut" -> gut ()
|
||||
| "look" -> look ()
|
||||
(* | "look" -> look () *)
|
||||
| "fresh" -> fresh ()
|
||||
| _ -> help ()
|
||||
else help ()
|
||||
|
@ -1,4 +1,4 @@
|
||||
(lang dune 3.17)
|
||||
(lang dune 3.16)
|
||||
|
||||
(name meat)
|
||||
|
||||
|
264
flake.lock
generated
264
flake.lock
generated
@ -1,236 +1,160 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"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": {
|
||||
"systems": "systems"
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"lastModified": 1743550720,
|
||||
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"ndg": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"lastModified": 1748103964,
|
||||
"narHash": "sha256-aRFl6I3x1aKzeOBaD/OJHYv+OQ+qE+3FR9uKhIvfW+A=",
|
||||
"owner": "feel-co",
|
||||
"repo": "ndg",
|
||||
"rev": "c556c4cbcba61474bf8a342a31a2d94cbefd8986",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "feel-co",
|
||||
"repo": "ndg",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"inputs": {
|
||||
"systems": "systems_3"
|
||||
},
|
||||
"nix-systems": {
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"lastModified": 1689347949,
|
||||
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default-linux",
|
||||
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flakey-profile": {
|
||||
"locked": {
|
||||
"lastModified": 1712898590,
|
||||
"narHash": "sha256-FhGIEU93VHAChKEXx905TSiPZKga69bWl1VB37FK//I=",
|
||||
"owner": "lf-",
|
||||
"repo": "flakey-profile",
|
||||
"rev": "243c903fd8eadc0f63d205665a92d4df91d42d9d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "lf-",
|
||||
"repo": "flakey-profile",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"lix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1732112222,
|
||||
"narHash": "sha256-H7GN4++a4vE49SUNojZx+FSk4mmpb2ifJUtJMJHProI=",
|
||||
"rev": "66f6dbda32959dd5cf3a9aaba15af72d037ab7ff",
|
||||
"type": "tarball",
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/66f6dbda32959dd5cf3a9aaba15af72d037ab7ff.tar.gz?rev=66f6dbda32959dd5cf3a9aaba15af72d037ab7ff"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://git.lix.systems/lix-project/lix/archive/main.tar.gz"
|
||||
}
|
||||
},
|
||||
"lix-module": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"flakey-profile": "flakey-profile",
|
||||
"lix": [
|
||||
"lix"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731967274,
|
||||
"narHash": "sha256-n6dPGRlMGdL8X5gviA6ZuRfUdbdD5KiNN/BpABA5YT0=",
|
||||
"rev": "aa2846680fa9a2032939d720487942567fd9eb63",
|
||||
"type": "tarball",
|
||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/aa2846680fa9a2032939d720487942567fd9eb63.tar.gz?rev=aa2846680fa9a2032939d720487942567fd9eb63"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz"
|
||||
}
|
||||
},
|
||||
"nh": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1732089528,
|
||||
"narHash": "sha256-+yXeJiSFn96pW6H/50DfCfZiOLSfZNGhK7R4f0aUvGY=",
|
||||
"owner": "viperML",
|
||||
"repo": "nh",
|
||||
"rev": "cff51af0ebb09227070b0332c598c7a4b7f8175a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "viperML",
|
||||
"repo": "nh",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default-linux",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1731386116,
|
||||
"narHash": "sha256-lKA770aUmjPHdTaJWnP3yQ9OI1TigenUqVC3wweqZuI=",
|
||||
"owner": "NixOS",
|
||||
"lastModified": 1748217807,
|
||||
"narHash": "sha256-P3u2PXxMlo49PutQLnk2PhI/imC69hFl1yY4aT5Nax8=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "689fed12a013f56d4c4d3f612489634267d86529",
|
||||
"rev": "3108eaa516ae22c2360928589731a4f1581526ef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.05",
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"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": 1732359803,
|
||||
"narHash": "sha256-DPGw9u0Ejy5Hkip79wWSfC1i8q+YqKYngi0AFx3Z4W8=",
|
||||
"lastModified": 1745930157,
|
||||
"narHash": "sha256-y3h3NLnzRSiUkYpnfvnS669zWZLoqqI6NprtLQ+5dck=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1c79f7f85262067ecdffd95234032dda50f42958",
|
||||
"rev": "46e634be05ce9dc6d4db8e664515ba10b78151ae",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1c79f7f85262067ecdffd95234032dda50f42958",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"ocaml-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1732401100,
|
||||
"narHash": "sha256-eNxEkqGdyD+x3yNhJ096N7/8j8TryWA493rSmaL9jAQ=",
|
||||
"owner": "nix-ocaml",
|
||||
"repo": "nix-overlays",
|
||||
"rev": "f6f12811924de05d921c397fad7455e0e2ee644c",
|
||||
"lastModified": 1748217807,
|
||||
"narHash": "sha256-P3u2PXxMlo49PutQLnk2PhI/imC69hFl1yY4aT5Nax8=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3108eaa516ae22c2360928589731a4f1581526ef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-ocaml",
|
||||
"repo": "nix-overlays",
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"lix": "lix",
|
||||
"lix-module": "lix-module",
|
||||
"nh": "nh",
|
||||
"nixpkgs": [
|
||||
"ocaml-overlay",
|
||||
"nixpkgs"
|
||||
],
|
||||
"ocaml-overlay": "ocaml-overlay"
|
||||
"nix-systems": "nix-systems",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"unf": "unf"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"unf": {
|
||||
"inputs": {
|
||||
"ndg": "ndg",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
"lastModified": 1748163740,
|
||||
"narHash": "sha256-WOK9w5gtdpy4RefaiRtr6YqFaPxR0OrmI2PleZnn4O4=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "4d711e5002bd22adbe6d786560be0fde6cbcf81e",
|
||||
"revCount": 1,
|
||||
"type": "git",
|
||||
"url": "https://git.atagen.co/atagen/unf"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
"type": "git",
|
||||
"url": "https://git.atagen.co/atagen/unf"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
179
flake.nix
179
flake.nix
@ -1,127 +1,88 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.follows = "ocaml-overlay/nixpkgs";
|
||||
|
||||
ocaml-overlay = {
|
||||
url = "github:nix-ocaml/nix-overlays";
|
||||
};
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
nh.url = "github:viperML/nh";
|
||||
|
||||
lix = {
|
||||
url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
lix-module = {
|
||||
url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.lix.follows = "lix";
|
||||
};
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
nix-systems.url = "github:nix-systems/default-linux";
|
||||
unf.url = "git+https://git.atagen.co/atagen/unf";
|
||||
};
|
||||
|
||||
nixConfig = {
|
||||
extra-substituters = "https://anmonteiro.nix-cache.workers.dev";
|
||||
extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=";
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
ocaml-overlay,
|
||||
...
|
||||
}: let
|
||||
inherit (inputs) nixpkgs;
|
||||
lix-overlay = inputs.lix-module.overlays.default;
|
||||
lix-module = inputs.lix-module.nixosModules.default;
|
||||
nh-overlay = inputs.nh.overlays.default;
|
||||
version = builtins.toString self.lastModified;
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
ocaml-overlay.overlays.default
|
||||
lix-overlay
|
||||
nh-overlay
|
||||
];
|
||||
modules = [lix-module];
|
||||
extra-substituters = "https://anmonteiro.nix-cache.workers.dev";
|
||||
extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=";
|
||||
};
|
||||
minimal = let
|
||||
inherit (pkgs) ocaml-ng;
|
||||
inherit
|
||||
(ocaml-ng.ocamlPackages_5_2)
|
||||
outputs =
|
||||
inputs:
|
||||
with inputs;
|
||||
let
|
||||
version = builtins.toString self.lastModified;
|
||||
collectPkgs = builtins.attrValues;
|
||||
forEachSystem =
|
||||
function:
|
||||
nixpkgs.lib.genAttrs (import nix-systems) (system: function nixpkgs.legacyPackages.${system});
|
||||
deps = forEachSystem (pkgs: {
|
||||
build = collectPkgs {
|
||||
inherit (pkgs.ocamlPackages)
|
||||
dune_3
|
||||
ocaml
|
||||
;
|
||||
in [
|
||||
dune_3
|
||||
ocaml
|
||||
];
|
||||
dev = let
|
||||
inherit (pkgs) ocaml-ng;
|
||||
inherit
|
||||
(ocaml-ng.ocamlPackages_5_2)
|
||||
};
|
||||
dev = collectPkgs {
|
||||
inherit (pkgs.ocamlPackages)
|
||||
utop
|
||||
ocaml-lsp
|
||||
ocamlformat
|
||||
ocamlformat-rpc-lib
|
||||
;
|
||||
in [
|
||||
utop
|
||||
ocaml-lsp
|
||||
ocamlformat
|
||||
ocamlformat-rpc-lib
|
||||
];
|
||||
inherit (pkgs) lix nh;
|
||||
in {
|
||||
devShells.default = let
|
||||
inherit (pkgs) mkShell;
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = minimal ++ dev ++ [lix nh];
|
||||
};
|
||||
};
|
||||
});
|
||||
in
|
||||
{
|
||||
devShells = forEachSystem (pkgs: {
|
||||
default = pkgs.mkShell {
|
||||
packages = pkgs.lib.mapAttrsToList (_: v: v) deps.${pkgs.system};
|
||||
shellHook =
|
||||
let
|
||||
justFile = ''
|
||||
default:
|
||||
@just --list
|
||||
|
||||
packages.default = pkgs.callPackage ./nix/default.nix {
|
||||
ocaml-deps = minimal;
|
||||
@build:
|
||||
nix build .#debug --offline
|
||||
|
||||
@release:
|
||||
nix build --offline
|
||||
|
||||
@test:
|
||||
printf "\\n\\n\\t************ running nix+dune tests ************\\n\\n\\n"
|
||||
nix flake check --offline
|
||||
'';
|
||||
in
|
||||
''
|
||||
printf '${justFile}' > justfile
|
||||
'';
|
||||
};
|
||||
});
|
||||
|
||||
packages = forEachSystem (pkgs: {
|
||||
default = pkgs.callPackage ./nix/default.nix {
|
||||
buildInputs = deps.${pkgs.system}.build;
|
||||
inherit version;
|
||||
};
|
||||
|
||||
defaultPackage = self.packages.${system}.default;
|
||||
}
|
||||
)
|
||||
// {
|
||||
nixosModules.meat = import ./nix/module.nix {
|
||||
meatOverlays = [
|
||||
self.overlays.meat
|
||||
nh-overlay
|
||||
ocaml-overlay.overlays.default
|
||||
];
|
||||
lixModule = lix-module;
|
||||
};
|
||||
|
||||
overlays.meat = final: _prev: let
|
||||
ocaml-deps = let
|
||||
inherit (final) ocaml-ng;
|
||||
inherit
|
||||
(ocaml-ng.ocamlPackages_5_2)
|
||||
dune_3
|
||||
ocaml
|
||||
;
|
||||
in [
|
||||
dune_3
|
||||
ocaml
|
||||
];
|
||||
in {
|
||||
meat = final.callPackage ./nix/default.nix {
|
||||
inherit ocaml-deps version;
|
||||
docs = pkgs.callPackage unf.lib.pak-chooie {
|
||||
inherit self;
|
||||
projectName = "meat";
|
||||
newPath = "https://git.atagen.co/atagen/meat/src";
|
||||
modules = [
|
||||
self.nixosModules.meat
|
||||
];
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
nixosModules.meat =
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [ ./nix/module.nix ];
|
||||
programs.meat.package = self.packages.${pkgs.system}.default;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
77
lib/meat.ml
77
lib/meat.ml
@ -2,65 +2,78 @@ let header = "\n ----- MEAT ----------------------------------------\n"
|
||||
let footer = "\n ---------------------------------------------------\n"
|
||||
|
||||
let help =
|
||||
"\n\
|
||||
\tYUM - CONSUME DELICIOUS MEATS\n\
|
||||
\tCOOK - ONLY PREPARE MEATS\n\
|
||||
\tPOKE - TASTE SUSPICIOUS MEATS\n\
|
||||
\tGUT - CLEAN MEAT STORES\n\
|
||||
\tLOOK - INSPECT MEAT\n\
|
||||
\tFRESH - HUNT FRESH MEATS\n\
|
||||
\t..N - ..MEATS OF N\n\
|
||||
\t..-S N - ..SUBMEAT N\n\
|
||||
\t..-A - ..ALL MEATS\n"
|
||||
{|
|
||||
YUM - CONSUME DELICIOUS MEATS
|
||||
COOK - ONLY PREPARE MEATS
|
||||
POKE - TASTE SUSPICIOUS MEATS
|
||||
GUT - CLEAN MEAT STORES
|
||||
FRESH - HUNT FRESH MEATS
|
||||
..-A - ..ALL MEATS|}
|
||||
|
||||
(* \tLOOK - LOOK FOR FRESHER MEATS *)
|
||||
open Sys
|
||||
|
||||
(* TODO rewrite all of this to use its own build and activation routines *)
|
||||
(* pipe into nom for user output, then use dix at the end *)
|
||||
let pass_args () =
|
||||
let len = Array.length argv and sconcat acc el = acc ^ " " ^ el in
|
||||
match len with
|
||||
| 3 -> argv.(2)
|
||||
| n when n > 3 ->
|
||||
print_int (n - 1);
|
||||
Array.fold_left sconcat "" (Array.sub argv 2 (n - 2))
|
||||
Array.fold_left sconcat " " (Array.sub argv 2 (n - 2))
|
||||
| _ -> ""
|
||||
|
||||
let do_cmd ?(args = true) cmd =
|
||||
match command (if args then cmd ^ pass_args () else cmd) with _ -> ()
|
||||
match command (if args then cmd ^ " " ^ pass_args () else cmd) with | 0 -> Ok(()) | e -> Error(e)
|
||||
|
||||
let meat_print text = print_endline ("\n \t" ^ text ^ "\n")
|
||||
|
||||
let do_build () =
|
||||
let (>>=) = Result.bind in
|
||||
let (>|=) = Fun.flip Result.map in
|
||||
let tmpdir = Filename.temp_dir "meat-build" "" in
|
||||
let build_target = Unix.getenv "MEATS" ^ "#nixosConfigurations." ^ Unix.gethostname () ^ ".config.system.build.toplevel" in
|
||||
do_cmd @@ "nix build --out-link " ^ tmpdir ^ "/build " ^ build_target >>=
|
||||
fun () -> do_cmd @@ "sudo " ^ tmpdir ^ "/build/bin/switch-to-configuration switch" >>=
|
||||
fun () -> do_cmd @@ "sudo " ^ tmpdir ^ "/build/bin/switch-to-configuration boot" >|=
|
||||
fun () -> Unix.unlink @@ tmpdir ^ "/build"
|
||||
|
||||
let yum () =
|
||||
print_string header;
|
||||
meat_print "CONSUMING DELICIOUS MEATS..";
|
||||
do_cmd "nh os switch";
|
||||
print_string footer
|
||||
do_build () |> function | Error _ -> print_string "FAILED TO CONSUME MEATS"; print_string footer | _ -> print_string footer
|
||||
|
||||
let cook () =
|
||||
print_string header;
|
||||
meat_print "PREPARING DELICIOUS MEATS..";
|
||||
do_cmd "nh os build";
|
||||
let build_target = Unix.getenv "MEATS" ^ "#nixosConfigurations." ^ Unix.gethostname () ^ ".config.system.build.toplevel" in
|
||||
do_cmd @@ "nix build --no-link" ^ build_target |> ignore;
|
||||
print_string footer
|
||||
|
||||
let poke () =
|
||||
print_string header;
|
||||
meat_print "PREPARING SUSPICIOUS MEATS..";
|
||||
do_cmd "nh os build -- --show-trace";
|
||||
let build_target = Unix.getenv "MEATS" ^ "#nixosConfigurations." ^ Unix.gethostname () ^ ".config.system.build.toplevel" in
|
||||
do_cmd @@ "nix build --no-link" ^ build_target ^ " --show-trace" |> ignore;
|
||||
print_string footer
|
||||
|
||||
let gut () =
|
||||
print_string header;
|
||||
meat_print "CLEANING MEAT STORES..";
|
||||
do_cmd "nh clean all";
|
||||
do_cmd "nh clean all" |> ignore;
|
||||
print_string footer
|
||||
|
||||
let look () =
|
||||
print_string header;
|
||||
meat_print "INSPECTING MEAT..";
|
||||
meat_print "CONSUMING MEATS:";
|
||||
do_cmd "nix flake metadata $NH_FLAKE";
|
||||
meat_print "PRODUCING MEATS:";
|
||||
do_cmd "nix flake show $NH_FLAKE";
|
||||
print_string footer
|
||||
(* TODO pending fuiska lib.. *)
|
||||
(* let look () = *)
|
||||
(* print_string header; *)
|
||||
(* meat_print "INSPECTING MEAT.."; *)
|
||||
(* meat_print "CONSUMING MEATS:"; *)
|
||||
(* let meats = Unix.getenv "MEATS" in *)
|
||||
(* do_cmd @@ "nix flake metadata" ^ meats |> ignore; *)
|
||||
(* meat_print "PRODUCING MEATS:"; *)
|
||||
(* do_cmd "nix flake show $MEATS"; *)
|
||||
(* print_string footer; *)
|
||||
|
||||
(* let all_flag () = Array.mem "-a" argv || Array.mem "--all" argv
|
||||
let sub_flag () = Array.mem "-s" argv || Array.mem "--subflake" argv *)
|
||||
@ -114,13 +127,13 @@ let submeats s =
|
||||
s
|
||||
|> List.iter (fun d ->
|
||||
meat_print ("PROCESSING SUBMEAT " ^ fmt_dir d ^ "..");
|
||||
do_cmd ~args:false ("nix flake update --flake " ^ d))
|
||||
do_cmd ~args:false @@ "nix flake update --flake " ^ d |> ignore)
|
||||
|
||||
let fresh () =
|
||||
print_string header;
|
||||
meat_print "HUNTING FRESH MEATS..";
|
||||
let argv_len = Array.length argv in
|
||||
let root = Sys.getenv "NH_FLAKE" in
|
||||
let root = Sys.getenv "MEATS" in
|
||||
let base_dir = root ^ "/flakes" in
|
||||
(match (sub_flag (), all_flag ()) with
|
||||
| false, false ->
|
||||
@ -132,14 +145,14 @@ let fresh () =
|
||||
|> iter (fun f ->
|
||||
if all_low f = "meat" then meat_print "PROCESSING REAL MEAT.."
|
||||
else meat_print ("PROCESSING FRESH MEAT " ^ all_caps f ^ "..");
|
||||
do_cmd ~args:false ("nix flake update " ^ f ^ " --flake " ^ root))
|
||||
else do_cmd ("nix flake update --flake " ^ root)
|
||||
do_cmd ~args:false @@ "nix flake update " ^ f ^ " --flake " ^ root |> ignore)
|
||||
else do_cmd @@ "nix flake update --flake " ^ root |> ignore
|
||||
| _, true ->
|
||||
(* all flag, update all subflakes and main flake inputs *)
|
||||
walk base_dir |> List.sort compdepth |> List.rev |> submeats;
|
||||
print_string footer;
|
||||
meat_print "PROCESSING FRESH MEATS..";
|
||||
do_cmd ~args:false ("nix flake update --flake " ^ root)
|
||||
do_cmd ~args:false @@ "nix flake update --flake " ^ root |> ignore
|
||||
| true, _ when argv_len >= 4 ->
|
||||
(* sub flag, update inputs as subflakes *)
|
||||
let subflakes =
|
||||
@ -155,8 +168,8 @@ let fresh () =
|
||||
meat_print "PROCESSING FRESH MEATS..";
|
||||
subflakes
|
||||
|> iter (fun f ->
|
||||
do_cmd ~args:false
|
||||
("nix flake update " ^ all_low f ^ " --flake $NH_FLAKE"))
|
||||
do_cmd ~args:false @@
|
||||
"nix flake update " ^ all_low f ^ " --flake $MEATS" |> ignore)
|
||||
| _ -> print_string help);
|
||||
print_string footer;
|
||||
print_newline ()
|
||||
|
@ -11,7 +11,7 @@ doc: "https://url/to/documentation"
|
||||
bug-reports: "https://github.com/username/reponame/issues"
|
||||
depends: [
|
||||
"ocaml"
|
||||
"dune" {>= "3.17"}
|
||||
"dune" {>= "3.16"}
|
||||
"odoc" {with-doc}
|
||||
]
|
||||
build: [
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
ocamlPackages,
|
||||
ocaml-deps,
|
||||
buildInputs,
|
||||
git,
|
||||
version,
|
||||
...
|
||||
@ -12,6 +12,6 @@ ocamlPackages.buildDunePackage {
|
||||
minimalOCamlVersion = "5.2";
|
||||
|
||||
src = ./..;
|
||||
nativeBuildInputs = [git];
|
||||
buildInputs = ocaml-deps;
|
||||
nativeBuildInputs = [ git ];
|
||||
inherit buildInputs;
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
cfg = config.programs.meat;
|
||||
in {
|
||||
options.programs.meat = {
|
||||
enable = mkEnableOption "meat";
|
||||
flake = mkOption {
|
||||
type = with types; nullOr (either path str);
|
||||
default = null;
|
||||
description = "path to your system flake";
|
||||
};
|
||||
};
|
||||
config = let
|
||||
inherit (pkgs) meat nh lix;
|
||||
in
|
||||
lib.mkIf
|
||||
cfg.enable
|
||||
{
|
||||
environment.systemPackages = [meat nh lix];
|
||||
environment.sessionVariables.NH_FLAKE =
|
||||
if (cfg.flake == null)
|
||||
then abort "Please set the programs.meat.flake option to your system flake."
|
||||
else config.programs.meat.flake;
|
||||
};
|
||||
}
|
@ -1,7 +1,30 @@
|
||||
{
|
||||
meatOverlays,
|
||||
lixModule,
|
||||
}: {
|
||||
imports = [./meat-module.nix lixModule];
|
||||
nixpkgs.overlays = meatOverlays;
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
cfg = config.programs.meat;
|
||||
in
|
||||
{
|
||||
options.programs.meat = {
|
||||
enable = mkEnableOption "meat";
|
||||
flake = mkOption {
|
||||
type = with types; either path str;
|
||||
description = "path to your system flake";
|
||||
};
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
description = "your ideal meat";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.sessionVariables.MEATS = cfg.flake;
|
||||
environment.systemPackages = [
|
||||
cfg.package
|
||||
pkgs.nh # for now..
|
||||
];
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user