Changes
2 changed files (+60/-0)
-
-
@@ -82,6 +82,12 @@ stdenvNoCC.mkDerivation rec {--require-parameter \ -d "Project directory to bind mount" complete -c ${name} \ --condition "__fish_seen_subcommand_from incus; and __fish_seen_subcommand_from $incus_commands" \ --long flake-dir \ --require-parameter \ -d "Flake directory to readonly mount" complete -c ${name} \ --condition "__fish_seen_subcommand_from incus; and __fish_seen_subcommand_from $incus_commands" \ --long mutable \
-
-
-
@@ -50,6 +50,9 @@ const Options = struct {/// Project directory to bind mount. project_dir: ?[]const u8 = null, /// Flake directory to readonly mount. flake_dir: ?[]const u8 = null, /// Enable container nesting (only container). nesting: bool = true,
-
@@ -147,6 +150,14 @@ const Options = struct {} } if (self.flake_dir) |flake_dir| { try json.objectField("flake"); try json.write(incus.DiskDevice{ .source = flake_dir, .path = "/home/workerbee/flake", }); } try json.endObject(); } };
-
@@ -173,6 +184,17 @@ const help =\\ Project directory to bind mount. To use this option, \\ host and local machine MUST be the same. \\ \\--flake-dir <PATH> \\ Bind a directory containing "flake.nix" and "flake.lock". \\ The bind is readonly, so "flake.lock" has to be generated \\ on the host beforehand, for example by running: \\ \\ $ nix flake update \\ \\ The directory will be available as "~/flake" inside \\ a container. Files other than "flake.nix" and \\ "flake.lock" will be also exposed to the container. \\ \\--mutable <VALUE>[,<VALUE>...] \\ Comma-separated list of directories to disable readonly \\ mount. To prevent unintentional command execution on
-
@@ -293,6 +315,38 @@ pub fn run(allocator: std.mem.Allocator, args: *std.process.ArgIterator) !exit.Ccontinue; } if (std.mem.eql(u8, arg, "--flake-dir")) { const path = args.next() orelse { std.log.err("{s} option requires a value", .{arg}); return .incorrect_usage; }; const realpath = std.fs.cwd().realpathAlloc(allocator, path) catch |err| switch (err) { std.mem.Allocator.Error.OutOfMemory => return .out_of_memory, else => { std.log.err("Failed to resolve path \"{s}\": {t}", .{ path, err }); return .filename_error; }, }; var dir = std.fs.cwd().openDir(path, .{}) catch |err| { std.log.err("Unable to open flake directory: {t}", .{err}); return .dir_open_error; }; defer dir.close(); inline for (&.{ "flake.nix", "flake.lock" }) |filename| { const file = dir.openFile(filename, .{ .mode = .read_only }) catch |err| { std.log.err("Unable to open {s}: {t}", .{ filename, err }); return .incorrect_usage; }; defer file.close(); } options.flake_dir = realpath; continue; } if (std.mem.eql(u8, arg, "--mutable")) { const values = args.next() orelse { std.log.err("{s} option requires a value", .{arg});
-