Compare commits

..

No commits in common. "1077cace3d87e546d89e3450c45d7baeaf3322f2" and "7cc6a8d1fd2c0cab818638436ba42289ce1151be" have entirely different histories.

6 changed files with 50 additions and 183 deletions

View file

@ -5,7 +5,7 @@ inputs:
purge-packages: purge-packages:
description: whether to remove apt packages description: whether to remove apt packages
required: false required: false
default: 'false' default: 'true'
apt-manifest-url: apt-manifest-url:
description: url to apt-package manifest (default ubuntu-22.04.4) description: url to apt-package manifest (default ubuntu-22.04.4)
required: false required: false

View file

@ -54,7 +54,7 @@ jobs:
for host in ${{ inputs.hosts }}; do for host in ${{ inputs.hosts }}; do
nix run . \ nix run . \
-- \ -- \
build --minimal \ build --system-path \
--host "$host" \ --host "$host" \
--flake . \ --flake . \
--verbose \ --verbose \

View file

@ -305,11 +305,11 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1719164993, "lastModified": 1719150233,
"narHash": "sha256-FABhTnL6CBNrvsHVrEXWYoH+zrNfA4yPmgorQupUSZo=", "narHash": "sha256-HOt6FGQdTRIitp5agm3tnZ/4OYM6RG6KOm3UGMntlrY=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "8a68199a0ceb2894a5d9cc300961c38123ac0312", "rev": "e09addf8dede9a8e7f2dd0e5bb414d3a0d5dc471",
"revCount": 4879, "revCount": 4878,
"submodules": true, "submodules": true,
"type": "git", "type": "git",
"url": "https://github.com/hyprwm/Hyprland/" "url": "https://github.com/hyprwm/Hyprland/"
@ -538,11 +538,11 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1719227224, "lastModified": 1719073535,
"narHash": "sha256-zvi2YfvlOLtui2JFhPs2qybpnJR3/2luMfp8t/eMh54=", "narHash": "sha256-G3LQrKVR5J31hpM8iFMHPchj7HRu0hcLarqLAyRALsI=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nix-eval-jobs", "repo": "nix-eval-jobs",
"rev": "32071eb9635dbe0e1e8fc750ea1aac6808272018", "rev": "630134d3ee9f33caef30b658537463053e9cfde2",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -625,11 +625,11 @@
"nixpkgs": "nixpkgs_4" "nixpkgs": "nixpkgs_4"
}, },
"locked": { "locked": {
"lastModified": 1719220171, "lastModified": 1718710563,
"narHash": "sha256-xywM6JoGT8AwfoOFJBTv8GRlvNu8LYqqqMS/OQ6uCgE=", "narHash": "sha256-O4rrM0Bkh3IRe8D600iniQ52QTmlnuTSp2KyXV7C2jE=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NixOS-WSL", "repo": "NixOS-WSL",
"rev": "269411cfed6aab694e46f719277c972de96177bb", "rev": "2fb93bea657ad99a7005ef601c67cb2820560a41",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -677,11 +677,11 @@
"nixpkgs": "nixpkgs_7" "nixpkgs": "nixpkgs_7"
}, },
"locked": { "locked": {
"lastModified": 1719246077, "lastModified": 1719149508,
"narHash": "sha256-ZE+7chVVT/WQ9pfu8qfnR+Y3++LZQ3wUpj5pe1F4rv4=", "narHash": "sha256-Hg8vaExQUf4Lu9CGi1A6Bp3w33Rw4GRna4OQupSPdHs=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixpkgs-wayland", "repo": "nixpkgs-wayland",
"rev": "2bdc10495e152111b53643745450116ffae5b0aa", "rev": "2306a407a29c9358b63723746eeb849215cb6cb6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -724,11 +724,11 @@
}, },
"nixpkgs_4": { "nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1718835956, "lastModified": 1718437845,
"narHash": "sha256-wM9v2yIxClRYsGHut5vHICZTK7xdrUGfrLkXvSuv6s4=", "narHash": "sha256-ZT7Oc1g4I4pHVGGjQFnewFVDRLH5cIZhEzODLz9YXeY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "dd457de7e08c6d06789b1f5b88fc9327f4d96309", "rev": "752c634c09ceb50c45e751f8791cb45cb3d46c9e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -849,11 +849,11 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1719241025, "lastModified": 1719110062,
"narHash": "sha256-EV39oqCYrE1JXZTCSG20AULpOFqpmuHyGy1u5Nhg6Io=", "narHash": "sha256-G+CRYQHhSP49ZG0mrYdDziFFtBxpNVk7BwI/k14kK8U=",
"owner": "roc-lang", "owner": "roc-lang",
"repo": "roc", "repo": "roc",
"rev": "d47a073634e79d2db69a67fd08a12b714d46b514", "rev": "794c20956de5f22019fe1bf1cad6bf7b738add52",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -908,11 +908,11 @@
}, },
"stable": { "stable": {
"locked": { "locked": {
"lastModified": 1719122173, "lastModified": 1718811006,
"narHash": "sha256-aEMsNUtqSPwn6l+LIZ/rX++nCgun3E9M3uSZs6Rwb7w=", "narHash": "sha256-0Y8IrGhRmBmT7HHXlxxepg2t8j1X90++qRN3lukGaIk=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "906320ae02f769d13a646eb3605a9821df0d6ea2", "rev": "03d771e513ce90147b65fe922d87d3a0356fc125",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1147,11 +1147,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1719192015, "lastModified": 1719105765,
"narHash": "sha256-6hrQt6y+P0qV/VkJQ4n4bZSaZLJNYXrKecS6B1xb9Wk=", "narHash": "sha256-tzjig1Sw3DsdoDIgPu8UFiPwK9HwUWuTghHT3xF8XN0=",
"owner": "Cloudef", "owner": "Cloudef",
"repo": "zig2nix", "repo": "zig2nix",
"rev": "048bebf58984486cf45c5e4119f4b149f27d7f1f", "rev": "32560c3060464003e122a732d563f4018e860f27",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1171,11 +1171,11 @@
"zig-overlay": "zig-overlay" "zig-overlay": "zig-overlay"
}, },
"locked": { "locked": {
"lastModified": 1719164948, "lastModified": 1719052215,
"narHash": "sha256-pXgziR7uWaDY18yCEXltcOExgdcHPReH0r/vmphnMoE=", "narHash": "sha256-kWL4LzPps7U/s5n+mQwA80IdRK0gMFhwyGN7Lvx/DyE=",
"owner": "zigtools", "owner": "zigtools",
"repo": "zls", "repo": "zls",
"rev": "9a37d38c2444e39a988f3970b04baae6b5aee61b", "rev": "2e5a2a5959c0ba645fd6bfbf93dc467c32458465",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -22,15 +22,12 @@
} }
]; ];
# deprecated? hardware.opengl = enabled // {
# hardware.opengl = enabled // { driSupport = true;
# driSupport = true; driSupport32Bit = true;
# driSupport32Bit = true; extraPackages = with pkgs; [ libGL ];
# extraPackages = with pkgs; [ libGL ]; setLdLibraryPath = true;
# setLdLibraryPath = true; };
# };
# Load nvidia driver for Xorg and Wayland # Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = [ "nvidia" ]; services.xserver.videoDrivers = [ "nvidia" ];

