Merge branch 'pr-void-cli-paisano' into 'master'
Void CLI See merge request private-void/depot!54
This commit is contained in:
commit
4db993b108
13 changed files with 231 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,3 +3,5 @@ result
|
|||
result-*
|
||||
**/.direnv/
|
||||
.data/
|
||||
.cache/
|
||||
.nixos-test-history
|
||||
|
|
10
catalog/part.nix
Normal file
10
catalog/part.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
perSystem = {
|
||||
options.catalog = lib.mkOption {
|
||||
type = with lib.types; lazyAttrsOf (lazyAttrsOf (lazyAttrsOf (submodule ./target.nix)));
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
31
catalog/target.nix
Normal file
31
catalog/target.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ lib, name, ... }:
|
||||
|
||||
{
|
||||
options = {
|
||||
description = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
};
|
||||
|
||||
actions = lib.mkOption {
|
||||
type = with lib.types; lazyAttrsOf (submodule {
|
||||
options = {
|
||||
description = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
};
|
||||
|
||||
command = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
|
||||
packages = lib.mkOption {
|
||||
type = with lib.types; listOf package;
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
52
cluster/catalog/default.nix
Normal file
52
cluster/catalog/default.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (config) cluster flake;
|
||||
in
|
||||
|
||||
{
|
||||
perSystem = { config, pkgs, ... }: {
|
||||
catalog.cluster = {
|
||||
services = lib.mapAttrs (name: svc: {
|
||||
description = "Cluster service: ${name}";
|
||||
actions = let
|
||||
mkDeployAction = { description, agents }: {
|
||||
inherit description;
|
||||
packages = [
|
||||
config.packages.cachix
|
||||
pkgs.tmux
|
||||
];
|
||||
command = let
|
||||
cachixDeployJson = pkgs.writeText "cachix-deploy.json" (builtins.toJSON {
|
||||
agents = lib.genAttrs agents (name: builtins.unsafeDiscardStringContext flake.nixosConfigurations.${name}.config.system.build.toplevel);
|
||||
});
|
||||
in ''
|
||||
set -e
|
||||
echo building ${toString (lib.length agents)} configurations in parallel
|
||||
tmux new-session ${lib.concatStringsSep " split-window " (
|
||||
map (host: let
|
||||
drvPath = builtins.unsafeDiscardStringContext flake.nixosConfigurations.${host}.config.system.build.toplevel.drvPath;
|
||||
in '' 'echo building configuration for ${host}; nix build -L --no-link --store "ssh-ng://${host}" --eval-store auto "${drvPath}^*"'\; '') agents
|
||||
)} select-layout even-vertical
|
||||
|
||||
source ~/.config/cachix/deploy
|
||||
cachix deploy activate ${cachixDeployJson}
|
||||
echo
|
||||
'';
|
||||
};
|
||||
in {
|
||||
deployAll = mkDeployAction {
|
||||
description = "Deploy ALL groups of this service.";
|
||||
agents = lib.unique (lib.concatLists (lib.attrValues svc.nodes));
|
||||
};
|
||||
} // lib.mapAttrs' (group: agents: {
|
||||
name = "deployGroup-${group}";
|
||||
value = mkDeployAction {
|
||||
description = "Deploy the '${group}' group of this service.";
|
||||
inherit agents;
|
||||
};
|
||||
}) svc.nodes;
|
||||
}) cluster.config.services;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
{ depot, lib, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./catalog
|
||||
];
|
||||
|
||||
options.cluster = lib.mkOption {
|
||||
type = lib.types.raw;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
./jobs/part.nix
|
||||
./lib/part.nix
|
||||
./cluster/part.nix
|
||||
./catalog/part.nix
|
||||
];
|
||||
};
|
||||
|
||||
|
|
42
lib/catalog.nix
Normal file
42
lib/catalog.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ config, lib, withSystem, ... }:
|
||||
|
||||
{
|
||||
lib = {
|
||||
catalog = {
|
||||
init = lib.genAttrs config.systems (system: withSystem system ({ config, ... }: lib.mapAttrsToList (name: cell: {
|
||||
cell = name;
|
||||
cellBlocks = lib.mapAttrsToList (name: block: {
|
||||
blockType = "catalogBlock";
|
||||
cellBlock = name;
|
||||
targets = lib.mapAttrsToList (name: target: {
|
||||
inherit name;
|
||||
inherit (target) description;
|
||||
actions = lib.mapAttrsToList (name: action: {
|
||||
inherit name;
|
||||
inherit (action) description;
|
||||
}) target.actions;
|
||||
}) block;
|
||||
}) cell;
|
||||
}) config.catalog));
|
||||
|
||||
actions = lib.genAttrs config.systems (system: withSystem system ({ config, pkgs, ... }:
|
||||
lib.mapAttrs (name: cell:
|
||||
lib.mapAttrs (name: block:
|
||||
lib.mapAttrs (name: target:
|
||||
lib.mapAttrs (name: action:
|
||||
let
|
||||
binPath = lib.makeBinPath action.packages;
|
||||
in pkgs.writeShellScript name ''
|
||||
# Void CLI Action
|
||||
# ---
|
||||
${lib.optionalString (action.packages != []) ''export PATH="${binPath}:$PATH"''}
|
||||
# ---
|
||||
${action.command}
|
||||
'') target.actions
|
||||
) block
|
||||
) cell
|
||||
)
|
||||
config.catalog));
|
||||
};
|
||||
};
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
./meta.nix
|
||||
./nginx.nix
|
||||
./identity.nix
|
||||
./catalog.nix
|
||||
];
|
||||
|
||||
options.lib = lib.mkOption {
|
||||
|
@ -23,5 +24,8 @@
|
|||
});
|
||||
};
|
||||
|
||||
config._module.args.depot = config;
|
||||
config = {
|
||||
_module.args.depot = config;
|
||||
flake = { inherit (config) lib; };
|
||||
};
|
||||
}
|
||||
|
|
21
packages/catalog/checks.nix
Normal file
21
packages/catalog/checks.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
perSystem = { config, ... }: {
|
||||
catalog.depot = {
|
||||
checks = lib.mapAttrs (name: check: {
|
||||
description = "NixOS Test: ${name}";
|
||||
actions = {
|
||||
build = {
|
||||
description = "Build this check.";
|
||||
command = "nix build -L --no-link '${builtins.unsafeDiscardStringContext check.drvPath}^*'";
|
||||
};
|
||||
runInteractive = {
|
||||
description = "Run interactive driver.";
|
||||
command = lib.getExe check.driverInteractive;
|
||||
};
|
||||
};
|
||||
}) config.checks;
|
||||
};
|
||||
};
|
||||
}
|
5
packages/catalog/default.nix
Normal file
5
packages/catalog/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
imports = [
|
||||
./checks.nix
|
||||
];
|
||||
}
|
|
@ -8,6 +8,7 @@ in {
|
|||
imports = [
|
||||
./projects.nix
|
||||
./patched-inputs.nix
|
||||
./catalog
|
||||
];
|
||||
perSystem = { pkgs, self', system, ... }: let
|
||||
patched-derivations = import ./patched-derivations.nix (pkgs // { flakePackages = self'.packages; });
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
searxng = pkgs.callPackage ./web-apps/searxng { inherit pins; };
|
||||
|
||||
stevenblack-hosts = pkgs.callPackage ./data/stevenblack { inherit pins; };
|
||||
|
||||
void = pkgs.callPackage ./tools/void { };
|
||||
};
|
||||
|
||||
projectShells = {
|
||||
|
@ -58,6 +60,7 @@
|
|||
hci
|
||||
npins
|
||||
pin
|
||||
void
|
||||
pkgs.deadnix
|
||||
pkgs.statix
|
||||
];
|
||||
|
|
53
packages/tools/void/default.nix
Normal file
53
packages/tools/void/default.nix
Normal file
|
@ -0,0 +1,53 @@
|
|||
{ lib, buildGoModule, fetchFromGitHub, installShellFiles }:
|
||||
|
||||
let
|
||||
version = "0.15.0+dev";
|
||||
rev = "6461b31e4458dbce655fa1db6d266f666dbdfc4e";
|
||||
in
|
||||
buildGoModule rec {
|
||||
|
||||
inherit version;
|
||||
pname = "void";
|
||||
|
||||
meta = {
|
||||
description = "Paisano CLI/TUI, customized for Private Void";
|
||||
license = lib.licenses.unlicense;
|
||||
homepage = "https://github.com/paisano-nix/tui";
|
||||
};
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "paisano-nix";
|
||||
repo = "tui";
|
||||
inherit rev;
|
||||
hash = "sha256-EFDb8jfv2SH57a6CfDo0WU4XjDihhgvVnKKw20yqksc=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace flake/flake.go --replace-fail __std lib.catalog
|
||||
substituteInPlace env/env.go --replace-fail '"metadata"' '"void-cli-metadata"'
|
||||
'';
|
||||
|
||||
sourceRoot = "source/src";
|
||||
|
||||
vendorHash = "sha256-S1oPselqHRIPcqDSsvdIkCwu1siQGRDHOkxWtYwa+g4=";
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
|
||||
postInstall = ''
|
||||
mv $out/bin/paisano $out/bin/void
|
||||
|
||||
installShellCompletion --cmd void \
|
||||
--bash <($out/bin/void _carapace bash) \
|
||||
--fish <($out/bin/void _carapace fish) \
|
||||
--zsh <($out/bin/void _carapace zsh)
|
||||
'';
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X main.buildVersion=${version}"
|
||||
"-X main.buildCommit=${rev}"
|
||||
"-X main.argv0=void"
|
||||
"-X main.project=Depot"
|
||||
];
|
||||
}
|
Loading…
Reference in a new issue