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

Introduce flake dev pattern #258

Closed
aldoborrero opened this issue Apr 28, 2023 · 1 comment
Closed

Introduce flake dev pattern #258

aldoborrero opened this issue Apr 28, 2023 · 1 comment
Assignees
Labels
Type: Enhancement Improvements or additions

Comments

@aldoborrero
Copy link
Collaborator

aldoborrero commented Apr 28, 2023

Right now if we run nix flake metadata, we obtain the following output:

Terminal outputs of Inputs
thinkpad-x1 :: Dev/nix-community/ethereum.nix2 ‹feat/devshell*› % nix flake metadata
Resolved URL:  git+file:///home/aldo/Dev/nix-community/ethereum.nix2
Locked URL:    git+file:///home/aldo/Dev/nix-community/ethereum.nix2?ref=refs%2fheads%2ffeat%2fdevshell&rev=21d7880e1e8c95b75209115c7b86c32c7985b714
Description:   A reproducible Nix package set for Ethereum clients and utilities
Path:          /nix/store/q2cn8xv7d4wvv1nrg16ngj57a6ai4jpn-source
Revision:      21d7880e1e8c95b75209115c7b86c32c7985b714
Revisions:     166
Last modified: 2023-04-28 10:27:16
Inputs:
├───devshell: github:numtide/devshell/3e0e60ab37cd0bf7ab59888f5c32499d851edb47
│   ├───flake-utils: github:numtide/flake-utils/846b2ae0fc4cc943637d3d1def4454213e203cba
│   └───nixpkgs follows input 'nixpkgs'
├───flake-compat: github:edolstra/flake-compat/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9
├───flake-parts: github:hercules-ci/flake-parts/dcc36e45d054d7bb554c9cdab69093debd91a0b5
│   └───nixpkgs-lib follows input 'nixpkgs'
├───flake-root: github:srid/flake-root/f1c0b93d05bdbea6c011136ba1a135c80c5b326c
├───foundry-nix: github:shazow/foundry.nix/e3e0951e0cb668e7796f1fde2926ff32dc544d49
│   ├───flake-utils: github:numtide/flake-utils/3cecb5b042f7f209c56ffd8371b2711a290ec797
│   └───nixpkgs follows input 'nixpkgs'
├───hercules-ci-effects: github:hercules-ci/hercules-ci-effects/15ff4f63e5f28070391a5b09a82f6d5c6cc5c9d0
│   ├───flake-parts: github:hercules-ci/flake-parts/c13d60b89adea3dc20704c045ec4d50dd964d447
│   │   └───nixpkgs-lib: github:NixOS/nixpkgs/130fa0baaa2b93ec45523fdcde942f6844ee9f6e?dir=lib
│   ├───hercules-ci-agent: github:hercules-ci/hercules-ci-agent/0b90d1a87c117a5861785cb85833dd1c9df0b6ef
│   │   ├───flake-parts: github:hercules-ci/flake-parts/c13d60b89adea3dc20704c045ec4d50dd964d447
│   │   │   └───nixpkgs-lib follows input 'hercules-ci-effects/hercules-ci-agent/nixpkgs'
│   │   ├───haskell-flake: github:hercules-ci/haskell-flake/1e1660e6dd00838ba73bc7952e6e73be67da18d1
│   │   ├───nix-darwin: github:LnL7/nix-darwin/87b9d090ad39b25b2400029c64825fc2a8868943
│   │   │   └───nixpkgs follows input 'hercules-ci-effects/hercules-ci-agent/nixpkgs'
│   │   ├───nixpkgs: github:NixOS/nixpkgs/c90c4025bb6e0c4eaf438128a3b2640314b1c58d
│   │   └───pre-commit-hooks-nix: github:cachix/pre-commit-hooks.nix/1a20b9708962096ec2481eeb2ddca29ed747770a
│   │       ├───flake-compat: github:edolstra/flake-compat/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9
│   │       ├───flake-utils: github:numtide/flake-utils/5aed5285a952e0b949eb3ba02c12fa4fcfef535f
│   │       ├───gitignore: github:hercules-ci/gitignore.nix/a20de23b925fd8264fd7fad6454652e142fd7f73
│   │       │   └───nixpkgs follows input 'hercules-ci-effects/hercules-ci-agent/pre-commit-hooks-nix/nixpkgs'
│   │       ├───nixpkgs follows input 'hercules-ci-effects/hercules-ci-agent/nixpkgs'
│   │       └───nixpkgs-stable: github:NixOS/nixpkgs/2f9fd351ec37f5d479556cd48be4ca340da59b8f
│   └───nixpkgs: github:NixOS/nixpkgs/1544ef240132d4357d9a39a40c8e6afd1678b052
├───nixpkgs: github:nixos/nixpkgs/4d2b37a84fad1091b9de401eb450aae66f1a741e
├───nixpkgs-unstable: github:nixos/nixpkgs/2362848adf8def2866fabbffc50462e929d7fffb
└───treefmt-nix: github:numtide/treefmt-nix/b25d1a3c2c7554d0462ab1dfddf2f13128638b90
    └───nixpkgs follows input 'nixpkgs'

As we can see from the above output, we export a big amount of inputs derivation that consumers of ethereum.nix doesn't necessarily need, exploding their flake.lock dependencies. Inputs like hercules-ci-effects, treefmt-nix are only internal for development purposes.

We can do better. Speaking with @zimbatm he proposed I should use what he called the flake dev pattern. The idea is quite simplistic:

  • Create another flake for dev purposes with all the current inputs we have.
  • Load that flake with direnv directly.
  • Leave the existing flake with only the necessary inputs needed for consumers but nothing else.

I have proof of concept made on this branch, but a separate PR will be added soon once #257 is merged back to main branch.

This is the issue that introduces this concept natively inside Nix.

@aldoborrero aldoborrero added the Type: Enhancement Improvements or additions label Apr 28, 2023
@aldoborrero aldoborrero self-assigned this Apr 28, 2023
@aldoborrero
Copy link
Collaborator Author

I'll mark this issue as closed for now. We can always get back to the idea if it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improvements or additions
Projects
None yet
Development

No branches or pull requests

1 participant