all nuing with versions

This commit is contained in:
ari committed 2026-09-16 22:15:07 -04:00
1 parent 1e1da2f7a1
commit f5f6a98152
3 files changed
+44 -26

No files matched your search

+19 -26
View File
@@ -15,22 +15,21 @@
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
# nu/lib/common.nu holds helpers shared by every host-side tool below
# (say/note/ok/warn/die/step/ask/confirm/confirm-word/shquote,
# vsock-ssh-args, run-argv). It's never `use`d at runtime - once a
# script is wrapped into a single file in the Nix store, a relative
# `use` isn't reliably resolvable - so it's concatenated in here
# instead, in front of each tool's own script.
nuScript = path: (builtins.readFile ./nu/lib/common.nu) + "\n" + (builtins.readFile path);
gitRev = self.rev or self.dirtyRev or "unknown";
shortRev = if gitRev == "unknown" then "unknown" else builtins.substring 0 7 gitRev;
version =
"${builtins.substring 0 4 self.lastModifiedDate}."
+ "${builtins.substring 4 2 self.lastModifiedDate}."
+ "${builtins.substring 6 2 self.lastModifiedDate}-${shortRev}";
in
{
nixosModules.default = ./modules/host.nix;
nixosModules.default = { lib, ... }: {
imports = [ ./modules/host.nix ];
config.services.hermenix.version = lib.mkDefault version;
};
packages.${system} = {
# One-time bootstrap image. See the README: building this needs two
# extra substituter flags so you aren't compiling Determinate Nix
# yourself.
hermes-guest-image = nixos-generators.nixosGenerate {
inherit system;
format = "raw-efi";
@@ -39,12 +38,6 @@
./guest/common.nix
];
};
# The host-side CLI: `hermenix setup` (guided disk/cache/image setup)
# and `hermenix migrate <source>` (carry over an existing flat
# HERMES_HOME). A Nu script, wrapped so its external dependencies are
# always on PATH regardless of what the host happens to have
# installed.
hermenix = pkgs.writers.writeNuBin "hermenix"
{
makeWrapperArgs = [
@@ -61,15 +54,13 @@
coreutils
nix
]))
"--set"
"HERMENIX_VERSION"
version
];
}
(nuScript ./nu/hermenix.nu);
# Host-side control of the VM itself (start/stop/console/snapshots/
# backups) - see nu/hermes-vm.nu. Defaults match
# services.hermenix's own option defaults; modules/host.nix wraps
# this same script with the per-host values baked in via env vars
# instead (see its own writeNuBin calls).
hermes-vm = pkgs.writers.writeNuBin "hermes-vm"
{
makeWrapperArgs = [
@@ -85,14 +76,13 @@
util-linux
restic
]))
"--set"
"HERMENIX_VERSION"
version
];
}
(nuScript ./nu/hermes-vm.nu);
# Host-side control of Hermes itself, inside the guest (identity,
# config, secrets, gateway service, passthrough to its own `hermes`
# CLI) - see nu/hermes-ctl.nu. Same per-host-defaults/module-override
# relationship as hermes-vm above.
hermes-ctl = pkgs.writers.writeNuBin "hermes-ctl"
{
makeWrapperArgs = [
@@ -106,6 +96,9 @@
gnutar
vim
]))
"--set"
"HERMENIX_VERSION"
version
];
}
(nuScript ./nu/hermes-ctl.nu);
+17
View File
@@ -384,6 +384,17 @@ in
default = 77;
description = "Host reaches the guest over vsock, so no inbound network path is needed.";
};
version = mkOption {
type = types.str;
default = "dev";
description = ''
"YYYY.MM.DD-<commit-sha>" reported by hermes-vm/hermes-ctl's
`version` subcommand. Normally supplied for free by this flake's own
`nixosModules.default` (from its git metadata) - the "dev" default
here only shows up if this module is imported some other way.
'';
};
};
config = mkIf cfg.enable {
@@ -837,6 +848,9 @@ in
"--set"
"HERMES_DISK_BASE_DIR"
cfg.disk.baseDir
"--set"
"HERMENIX_VERSION"
cfg.version
];
}
((builtins.readFile ../nu/lib/common.nu) + "\n" + (builtins.readFile ../nu/hermes-vm.nu)))
@@ -872,6 +886,9 @@ in
"--set"
"HERMES_CLI_NAME"
cfg.cliName
"--set"
"HERMENIX_VERSION"
cfg.version
];
}
((builtins.readFile ../nu/lib/common.nu) + "\n" + (builtins.readFile ../nu/hermes-ctl.nu)))
+8
View File
@@ -55,3 +55,11 @@ def vsock-ssh-args [vsock_cid: int, guest_user: string, guest_host: string] {
def run-argv [argv: list<string>] {
^($argv | first) ...($argv | skip 1)
}
# --------------------------------------------------------------- version ---
# HERMENIX_VERSION is baked in at build time (flake.nix / modules/host.nix)
# as "YYYY.MM.DD-<commit-sha>" from this repo's own git metadata. "dev" is
# only seen running an unwrapped checkout of the script directly.
def hermenix-version [] { $env.HERMENIX_VERSION? | default "dev" }
def "main version" [] { print (hermenix-version) }