View file

@ -8,15 +8,12 @@ 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(nom, minimal, args...) oizys.NixBuild(nom, args...)
}, },
} }
var minimal bool
func init() { func init() {
rootCmd.AddCommand(buildCmd) rootCmd.AddCommand(buildCmd)
buildCmd.Flags().BoolVar(&nom, "nom", false, "display result with nom") buildCmd.Flags().BoolVar(&nom, "nom", false, "display result with nom")
// buildCmd.Flags().BoolVar(&systemPath, "system-path", false, "build system path derivation") buildCmd.Flags().BoolVar(&systemPath, "system-path", false, "build system path derivation")
buildCmd.Flags().BoolVar(&minimal, "minimal", false, "use system dry-run to make build args")
} }

View file

@ -7,7 +7,6 @@ import (
"io/fs" "io/fs"
"os" "os"
"os/exec" "os/exec"
"sort"
"strings" "strings"
"time" "time"
@ -71,11 +70,13 @@ func parseSystemPath(derivation map[string]Derivation) (string, error) {
func (o *Oizys) getSystemPath() string { func (o *Oizys) getSystemPath() string {
cmd := exec.Command("nix", "derivation", "show", o.nixosConfigAttr()) cmd := exec.Command("nix", "derivation", "show", o.nixosConfigAttr())
logCmd(cmd) logCmd(cmd)
// TODO: add spinner?
// cmd.Stderr = os.Stderr
s := nixSpinner(o.host) s := nixSpinner(o.host)
out, err := cmd.Output() out, err := cmd.Output()
s.Stop() s.Stop()
if err != nil { if err != nil {
log.Fatal("failed to evalute nixosConfiguration for system-path.drv", "err", err) log.Fatal(err)
} }
var derivation map[string]Derivation var derivation map[string]Derivation
@ -271,30 +272,6 @@ func parseDryRun(buf string) (*packages, *packages) {
parsePackages(parts[1], "packages to fetch") parsePackages(parts[1], "packages to fetch")
} }
// TODO: Refactor this and above
func parseDryRun2(buf string) ([]string, []string) {
lines := strings.Split(strings.TrimSpace(buf), "\n")
var parts [2][]string
i := 0
for _, line := range lines {
if strings.Contains(line, "fetch") && strings.HasSuffix(line, ":") {
i++
}
if i == 2 {
log.Fatal("failed to parse output", "output", buf)
}
if strings.HasPrefix(line, " ") {
parts[i] = append(parts[i], strings.TrimSpace(line))
}
}
if len(parts[0])+len(parts[1]) == 0 {
log.Info("no changes...")
os.Exit(0)
}
return parts[0], parts[1]
}
func showDryRunResult(nixOutput string, verbose bool) { func showDryRunResult(nixOutput string, verbose bool) {
toBuild, toFetch := parseDryRun(nixOutput) toBuild, toFetch := parseDryRun(nixOutput)
toBuild.show(verbose) toBuild.show(verbose)
@ -341,7 +318,7 @@ func runCommand(cmd *exec.Cmd) {
} }
} }
func (o *Oizys) NixBuild(nom bool, minimal bool, rest ...string) { func (o *Oizys) NixBuild(nom bool, rest ...string) {
var cmdName string var cmdName string
if nom { if nom {
cmdName = "nom" cmdName = "nom"
@ -349,123 +326,19 @@ func (o *Oizys) NixBuild(nom bool, minimal bool, rest ...string) {
cmdName = "nix" cmdName = "nix"
} }
cmd := exec.Command(cmdName, "build") cmd := exec.Command(cmdName, "build")
if o.systemPath {
cmd.Args = append(cmd.Args, fmt.Sprintf("%s^*", o.getSystemPath()))
}
cmd.Args = append(cmd.Args, rest...) cmd.Args = append(cmd.Args, rest...)
if o.resetCache { if o.resetCache {
cmd.Args = append(cmd.Args, "--narinfo-cache-positive-ttl", "0") cmd.Args = append(cmd.Args, "--narinfo-cache-positive-ttl", "0")
} }
// if o.inCI { if o.inCI {
// o.ciPreBuild(cmd) o.ciPreBuild(cmd)
// }
if minimal {
log.Debug("populating args with derivations not already built")
drvs := o.systemPathDrvsToBuild()
if len(drvs) == 0 {
log.Info("nothing to build. exiting...")
os.Exit(0)
} }
cmd.Args = append(cmd.Args, drvs...)
}
runCommand(cmd) runCommand(cmd)
} }
var ignoredMap = stringSliceToMap(
[]string{
"builder.pl",
"profile",
"system-path",
"nixos-install",
"nixos-version",
"nixos-manual-html",
"nixos-configuration-reference-manpage",
"nixos-rebuild",
"nixos-help",
"nixos-generate-config",
"nixos-wsl-version",
"nixos-wsl-welcome-message",
"nixos-wsl-welcome",
// trivial packages
"restic-gdrive",
"gitea",
"lock",
},
)
func drvIsIgnored(drv string) bool {
s := strings.SplitN(strings.Replace(drv, ".drv", "", 1), "-", 2)
_, ok := ignoredMap[s[len(s)-1]]
return ok
}
func stringSliceToMap(slice []string) map[string]struct{} {
hashMap := make(map[string]struct{}, len(slice))
for _, s := range slice {
hashMap[s] = struct{}{}
}
return hashMap
}
func drvsToInputs(derivation map[string]Derivation) []string {
var drvs []string
for _, drv := range derivation {
for name := range drv.InputDrvs {
drvs = append(drvs, name)
}
}
return drvs
}
// v2
func (o *Oizys) systemPathDrvsToBuild() []string {
log.Debug("getting system-path build-only deps")
systemPathDrv := fmt.Sprintf("%s^*", o.getSystemPath())
derivationCmd := exec.Command("nix", "derivation", "show", systemPathDrv)
logCmd(derivationCmd)
output, err := derivationCmd.Output()
if err != nil {
log.Fatal("failed to evaluate", "drv", systemPathDrv)
}
// TODO: abstract this?
var derivation map[string]Derivation
if err := json.Unmarshal(output, &derivation); err != nil {
log.Fatal(err)
}
systemPathInputDrvs := stringSliceToMap(drvsToInputs(derivation))
// get to build packages for full system
systemCmd := exec.Command("nix", "build", o.nixosConfigAttr(), "--dry-run")
logCmd(systemCmd)
result, err := systemCmd.CombinedOutput()
if err != nil {
log.Fatal("failed to dry-run build full system", "err", err)
}
toBuild, _ := parseDryRun2(string(result))
var toActuallyBuild []string
for _, drv := range toBuild {
_, ok := systemPathInputDrvs[drv]
if ok && !drvIsIgnored(drv) {
toActuallyBuild = append(toActuallyBuild, drv)
}
}
drvs := make([]string, len(toActuallyBuild))
for i, pkg := range toActuallyBuild {
drvs[i] = fmt.Sprintf("%s^*", strings.TrimSpace(pkg))
}
return drvs
}
func contains(s []string, search string) bool {
i := sort.SearchStrings(s, search)
return i < len(s) && s[i] == search
}
func (o *Oizys) writeToGithubStepSummary(txt string) { func (o *Oizys) writeToGithubStepSummary(txt string) {
f, err := os.OpenFile(o.githubSummary, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) f, err := os.OpenFile(o.githubSummary, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil { if err != nil {
@ -516,7 +389,7 @@ func (o *Oizys) checkPath(name string) string {
func (o *Oizys) Checks(nom bool, rest ...string) { func (o *Oizys) Checks(nom bool, rest ...string) {
checks := o.getChecks() checks := o.getChecks()
for _, check := range checks { for _, check := range checks {
o.NixBuild(nom, false, o.checkPath(check)) o.NixBuild(nom, o.checkPath(check))
} }
} }