diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a3b6eae --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +stages: + - eval + - build + +default: + tags: + - nix + +"Evaluate for builds": + stage: eval + artifacts: + paths: + - gitlab-ci-continue.yml + script: nix run ".#gen-build" > gitlab-ci-continue.yml + +"Trigger builds": + stage: build + trigger: + include: + - artifact: gitlab-ci-continue.yml + job: "Evaluate for builds" + variables: + PARENT_PIPELINE_ID: $CI_PIPELINE_ID diff --git a/flake.nix b/flake.nix index 50708c4..6b55233 100644 --- a/flake.nix +++ b/flake.nix @@ -66,7 +66,7 @@ top.agenix.overlays.default local_overlay packages_overlay - top.nurpkgs.overlay + top.nurpkgs.overlays.default top.vsext.overlays.default ]; diff --git a/hosts/genesis/home-assistant.nix b/hosts/genesis/home-assistant.nix index 529122c..851d9d3 100755 --- a/hosts/genesis/home-assistant.nix +++ b/hosts/genesis/home-assistant.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: { virtualisation.podman.enable = true; @@ -28,7 +28,7 @@ "zwave_js" ]; customComponents = with pkgs.home-assistant-custom-components; [ - pkgs.python3.pkgs.daikinone + config.services.home-assistant.package.python.pkgs.daikinone nest_protect smartthinq-sensors ]; diff --git a/hosts/jude/default.nix b/hosts/jude/default.nix index d3afdf6..dddb0b2 100644 --- a/hosts/jude/default.nix +++ b/hosts/jude/default.nix @@ -107,6 +107,7 @@ pulse.enable = true; wireplumber.enable = true; }; + pulseaudio.enable = false; # This conflicts with pipewire locate.enable = true; xserver.videoDrivers = [ "nvidia" ]; }; @@ -117,7 +118,6 @@ nvidiaSettings = true; open = true; }; - pulseaudio.enable = false; # This conflicts with pipewire system76 = { firmware-daemon.enable = true; #kernel-modules.enable = true; diff --git a/hosts/jude/virt.nix b/hosts/jude/virt.nix index d991ed7..0b94f07 100644 --- a/hosts/jude/virt.nix +++ b/hosts/jude/virt.nix @@ -39,7 +39,7 @@ in ("vfio-pci.ids=" + (lib.concatStringsSep "," passthru)) ]; }; - hardware.opengl.enable = true; + hardware.graphics.enable = true; services.gitlab-runner = { enable = true; diff --git a/pkgs/default.nix b/pkgs/default.nix index f5ae755..2e2bf19 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -10,9 +10,10 @@ in aacs = c ./aacs.nix { }; brew = c ./homebrew.nix { }; create_ssl = c ./create_ssl.nix { }; + gen-build = c ./gen-build { }; + hms = c ./hms { }; inject-darwin = c ./inject-darwin.nix { }; inject = c ./inject.nix { }; - hms = c ./hms { }; qemu-hook = c ./qemu-hook.nix { }; setup-ssh = c ./setup-ssh { }; upgrade-pg-cluster = c ./upgrade-pg-cluster.nix { }; diff --git a/pkgs/gen-build/default.nix b/pkgs/gen-build/default.nix new file mode 100644 index 0000000..aec3f7c --- /dev/null +++ b/pkgs/gen-build/default.nix @@ -0,0 +1,14 @@ +{ + buildGoModule, +}: +let + src = ./.; +in +buildGoModule { + inherit src; + name = "gen-build"; + + vendorHash = "sha256-g+yaVIx4jxpAQ/+WrGKxhVeliYx7nLQe/zsGpxV4Fn4="; + + meta.mainProgram = "main"; +} diff --git a/pkgs/gen-build/gen-build.go b/pkgs/gen-build/gen-build.go new file mode 100644 index 0000000..f06fcb0 --- /dev/null +++ b/pkgs/gen-build/gen-build.go @@ -0,0 +1,109 @@ +package main + +import ( + "encoding/json" + "fmt" + "os/exec" + + "gopkg.in/yaml.v3" +) + +type NixFlakeOutput struct { + Apps map[string]interface{} `json:"apps"` + Checks map[string]interface{} `json:"checks"` + DarwinConfigurations ArchTypes `json:"darwinConfigurations"` + DevShells map[string]interface{} `json:"devShells"` + HomeConfigurations map[string]interface{} `json:"homeConfigurations"` + NixosConfigurations map[string]interface{} `json:"nixosConfigurations"` + Packages ArchTypes `json:"packages"` +} + +type ArchTypes struct { + X86_64 map[string]map[string]string `json:"x86_64-linux"` + Aarch64 map[string]map[string]string `json:"aarch64-linux"` + DarwinX86 map[string]map[string]string `json:"x86_64-darwin"` + DarwinArm map[string]map[string]string `json:"aarch64-darwin"` +} + +func GetNixFlakeOutput() (*NixFlakeOutput, error) { + cmd := exec.Command("nix", "flake", "show", "--json") + output, err := cmd.Output() + if err != nil { + return nil, err + } + + var flakeOutput NixFlakeOutput + err = json.Unmarshal(output, &flakeOutput) + if err != nil { + return nil, err + } + + return &flakeOutput, nil +} + +type GitlabCIJob struct { + Stage string `json:"stage"` + Tags []string `json:"tags"` + Script []string `json:"script"` +} + +func NewGitlabCIJob(target string) GitlabCIJob { + return GitlabCIJob{ + Stage: "build", + Tags: []string{"nix"}, + Script: []string{ + "nix build -L '.#" + target + "'", + }, + } +} + +func main() { + flakeOutput, err := GetNixFlakeOutput() + if err != nil { + panic(err) + } + + // Some boilerplate that Go requires us to have + pipeline := make(map[string]interface{}) + pipeline["stages"] = []string{"build"} + pipeline["Run flake check"] = GitlabCIJob{ + Stage: "build", + Tags: []string{"nix"}, + Script: []string{ + "nix flake check --no-build", + }, + } + // Since this is kinda a one-off thing, I can use this directly + // homeConfigurations are treated like they are not known as a + // flake output type. Therefore, it just informs you that it is + // part of the output, but does not evaluate deeper to tell you + // what the name of it is. I will just do this manually for now. + pipeline["Build Home config "] = NewGitlabCIJob("homeConfigurations.\"gregory.hellings\".activationPackage") + + if flakeOutput.Apps != nil { + for appName := range flakeOutput.Apps { + pipeline[appName] = NewGitlabCIJob("apps." + appName) + } + } + + if flakeOutput.Packages.X86_64 != nil { + for pkgName := range flakeOutput.Packages.X86_64 { + if flakeOutput.Packages.X86_64[pkgName]["type"] == "derivation" { + pipeline["Build package "+pkgName] = NewGitlabCIJob("packages.x86_64-linux." + pkgName) + } + } + } + + if flakeOutput.NixosConfigurations != nil { + for configName := range flakeOutput.NixosConfigurations { + pipeline["Build NixOS config "+configName] = NewGitlabCIJob("nixosConfigurations." + configName + ".config.system.build.toplevel") + } + } + + yamlData, err := yaml.Marshal(pipeline) + if err != nil { + panic(err) + } + + fmt.Printf("%s\n", yamlData) +} diff --git a/pkgs/gen-build/go.mod b/pkgs/gen-build/go.mod new file mode 100644 index 0000000..d14d21e --- /dev/null +++ b/pkgs/gen-build/go.mod @@ -0,0 +1,5 @@ +module main + +go 1.23.4 + +require gopkg.in/yaml.v3 v3.0.1 diff --git a/pkgs/gen-build/go.sum b/pkgs/gen-build/go.sum new file mode 100644 index 0000000..a62c313 --- /dev/null +++ b/pkgs/gen-build/go.sum @@ -0,0 +1,4 @@ +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=