Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nix): implement overlays #12

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

feat(nix): implement overlays #12

wants to merge 10 commits into from

Conversation

dminca
Copy link
Owner

@dminca dminca commented Jul 6, 2024

  • setup repo structure
  • configure overlay for 'kluctl' package first; once this works, MVP delivered
  • since this is the initial commit on this feature, it's obviously broken and throwing the following error
error:
       … while evaluating a branch condition

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:125:9:

          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:123:13:

          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

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

       error: function 'anonymous lambda' called without required argument 'pkgs'

       at /nix/store/2cv47br877dpnc9p1cv3x95a27nsidb0-source/overlays/kluctl/default.nix:1:1:

            1| { pkgs, config, lib, ... }:
             | ^
            2|

Resolves: #9
Related:

@dminca dminca self-assigned this Jul 6, 2024
@dminca dminca force-pushed the feat/overlays branch 2 times, most recently from 93a0ab5 to eabf6f5 Compare July 7, 2024 09:04
@dminca dminca marked this pull request as ready for review July 7, 2024 09:09
@dminca
Copy link
Owner Author

dminca commented Jul 7, 2024

Overriding buildGoModule led me to this now NixOS/nixpkgs#86349 , got the hint on Matrix

* setup repo structure
* configure overlay for 'kluctl' package first; once this works, MVP
  delivered
* since this is the initial commit on this feature, it's obviously
  broken and throwing the following error

```sh
error:
       … while evaluating a branch condition

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:125:9:

          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:123:13:

          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

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

       error: function 'anonymous lambda' called without required argument 'pkgs'

       at /nix/store/2cv47br877dpnc9p1cv3x95a27nsidb0-source/overlays/kluctl/default.nix:1:1:

            1| { pkgs, config, lib, ... }:
             | ^
            2|
```

Resolves: #9
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
* this also doesn't fly, throws the same error

error:
       … while evaluating a branch condition

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:125:9:

          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:123:13:

          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

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

       error: function 'anonymous lambda' called without required argument 'pkgs'

       at /nix/store/92vr1hwi6r3yvadis7fdllvqfzb27n4k-source/overlays/kluctl/default.nix:1:1:

            1| { pkgs, config, lib, ... }:
             | ^
            2|

Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
* applied Kevin's trick (thanks Kevin!)
  * https://kevinmacksa.me/post/20240128-nix-develop/

error:
       … while evaluating a branch condition

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:125:9:

          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:123:13:

          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

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

       error: function 'anonymous lambda' called without required argument 'pkgs'

       at /nix/store/689c81khgfny2578misrv97mhf1m1hk6-source/overlays/kluctl/default.nix:1:1:

            1| { pkgs, config, lib, ... }:
             | ^
            2|

Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
* fix the hash
* program is now successfully compiling
  * thanks to Kevin for writing this piece
    * https://kevinmacksa.me/post/20240128-nix-develop/
* if `args` is not consumed by nixpkgs.overlays through the `import`
  function, the following error will be thrown

error:
       … while evaluating a branch condition

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:125:9:

          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin

         at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:123:13:

          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

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

       error: A definition for option `nixpkgs.overlays' is not of type `null or (list of (nixpkgs overlay))'. Definition values:
       - In `/nix/store/263gwwg2y9jxammp2yrrkpjwkqi1bnjv-source/hosts/M-C02FX3JUML85/home.nix': <function>

Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
* `rec` is slow and has a lot of downsides; replace with `let-in`
  expression to avoid other strange issues what I was facing, for
  instance this error was thrown previously

error: hash mismatch in fixed-output derivation '/nix/store/yw5l1d80v05y5bgdmc2yz4r1s2hqfvi7-kluctl-2.25.0-go-modules.drv':
         specified: sha256-EEOVd15f1SK8InSIG+TuVwWibkf+ePJ5AGZpiMD+RaQ=
            got:    sha256-TckT39wQn4dclcYSfxootv1Lw5+iYxY6/wwdUc1+Z6s=
error: 1 dependencies of derivation '/nix/store/f2dpnsp3zh52i5l6iaafrq45wc9370k6-kluctl-2.25.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f98mgwkpz9mq6cf8h34533khik8vy7iq-home-manager-applications.drv' failed to build
error: 1 dependencies of derivation '/nix/store/lqx96ba7yjswfjfmsljb370ppci3hsch-home-manager-fonts.drv' failed to build
error: 1 dependencies of derivation '/nix/store/vrssavvbiyjbiq4yb2psd9yis8zjlyyv-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1cdk98lgzjyybirwq318zcxb81zlbdzh-home-manager-generation.drv' failed to build

* this error is still present with the `let-in` expression ...

Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
* this is a terrible hack but unfortunately it's necessary because
  buildGoModule computes the vendorHash after installing all Go modules
* although overriding the vendorHash works just fine, there's still
  something wrong because the overlay is not applied properly, as per

    kluctl --version
    kluctl version v2.22.1

Resolves:
Related: NixOS/nixpkgs#86349
Signed-off-by: Daniel-Andrei Minca <[email protected]>
Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
* this function was supposed to load all overlays sitting under
  `./overlays/` , turns out it's givig more of a headacke

Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
* even though the overlay is now used and compiled, hitting an infinite
  hashing mismatch issue
    error: hash mismatch in fixed-output derivation '/nix/store/gsdgyx2wdlqlxl555n532vgyn5j5bkhb-kluctl-2.25.1-go-modules.drv':
             specified: sha256-TckT39wQn4dclcYSfxootv1Lw5+iYxY6/wwdUc1+Z6s=
                got:    sha256-iE4fPRq2kalP53AO3YaaqbRMH4Cl6XB5UseJmepoW+4=
    [0/9 built (1 failed), 0.0 MiB DL] building kluctl-2.25.1-go-modules (installPhase): Running phase: installPhase^Z
    error: 1 dependencies of derivation '/nix/store/4x4nz1a1ik137jpmcjaqi1yc9yzpiw6g-kluctl-2.25.1.drv' failed to build
    error: 1 dependencies of derivation '/nix/store/h8yslr3m7vw83z2hsyadxwb380rbm5bc-home-manager-applications.drv' failed to build
    error: 1 dependencies of derivation '/nix/store/p011vblrj14f7qhbdx496d9mak4pdg4s-home-manager-fonts.drv' failed to build
    error: 1 dependencies of derivation '/nix/store/vvwrs9c678wwnypvkzjfxspv1nalmgdc-home-manager-path.drv' failed to build
    error: 1 dependencies of derivation '/nix/store/wc39y38f1pcbz571hp2bp980frf0w7g4-home-manager-generation.drv' failed to build

Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement overlays
1 participant