mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-30 12:10:43 -06:00
Compare commits
1 commit
6517ac3514
...
ca58a68a3f
Author | SHA1 | Date | |
---|---|---|---|
ca58a68a3f |
7 changed files with 12 additions and 57 deletions
|
@ -1,6 +1,6 @@
|
||||||
inputs:
|
inputs:
|
||||||
let
|
let
|
||||||
inherit (inputs) nixpkgs self zig2nix;
|
inherit (inputs) nixpkgs self;
|
||||||
lib = nixpkgs.lib.extend (import ./extended.nix);
|
lib = nixpkgs.lib.extend (import ./extended.nix);
|
||||||
|
|
||||||
inherit (builtins)
|
inherit (builtins)
|
||||||
|
@ -53,7 +53,7 @@ rec {
|
||||||
|
|
||||||
oizysHosts = mapAttrs (name: _: mkSystem name) (readDir ../hosts);
|
oizysHosts = mapAttrs (name: _: mkSystem name) (readDir ../hosts);
|
||||||
oizysPkg = forAllSystems (pkgs: rec {
|
oizysPkg = forAllSystems (pkgs: rec {
|
||||||
oizys-zig = pkgs.callPackage ../pkgs/oizys/oizys-zig { inherit zig2nix; };
|
oizys-zig = pkgs.callPackage ../pkgs/oizys/oizys-zig { zig2nix = inputs.zig2nix; };
|
||||||
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 { };
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::{CommandFactory, Parser, Subcommand};
|
use clap::{CommandFactory, Parser, Subcommand};
|
||||||
use clap_complete::{generate, Generator, Shell};
|
use clap_complete::{generate, Generator, Shell};
|
||||||
use spinoff::{spinners, Color, Spinner};
|
|
||||||
use std::{env, io, path::PathBuf, process::Command};
|
use std::{env, io, path::PathBuf, process::Command};
|
||||||
|
use spinoff::{spinners, Color, Spinner};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
|
@ -62,25 +62,6 @@ struct Oizys {
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trim_hashes(buf: &str, trim_drv: bool) -> Vec<String> {
|
|
||||||
buf.lines()
|
|
||||||
.skip(1)
|
|
||||||
.map(|line| {
|
|
||||||
line.split_once('-')
|
|
||||||
.map(|x| {
|
|
||||||
format!(" {}", {
|
|
||||||
if trim_drv {
|
|
||||||
x.1.replace(".drv", "")
|
|
||||||
} else {
|
|
||||||
x.1.to_string()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.expect("failed to trim derivation")
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Oizys {
|
impl Oizys {
|
||||||
fn from(cli: &Cli) -> Oizys {
|
fn from(cli: &Cli) -> Oizys {
|
||||||
let host = cli
|
let host = cli
|
||||||
|
@ -113,21 +94,17 @@ impl Oizys {
|
||||||
|
|
||||||
fn parse_dry_output(self: &Oizys, output: &str) {
|
fn parse_dry_output(self: &Oizys, output: &str) {
|
||||||
let parts: Vec<&str> = output.split("\nthese").collect();
|
let parts: Vec<&str> = output.split("\nthese").collect();
|
||||||
// TODO: handle more cases of output
|
|
||||||
// currently fails if nothing to fetch
|
|
||||||
if parts.len() != 3 {
|
if parts.len() != 3 {
|
||||||
eprintln!("couldn't parse dry output into three parts");
|
eprintln!("couldn't parse dry output into three parts");
|
||||||
eprintln!("{}", output);
|
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
let to_build: Vec<String> = trim_hashes(parts[1], true);
|
let to_build: Vec<&str> = parts[1].lines().skip(1).collect();
|
||||||
let to_fetch: Vec<String> = trim_hashes(parts[2], false);
|
let to_fetch: Vec<&str> = parts[2].lines().skip(1).collect();
|
||||||
|
println!("To build: {}", to_build.len());
|
||||||
|
println!("To fetch: {}",to_fetch.len());
|
||||||
if self.verbose > 0 {
|
if self.verbose > 0 {
|
||||||
println!("TO BUILD: {}\n{}\n", to_build.len(), to_build.join("\n"));
|
println!("TO BUILD: \n{}\n", to_build.join("\n"));
|
||||||
println!("TO FETCH: {}\n{}\n", to_fetch.len(), to_fetch.join("\n"));
|
println!("TO FETCH: \n{}\n", to_fetch.join("\n"));
|
||||||
} else {
|
|
||||||
println!("To build: {}", to_build.len());
|
|
||||||
println!("To fetch: {}", to_fetch.len());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,12 +119,7 @@ impl Oizys {
|
||||||
let output = String::from_utf8(cmd.output().expect("failed to run nix build").stderr)
|
let output = String::from_utf8(cmd.output().expect("failed to run nix build").stderr)
|
||||||
.expect("faild to parse nix build --dry-run output");
|
.expect("faild to parse nix build --dry-run output");
|
||||||
spinner.stop_with_message("evaluating finished");
|
spinner.stop_with_message("evaluating finished");
|
||||||
|
self.parse_dry_output(&output);
|
||||||
if output.contains("derivations will be built") {
|
|
||||||
self.parse_dry_output(&output);
|
|
||||||
} else {
|
|
||||||
println!("{} up to date", self.host)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(self: &Oizys) {
|
fn build(self: &Oizys) {
|
||||||
|
|
|
@ -11,8 +11,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
exe.root_module.addImport("yazap", b.dependency("yazap", .{}).module("yazap"));
|
exe.root_module.addImport("yazap", b.dependency("yazap", .{ .target = target }).module("yazap"));
|
||||||
exe.root_module.addImport("donuts", b.dependency("donuts", .{}).module("donuts"));
|
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(exe);
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
.url = "git+https://github.com/prajwalch/yazap.git#341750ff62e3102da4a7f8233920aebace1fc337",
|
.url = "git+https://github.com/prajwalch/yazap.git#341750ff62e3102da4a7f8233920aebace1fc337",
|
||||||
.hash = "1220fa71798c994044a987cbde6e73af76bfc402117a61971ccf48f4af4b7154e8d3",
|
.hash = "1220fa71798c994044a987cbde6e73af76bfc402117a61971ccf48f4af4b7154e8d3",
|
||||||
},
|
},
|
||||||
.donuts = .{
|
|
||||||
.url = "git+https://github.com/daylinmorgan/donuts.git#b454b9c1fa3084e6d1431f399d133afe31d4235a",
|
|
||||||
.hash = "1220b6bf5f90c96bd9ac86d989aa1afd605522463afa7f8f372cdf24fac65a5eed99",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
.paths = .{""},
|
.paths = .{""},
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,5 @@
|
||||||
"name": "yazap",
|
"name": "yazap",
|
||||||
"url": "git+https://github.com/prajwalch/yazap.git#341750ff62e3102da4a7f8233920aebace1fc337",
|
"url": "git+https://github.com/prajwalch/yazap.git#341750ff62e3102da4a7f8233920aebace1fc337",
|
||||||
"hash": "sha256-nNhFpay+xk0Ix3GAT1fZ2q/bD9AAx7Xkl4X7QxlzK0M="
|
"hash": "sha256-nNhFpay+xk0Ix3GAT1fZ2q/bD9AAx7Xkl4X7QxlzK0M="
|
||||||
},
|
|
||||||
"1220b6bf5f90c96bd9ac86d989aa1afd605522463afa7f8f372cdf24fac65a5eed99": {
|
|
||||||
"name": "donuts",
|
|
||||||
"url": "git+https://github.com/daylinmorgan/donuts.git#b454b9c1fa3084e6d1431f399d133afe31d4235a",
|
|
||||||
"hash": "sha256-q3FcUMdhpiyoqlwj5FbIVdUszeAoYzVFzGTgfWzm/pU="
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ const Oizys = @This();
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const ArgMatches = @import("yazap").ArgMatches;
|
const ArgMatches = @import("yazap").ArgMatches;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const Donuts = @import("donuts").Donuts;
|
|
||||||
|
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
flake: []const u8,
|
flake: []const u8,
|
||||||
|
@ -179,17 +178,10 @@ const DryResult = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn dry(self: *Oizys) !void {
|
pub fn dry(self: *Oizys) !void {
|
||||||
var sp = Donuts(std.io.getStdOut()).init(
|
|
||||||
"evaluating...",
|
|
||||||
.{ .style = .dots },
|
|
||||||
.{},
|
|
||||||
);
|
|
||||||
try sp.start();
|
|
||||||
const cmd_output = try std.ChildProcess.run(.{
|
const cmd_output = try std.ChildProcess.run(.{
|
||||||
.allocator = self.allocator,
|
.allocator = self.allocator,
|
||||||
.argv = &.{ "nix", "build", self.output, "--dry-run" },
|
.argv = &.{ "nix", "build", self.output, "--dry-run" },
|
||||||
});
|
});
|
||||||
try sp.stop(.{ .message = "done." });
|
|
||||||
defer self.allocator.free(cmd_output.stdout);
|
defer self.allocator.free(cmd_output.stdout);
|
||||||
defer self.allocator.free(cmd_output.stderr);
|
defer self.allocator.free(cmd_output.stderr);
|
||||||
var result = try DryResult.parse(self.allocator, cmd_output.stderr);
|
var result = try DryResult.parse(self.allocator, cmd_output.stderr);
|
||||||
|
|
|
@ -24,4 +24,5 @@ pub fn main() !void {
|
||||||
var oizys = try Oizys.init(allocator, cli.matches, cli.forward);
|
var oizys = try Oizys.init(allocator, cli.matches, cli.forward);
|
||||||
defer oizys.deinit();
|
defer oizys.deinit();
|
||||||
try oizys.run();
|
try oizys.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue