From 09543fbe13c05c28839967700e1abc168880beeb Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 13 Jun 2025 00:17:09 -0500 Subject: [PATCH] Fix discovering home-manager paths --- pkgs/gen-build/gen-build.go | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/pkgs/gen-build/gen-build.go b/pkgs/gen-build/gen-build.go index e09a818..7db1aeb 100644 --- a/pkgs/gen-build/gen-build.go +++ b/pkgs/gen-build/gen-build.go @@ -41,6 +41,22 @@ func GetNixFlakeOutput() (*NixFlakeOutput, error) { return &flakeOutput, nil } +func GetNixHomeManagerOutput() ([]string, error) { + cmd := exec.Command("nix", "eval", ".#homeConfigurations", "--apply", "hconf: builtins.filter (name: hconf.${name}.pkgs.hostPlatform.isLinux) (builtins.attrNames hconf)", "--json") + output, err := cmd.Output() + if err != nil { + return nil, err + } + + var result []string + err = json.Unmarshal(output, &result) + if err != nil { + return nil, err + } + + return result, nil +} + type GitlabCIJob struct { Stage string `json:"stage"` Tags []string `json:"tags"` @@ -73,12 +89,16 @@ func main() { "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.\"greg\".activationPackage") + + if flakeOutput.HomeConfigurations != nil { + homeNames, err := GetNixHomeManagerOutput() + if err != nil { + panic(err) + } + for i := range homeNames { + pipeline["Build Home Configuration "+homeNames[i]] = NewGitlabCIJob("homeConfigurations.\"" + homeNames[i] +"\".activationPackage") + } + } if flakeOutput.Apps != nil { for appName := range flakeOutput.Apps {