remove dep on pinix for oizys-zig

This commit is contained in:
Daylin Morgan 2024-05-13 10:07:22 -05:00
parent 8f51affe7c
commit 689c594493
Signed by: daylin
GPG key ID: 950D13E9719334AD
3 changed files with 7 additions and 17 deletions

View file

@ -57,7 +57,7 @@ rec {
oizys-nim = pkgs.callPackage ../pkgs/oizys/oizys-nim { }; oizys-nim = pkgs.callPackage ../pkgs/oizys/oizys-nim { };
oizys-rs = pkgs.callPackage ../pkgs/oizys/oizys-rs { }; oizys-rs = pkgs.callPackage ../pkgs/oizys/oizys-rs { };
oizys-go = pkgs.callPackage ../pkgs/oizys/oizys-go { }; oizys-go = pkgs.callPackage ../pkgs/oizys/oizys-go { };
default = oizys-go; default = oizys-zig;
}); });
devShells = forAllSystems (pkgs: { devShells = forAllSystems (pkgs: {
default = pkgs.mkShell { default = pkgs.mkShell {

View file

@ -34,7 +34,6 @@ pub fn init(allocator: Allocator) !Cli {
try subcmd.addArg(Arg.positional("forward", null, null)); try subcmd.addArg(Arg.positional("forward", null, null));
try subcmd.addArg(Arg.singleValueOption("flake", 'f', "path to flake")); try subcmd.addArg(Arg.singleValueOption("flake", 'f', "path to flake"));
try subcmd.addArg(Arg.singleValueOption("host", null, "hostname (default: current host)")); try subcmd.addArg(Arg.singleValueOption("host", null, "hostname (default: current host)"));
try subcmd.addArg(Arg.booleanOption("no-pinix", null, "don't use pinix"));
try oizys.addSubcommand(subcmd.*); try oizys.addSubcommand(subcmd.*);
} }

View file

@ -9,7 +9,6 @@ host: []const u8,
cache_name: []const u8, cache_name: []const u8,
output: []const u8, output: []const u8,
cmd: OizysCmd, cmd: OizysCmd,
no_pinix: bool,
debug: bool = false, debug: bool = false,
forward: ?[][]const u8, forward: ?[][]const u8,
@ -41,7 +40,6 @@ pub fn init(allocator: std.mem.Allocator, matches: *const ArgMatches, forward: ?
), ),
.cmd = std.meta.stringToEnum(OizysCmd, cmd).?, .cmd = std.meta.stringToEnum(OizysCmd, cmd).?,
.cache_name = flags.getSingleValue("cache") orelse "daylin", .cache_name = flags.getSingleValue("cache") orelse "daylin",
.no_pinix = flags.containsArg("no-pinix"),
.forward = forward, .forward = forward,
}; };
} }
@ -52,13 +50,6 @@ pub fn deinit(self: *Oizys) void {
self.allocator.free(self.output); self.allocator.free(self.output);
} }
pub fn nix(self: *Oizys) []const u8 {
return if (self.no_pinix) "nix" else "pix";
}
pub fn nixos_rebuild(self: *Oizys) []const u8 {
return if (self.no_pinix) "nixos-rebuild" else "pixos-rebuild";
}
pub fn getDefaultHostName(allocator: Allocator) ![]const u8 { pub fn getDefaultHostName(allocator: Allocator) ![]const u8 {
var name_buffer: [std.posix.HOST_NAME_MAX]u8 = undefined; var name_buffer: [std.posix.HOST_NAME_MAX]u8 = undefined;
@ -89,8 +80,8 @@ pub fn runNixCmd(self: *Oizys, cmd: NixCmd, argv: []const []const u8) !void {
defer args.deinit(); defer args.deinit();
switch (cmd) { switch (cmd) {
NixCmd.Nix => try args.append(self.nix()), NixCmd.Nix => try args.append("nix"),
NixCmd.NixosRebuild => try args.appendSlice(&.{ "sudo", self.nixos_rebuild() }), NixCmd.NixosRebuild => try args.appendSlice(&.{ "sudo", "nixos-rebuild"}),
} }
try args.appendSlice(argv); try args.appendSlice(argv);
if (self.forward) |fwd| try args.appendSlice(fwd); if (self.forward) |fwd| try args.appendSlice(fwd);
@ -119,10 +110,10 @@ pub fn cache(self: *Oizys) !void {
pub fn run(self: *Oizys) !void { pub fn run(self: *Oizys) !void {
switch (self.cmd) { switch (self.cmd) {
.@"switch" => try self.runNixCmd(NixCmd.NixosRebuild, &.{ "switch", "--flake", self.flake }), .@"switch" => try self.runNixCmd(.NixosRebuild, &.{ "switch", "--flake", self.flake }),
.boot => try self.runNixCmd(NixCmd.NixosRebuild, &.{ "boot", "--flake", self.flake }), .boot => try self.runNixCmd(.NixosRebuild, &.{ "boot", "--flake", self.flake }),
.dry => try self.runNixCmd(NixCmd.Nix, &.{ "build", self.output, "--dry-run" }), .dry => try self.runNixCmd(.Nix, &.{ "build", self.output, "--dry-run" }),
.build => try self.runNixCmd(NixCmd.Nix, &.{ "build", self.output }), .build => try self.runNixCmd(.Nix, &.{ "build", self.output }),
.output => { .output => {
const stdout = std.io.getStdOut().writer(); const stdout = std.io.getStdOut().writer();
try stdout.print("{s}\n", .{self.output}); try stdout.print("{s}\n", .{self.output});