mirror of
https://github.com/daylinmorgan/oizys.git
synced 2025-01-22 11:17:33 -06:00
QOL oizys-go
This commit is contained in:
parent
c51da5dacf
commit
0e132b9372
7 changed files with 90 additions and 10 deletions
|
@ -56,7 +56,7 @@ in
|
||||||
oizys-zig = pkgs.callPackage ../pkgs/oizys/oizys-zig { inherit zig2nix; };
|
oizys-zig = pkgs.callPackage ../pkgs/oizys/oizys-zig { inherit 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 { inherit self;};
|
||||||
default = oizys-go;
|
default = oizys-go;
|
||||||
});
|
});
|
||||||
devShells = forAllSystems (pkgs: {
|
devShells = forAllSystems (pkgs: {
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
pkgs.nixd
|
pkgs.nixd
|
||||||
pkgs.nixfmt-rfc-style
|
pkgs.nixfmt-rfc-style
|
||||||
|
pkgs.nix-output-monitor
|
||||||
|
|
||||||
|
|
||||||
self.packages.${pkgs.system}.default
|
self.packages.${pkgs.system}.default
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,11 @@ var buildCmd = &cobra.Command{
|
||||||
Use: "build",
|
Use: "build",
|
||||||
Short: "nix build",
|
Short: "nix build",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
oizys.NixBuild(args...)
|
oizys.NixBuild(nom, args...)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(buildCmd)
|
rootCmd.AddCommand(buildCmd)
|
||||||
|
buildCmd.Flags().BoolVar(&nom, "nom", false, "display result with nom")
|
||||||
}
|
}
|
||||||
|
|
18
pkgs/oizys/oizys-go/cmd/checks.go
Normal file
18
pkgs/oizys/oizys-go/cmd/checks.go
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var checksCmd = &cobra.Command{
|
||||||
|
Use: "checks",
|
||||||
|
Short: "nix build checks",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
oizys.Checks(nom, args...)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(checksCmd)
|
||||||
|
checksCmd.Flags().BoolVar(&nom, "nom", false, "display result with nom")
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ var (
|
||||||
host string
|
host string
|
||||||
cacheName string
|
cacheName string
|
||||||
verbose bool
|
verbose bool
|
||||||
|
nom bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var oizys = o.NewOizys()
|
var oizys = o.NewOizys()
|
||||||
|
|
|
@ -1,14 +1,25 @@
|
||||||
{
|
{
|
||||||
|
self,
|
||||||
lib,
|
lib,
|
||||||
installShellFiles,
|
installShellFiles,
|
||||||
buildGoModule,
|
buildGoModule,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
gh,
|
gh,
|
||||||
|
nix-output-monitor,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
mkDate =
|
||||||
|
longDate:
|
||||||
|
(lib.concatStringsSep "-" [
|
||||||
|
(builtins.substring 0 4 longDate)
|
||||||
|
(builtins.substring 4 2 longDate)
|
||||||
|
(builtins.substring 6 2 longDate)
|
||||||
|
]);
|
||||||
|
in
|
||||||
buildGoModule {
|
buildGoModule {
|
||||||
pname = "oizys";
|
pname = "oizys";
|
||||||
version = "unstable";
|
version = "date=${mkDate self.lastModifiedDate}";
|
||||||
|
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
vendorHash = "sha256-Geqcp0/7I1IF2IfaYyIChz7SOCF+elIEdcz2VsAU0hQ=";
|
vendorHash = "sha256-Geqcp0/7I1IF2IfaYyIChz7SOCF+elIEdcz2VsAU0hQ=";
|
||||||
|
@ -25,6 +36,6 @@ buildGoModule {
|
||||||
|
|
||||||
postFixup = ''
|
postFixup = ''
|
||||||
wrapProgram $out/bin/oizys \
|
wrapProgram $out/bin/oizys \
|
||||||
--prefix PATH ${lib.makeBinPath [ gh ]}
|
--prefix PATH ':' ${lib.makeBinPath [ gh nix-output-monitor ]}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package oizys
|
package oizys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
@ -24,7 +25,6 @@ type Oizys struct {
|
||||||
verbose bool
|
verbose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewOizys() *Oizys {
|
func NewOizys() *Oizys {
|
||||||
hostname, err := os.Hostname()
|
hostname, err := os.Hostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -246,13 +246,59 @@ func runCommand(cmd *exec.Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Oizys) NixBuild(rest ...string) {
|
// func runBuildWithNom(buildCmd *exec.Cmd) {
|
||||||
args := []string{"build", o.Output()}
|
// log.Println("starting build?")
|
||||||
args = append(args, rest...)
|
// nomCmd := exec.Command("nom","--json")
|
||||||
cmd := exec.Command("nix", args...)
|
// var err error
|
||||||
|
// buildCmd.Args = append(buildCmd.Args, "--log-format", "internal-json", "-v")
|
||||||
|
// nomCmd.Stdin, err = buildCmd.StderrPipe()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
// nomCmd.Stdout = os.Stdout
|
||||||
|
// nomCmd.Start()
|
||||||
|
// log.Println("starting buildcmd?")
|
||||||
|
// buildCmd.Run()
|
||||||
|
// nomCmd.Wait()
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (o *Oizys) NixBuild(nom bool, rest ...string) {
|
||||||
|
var cmdName string
|
||||||
|
if nom {
|
||||||
|
cmdName = "nom"
|
||||||
|
} else {
|
||||||
|
cmdName = "nix"
|
||||||
|
}
|
||||||
|
cmd := exec.Command(cmdName, "build")
|
||||||
|
cmd.Args = append(cmd.Args, rest...)
|
||||||
runCommand(cmd)
|
runCommand(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *Oizys) getChecks() []string {
|
||||||
|
attrName := fmt.Sprintf("%s#%s", o.flake, "checks.x86_64-linux")
|
||||||
|
cmd := exec.Command("nix", "eval", attrName, "--apply", "builtins.attrNames", "--json")
|
||||||
|
out, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
var checks []string
|
||||||
|
if err := json.Unmarshal(out, &checks); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
return checks
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Oizys) checkPath(name string) string {
|
||||||
|
return fmt.Sprintf("%s#checks.x86_64-linux.%s", o.flake, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Oizys) Checks(nom bool, rest ...string) {
|
||||||
|
checks := o.getChecks()
|
||||||
|
for _, check := range checks {
|
||||||
|
o.NixBuild(nom, o.checkPath(check))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (o *Oizys) CacheBuild(rest ...string) {
|
func (o *Oizys) CacheBuild(rest ...string) {
|
||||||
args := []string{
|
args := []string{
|
||||||
"watch-exec", o.cache, "--", "nix",
|
"watch-exec", o.cache, "--", "nix",
|
||||||
|
|
Loading…
Reference in a new issue