Compare commits

..

4 commits

Author SHA1 Message Date
1077cace3d
don't purge packages by default 2024-06-24 13:28:32 -05:00
720d12d455
improved cache population 2024-06-24 13:24:24 -05:00
aebda80ff2
remove deprecated option 2024-06-24 13:23:46 -05:00
2c88677922
flake.lock: Update
Flake lock file updates:

• Updated input 'hyprland':
    'git+https://github.com/hyprwm/Hyprland/?ref=refs/heads/main&rev=e09addf8dede9a8e7f2dd0e5bb414d3a0d5dc471' (2024-06-23)
  → 'git+https://github.com/hyprwm/Hyprland/?ref=refs/heads/main&rev=8a68199a0ceb2894a5d9cc300961c38123ac0312' (2024-06-23)
• Updated input 'nixos-wsl':
    'github:nix-community/NixOS-WSL/2fb93bea657ad99a7005ef601c67cb2820560a41' (2024-06-18)
  → 'github:nix-community/NixOS-WSL/269411cfed6aab694e46f719277c972de96177bb' (2024-06-24)
• Updated input 'nixos-wsl/nixpkgs':
    'github:NixOS/nixpkgs/752c634c09ceb50c45e751f8791cb45cb3d46c9e' (2024-06-15)
  → 'github:NixOS/nixpkgs/dd457de7e08c6d06789b1f5b88fc9327f4d96309' (2024-06-19)
• Updated input 'nixpkgs-wayland':
    'github:nix-community/nixpkgs-wayland/2306a407a29c9358b63723746eeb849215cb6cb6' (2024-06-23)
  → 'github:nix-community/nixpkgs-wayland/2bdc10495e152111b53643745450116ffae5b0aa' (2024-06-24)
• Updated input 'nixpkgs-wayland/nix-eval-jobs':
    'github:nix-community/nix-eval-jobs/630134d3ee9f33caef30b658537463053e9cfde2' (2024-06-22)
  → 'github:nix-community/nix-eval-jobs/32071eb9635dbe0e1e8fc750ea1aac6808272018' (2024-06-24)
• Updated input 'roc':
    'github:roc-lang/roc/794c20956de5f22019fe1bf1cad6bf7b738add52' (2024-06-23)
  → 'github:roc-lang/roc/d47a073634e79d2db69a67fd08a12b714d46b514' (2024-06-24)
• Updated input 'stable':
    'github:nixos/nixpkgs/03d771e513ce90147b65fe922d87d3a0356fc125' (2024-06-19)
  → 'github:nixos/nixpkgs/906320ae02f769d13a646eb3605a9821df0d6ea2' (2024-06-23)
• Updated input 'zig2nix':
    'github:Cloudef/zig2nix/32560c3060464003e122a732d563f4018e860f27' (2024-06-23)
  → 'github:Cloudef/zig2nix/048bebf58984486cf45c5e4119f4b149f27d7f1f' (2024-06-24)
• Updated input 'zls':
    'github:zigtools/zls/2e5a2a5959c0ba645fd6bfbf93dc467c32458465' (2024-06-22)
  → 'github:zigtools/zls/9a37d38c2444e39a988f3970b04baae6b5aee61b' (2024-06-23)
2024-06-24 11:36:06 -05:00
6 changed files with 183 additions and 50 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: 'true' default: 'false'
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 --system-path \ build --minimal \
--host "$host" \ --host "$host" \
--flake . \ --flake . \
--verbose \ --verbose \

View file

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

View file

@ -22,12 +22,15 @@
} }
]; ];
hardware.opengl = enabled // { # deprecated?
driSupport = true; # hardware.opengl = enabled // {
driSupport32Bit = true; # driSupport = true;
extraPackages = with pkgs; [ libGL ]; # driSupport32Bit = true;
setLdLibraryPath = true; # extraPackages = with pkgs; [ libGL ];
}; # 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,12 +8,15 @@ 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, args...) oizys.NixBuild(nom, minimal, 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,6 +7,7 @@ import (
"io/fs" "io/fs"
"os" "os"
"os/exec" "os/exec"
"sort"
"strings" "strings"
"time" "time"
@ -70,13 +71,11 @@ 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(err) log.Fatal("failed to evalute nixosConfiguration for system-path.drv", "err", err)
} }
var derivation map[string]Derivation var derivation map[string]Derivation
@ -272,6 +271,30 @@ 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)
@ -318,7 +341,7 @@ func runCommand(cmd *exec.Cmd) {
} }
} }
func (o *Oizys) NixBuild(nom bool, rest ...string) { func (o *Oizys) NixBuild(nom bool, minimal bool, rest ...string) {
var cmdName string var cmdName string
if nom { if nom {
cmdName = "nom" cmdName = "nom"
@ -326,19 +349,123 @@ func (o *Oizys) NixBuild(nom 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 {
@ -389,7 +516,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, o.checkPath(check)) o.NixBuild(nom, false, o.checkPath(check))
} }
} }