srid / nixos-config

KISS NixOS configuration based on Flakes & flake-parts (supports macOS too)
433 stars 17 forks source link

Segfault upon updating `flake-parts` #31

Closed ParetoOptimalDev closed 12 months ago

ParetoOptimalDev commented 1 year ago
git clone https://github.com/srid/nixos-config.git
nix flake lock --update-input flake-parts
nix develop
trace: warning: When invoking flake-parts, it is recommended to pass all the flake output
arguments in the `inputs` parameter. If you only pass `self`, it's not
possible to use the `inputs` module argument in the module `imports`.

Please pass the output function arguments. For example:

    outputs = inputs@{ flake-parts, ... }:
      flake-parts.lib.mkFlake { inherit inputs; } { /* module */ };

To avoid an infinite recursion, *DO NOT* pass `self.inputs` and
*DO NOT* pass `inherit (self) inputs`, but pass the output function
arguments as `inputs` like above.

~~I tried updating it to use that form and managed to get a segmentation fault :disappointed: ~~

So doing the above steps will show that error on both x86_64 linux and darwin-arch64, but on darwin-arch64 it will segfault. I'm assuming because of infinte recursion it warns about? Not sure.

I'm trying to see if I can downgrade to the older seemingly working flake-parts for now.

srid commented 1 year ago

Yea, I see this too (when updating the flake-parts input and switching mkFlake to use "inputs").

❯ nix develop
warning: Git tree '/Users/srid/code/nixos-config' is dirty
evaluating derivation 'git+file:///Users/srid/code/nixos-config#devShells.aarch64-darwin.default'zsh: segmentation fault  nix develop

cc @roberth

roberth commented 1 year ago

Could you try with the environment variable GC_DONT_GC=1?

I'm assuming because of infinte recursion it warns about?

If you make the mkFlake invocation look exactly as suggested, taking inputs from the @-pattern, this does not apply to you.

srid commented 1 year ago

Same error,

❯ GC_DONT_GC=1 nix develop
warning: Git tree '/Users/srid/code/nixos-config' is dirty
evaluating derivation 'git+file:///Users/srid/code/nixos-config#devShells.aarch64-darwin.default'zsh: segmentation fault  GC_DONT_GC=1 nix develop

The issue is only on macOS; Linux works fine.

roberth commented 1 year ago

Based on srid's flake with this patch applied I have some observations evaluating on aarch64-darwin with the latest Nix.

patch ```diff diff --git a/flake.lock b/flake.lock index ceea45e..44dcbd5 100644 --- a/flake.lock +++ b/flake.lock @@ -209,11 +209,11 @@ "nixpkgs-lib": "nixpkgs-lib_2" }, "locked": { - "lastModified": 1668450977, - "narHash": "sha256-cfLhMhnvXn6x1vPm+Jow3RiFAUSCw/l1utktCw5rVA4=", + "lastModified": 1677714448, + "narHash": "sha256-Hq8qLs8xFu28aDjytfxjdC96bZ6pds21Yy09mSC156I=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "d591857e9d7dd9ddbfba0ea02b43b927c3c0f1fa", + "rev": "dc531e3a9ce757041e1afaff8ee932725ca60002", "type": "github" }, "original": { @@ -576,11 +576,11 @@ "nixpkgs-lib_2": { "locked": { "dir": "lib", - "lastModified": 1665349835, - "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=", + "lastModified": 1677407201, + "narHash": "sha256-3blwdI9o1BAprkvlByHvtEm5HAIRn/XPjtcfiunpY7s=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1", + "rev": "7f5639fa3b68054ca0b062866dc62b22c3f11505", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 70a6e9a..480319f 100644 --- a/flake.nix +++ b/flake.nix @@ -41,7 +41,7 @@ }; outputs = inputs@{ self, home-manager, nixpkgs, darwin, ... }: - inputs.flake-parts.lib.mkFlake { inherit (inputs) self; } { + inputs.flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" "aarch64-darwin" ]; imports = [ inputs.flake-root.flakeModule ```
[139] m1@host> GC_DONT_GC=1 ~/result/bin/nix repl                                                                                  ~/nixos-config
Welcome to Nix 2.15.0pre20230307_ba0486f. Type :? for help.

nix-repl> let
            go = as: go as;
          in
          {
            hi = go null;
          }
{ hi = zsh: segmentation fault  GC_DONT_GC=1 ~/result/bin/nix repl
srid commented 1 year ago

I was wrong, this still happens.

srid commented 1 year ago

Note to self: the crash is silent (seems as if nix run succeeded, but check echo $?). This still happens.

roberth commented 1 year ago

You could try a larger stack size with ulimit -s. It could be a stack overflow, which I believe are somewhat rare compared to infinite recursions.

srid commented 1 year ago

Another repro?

https://github.com/srid/nixos-flake/discussions/27#discussioncomment-6653168