Skip to content

Set devshell subflake inputs to track parent flake inputs#445

Closed
astratagem wants to merge 4 commits into
mainfrom
devshell-subflake-inputs-fixes
Closed

Set devshell subflake inputs to track parent flake inputs#445
astratagem wants to merge 4 commits into
mainfrom
devshell-subflake-inputs-fixes

Conversation

@astratagem
Copy link
Copy Markdown
Collaborator

@astratagem astratagem commented Mar 30, 2022

Addresses a few issues with the std input and devshell subflake I ran into on macOS while testing #438.

Depends on divnix/std#47

Comment thread devshell/flake.nix
main.url = "path:../.";

# Inherited inputs
nixpkgs.follows = "main/nixpkgs";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need a nixpkgs that follow the main one?

In my reasoning we rather want uncoupled up-to-date tooling for the devshell.

Was your reasoning to increase cache hits?

Copy link
Copy Markdown
Collaborator Author

@astratagem astratagem Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The immediate reason was an error running nix develop --update-input main './devshell#default' --command evalnix on darwin in #438. nixpkgs-unstable breaks on darwin hosts regularly.

In my reasoning we rather want uncoupled up-to-date tooling for the devshell.

That's a good point, and for that reason I tend to use overlays like in https://github.com/divnix/digga/blob/main/examples/devos/overlays/overrides.nix – but that seems to me like it would be better to leave that decision to the user to handle.

AFAIK digga doesn't currently force users to depend on nixpkgs-unstable at all, so this is a pretty significant change. Adding nixpkgs-unstable in a subflake effectively hides that away, especially without documentation.

For reference, here's the error I got on darwin, caused by std's chicken dependency:

❯ nix develop --update-input main './devshell#default' --command evalnix
warning: Git tree '/Users/montchr/Developer/contrib/divnix/digga' is dirty
warning: updating lock file '/Users/montchr/Developer/contrib/divnix/digga/devshell/flake.lock':
• Updated input 'main':
    'path:../.?narHash=sha256-DSQeol3hCIM0ZaSAebmrLHnXcszDy9XScIOCHwEjY6c='
  → 'path:../.?narHash=sha256-9az30Kwl1hiEgi5WloHRE9NUIkCR5CcpHaSE0WJbyAw='
• Added input 'main/darwin':
    'github:montchr/nix-darwin/3bb62d40a2ef5c7c1b5634c58c47dd4a239d7618' (2022-02-28)
• Added input 'main/darwin/nixpkgs':
    follows 'main/latest'
• Updated input 'main/std':
    'github:divnix/std/133fb0c1cc8d0d477a3d339971ef09fa57a60fd3' (2022-03-14)
  → 'github:montchr/std/d6390c705cd8c0c583b95dec77a9c493afd34e19' (2022-03-29)
• Updated input 'main/std/nixpkgs':
    'github:nixos/nixpkgs/3eb07eeafb52bcbf02ce800f032f18d666a9498d' (2022-03-15)
  → 'github:nixos/nixpkgs/30d3d79b7d3607d56546dd2a6b49e156ba0ec634' (2022-03-25)
warning: Git tree '/Users/montchr/Developer/contrib/divnix/digga' is dirty
error: builder for '/nix/store/1lw7b3489as9bniipw27yg687c7ykig8-chicken-5.3.0.drv' failed with exit code 2;
       last 10 log lines:
       > (PASS) (repository-path) contains something by default
       >  TOTALS:
       >   1 tests completed in 0.026 seconds
       >   1 (100.00%) tests passed
       >   0 (0.00%) tests failed
       > /usr/bin/env DYLD_LIBRARY_PATH='/private/tmp/nix-build-chicken-5.3.0.drv-0/chicken-5.3.0/tests/..' /private/tmp/nix-build-chicken-5.3.0.drv-0/chicken-5.3.0/tests/../chicken 'sample-module.scm' -output-file 'sample-module.c' -dynamic -feature chicken-compile-shared -verbose -include-path /private/tmp/nix-build-chicken-5.3.0.drv-0/chicken-5.3.0/tests/.. -consult-types-file ../types.db -ignore-repository -emit-import-library sample-module
       > sh: /usr/bin/env: Operation not permitted
       >
       > Error: shell command terminated with non-zero exit status 32256: /usr/bin/env DYLD_LIBRARY_PATH='/private/tmp/nix-build-chicken-5.3.0.drv-0/chicken-5.3.0/tests/..' /private/tmp/nix-build-chicken-5.3.0.drv-0/chicken-5.3.0/tests/../chicken 'sample-module.scm' -output-file 'sample-module.c' -dynamic -feature chicken-compile-shared -verbose -include-path /private/tmp/nix-build-chicken-5.3.0.drv-0/chicken-5.3.0/tests/.. -consult-types-file ../types.db -ignore-repository -emit-import-library sample-module
       > make: *** [rules.make:1015: check] Error 1
       For full logs, run 'nix log /nix/store/1lw7b3489as9bniipw27yg687c7ykig8-chicken-5.3.0.drv'.
error: 1 dependencies of derivation '/nix/store/fy6anzg4kg985qdsy52ll66mfy9v530n-chicken-5.3.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/15kf3wl5apajs7lvs29542i9w1zhqx8g-std.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2dn2003ccgl8y3iccw68f7flgnmhq29a-devshell-dir.drv' failed to build
error: 1 dependencies of derivation '/nix/store/0696if0xfc8l0ac355lahfvbd57ckj2x-Digga-formerly-DevOS--env.drv' failed to build

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting!

I didn't have this mac compatibility issues with unstable on the screen.

Each invokation of an overlay recalculates the nixpkgs fix-point which adds 130MB roughly of RAM requirement.

They also obfuscate cache potential hits due to the changes fixed point.

It might also be that the original package wasn't built for the different nixpkgs api.

So I'm trying to reduce my use of overlays.

After all, if this increases compatibility, then I'm happy.

Comment thread devshell/flake.nix
devShells.default = devshell.legacyPackages.mkShell (
{extraModulesPath, ...}: {
name = "Digga (formerly DevOS)";
name = "digga-fka-devos";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is due to an old version of devshell 😄. I bothered to do a fix a while ago upstream.

@blaggacao
Copy link
Copy Markdown
Contributor

divnix/std#47 is merged, does this need bumping?

@astratagem
Copy link
Copy Markdown
Collaborator Author

Closing in favor of #444

@astratagem astratagem closed this Mar 30, 2022
@Pacman99 Pacman99 deleted the devshell-subflake-inputs-fixes branch April 5, 2022 19:01
@Pacman99 Pacman99 restored the devshell-subflake-inputs-fixes branch April 5, 2022 19:01
@astratagem astratagem deleted the devshell-subflake-inputs-fixes branch July 9, 2022 21:16
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.

2 participants