arnarg / nixidy

Kubernetes GitOps with nix and Argo CD.
https://arnarg.github.io/nixidy/
MIT License
99 stars 4 forks source link

Can't run nixidy build on macos #18

Closed wokalski closed 3 weeks ago

wokalski commented 3 weeks ago

I have a remote linux builder set up so it's not a big deal but currently it's not possible to run nixidy build on my laptop. It fails with:

trace: warning: The type `types.string` is deprecated. See https://github.com/NixOS/nixpkgs/pull/66346 for better alternative types.
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'nixidy-environment-sandbox-tests'
         whose name attribute is located at /nix/store/0fnka2dn3p1hpy2ls3xraai45nlpmrx9-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'paths' of derivation 'nixidy-environment-sandbox-tests'

         at /nix/store/0alzw54kr6qam4hqfs4mhf6ryd3l46ns-source/modules/build.nix:96:11:

           95|           name = "nixidy-environment-${envName}";
           96|           paths = [
             |           ^
           97|             joined

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Package ‘busybox-1.36.1’ in /nix/store/0fnka2dn3p1hpy2ls3xraai45nlpmrx9-source/pkgs/os-specific/linux/busybox/default.nix:163 is not available on the requested hostPlatform:
         hostPlatform.config = "aarch64-apple-darwin"
         package.meta.platforms = [
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "loongarch64-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mips-linux"
           "mips64-linux"
           "mips64el-linux"
           "mipsel-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
         ]
         package.meta.badPlatforms = [ ]
       , refusing to evaluate.

workaround: nix build ".#nixidyEnvs.x86_64-linux.pl-3.environmentPackage"

mrtz-j commented 3 weeks ago

I've come across a similar error on macOS, and I think I've figured out why it's happening. It looks like it's related to how nix-helm handles charts. I've found that it builds just fine if I comment out the charts part from mkEnv.

arnarg commented 3 weeks ago

Unfortunately I don't have a darwin machine to debug this. It'd be great if someone who does could take a look at this.

wokalski commented 3 weeks ago

@mrtz-j i'm happy to take a look at it to fix it but it'd be much easier if you share your patch with me so that I can at least trace what's going on. Based on that error I pasted it was hard for me to understand the real reason.

arnarg commented 3 weeks ago

Manually running the nix build command that the nixidy cli wrapper runs with --show-trace appended might provide more info.

mrtz-j commented 3 weeks ago

I was able to track it down to helm.releases in modules/applications/helm.nix. When I commented out that part of my application, the nixidy switch worked.

arnarg commented 3 weeks ago

Could either of you provide a full stack trace by manually running the nix build with --show-trace? Maybe I can see any clues as to what needs to be fixed.

mrtz-j commented 3 weeks ago

I've attached a full stack trace from the following command nix -Lv --show-trace build .#nixidyEnvs.aarch64-darwin.prod.environmentPackage here: trace.txt

arnarg commented 3 weeks ago

fromYAML in nix-kube-generators uses busybox seems like :/

https://github.com/farcaller/nix-kube-generators/blob/master/lib/default.nix#L11

In the short term we could bring our own implementation in nixidy as I want it to work on Mac OS too.

arnarg commented 3 weeks ago

yq doesn't even need to be piped into so this should be fairly simple.

https://github.com/kislyuk/yq?tab=readme-ov-file#synopsis

arnarg commented 3 weeks ago

I created a new branch fix/from-yaml that fixes the function implementation in nixidy. It passes lib and module tests but could you try it on mac os?

https://github.com/arnarg/nixidy/tree/fix/from-yaml

mrtz-j commented 3 weeks ago

Yay, the fix works on aarch64-darwin. I was able to successfully generate the resources for a chart.

arnarg commented 3 weeks ago

Awesome! I merged it to main now. Thanks for the help with debugging.

mrtz-j commented 3 weeks ago

No problem, thanks for the quick fix.