Skip to content

Commit

Permalink
feat: simplify importing logic of the flake (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
aldoborrero authored Nov 14, 2023
1 parent 937779b commit 33580b5
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 270 deletions.
38 changes: 0 additions & 38 deletions checks.nix

This file was deleted.

17 changes: 0 additions & 17 deletions flake-shell.nix

This file was deleted.

86 changes: 32 additions & 54 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 86 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "A reproducible Nix package set for Ethereum clients and utilities";
description = "ethereum.nix / A reproducible Nix package set for Ethereum clients and utilities";

nixConfig = {
extra-substituters = ["https://nix-community.cachix.org"];
Expand All @@ -22,7 +22,6 @@
inputs.nixpkgs-lib.follows = "nixpkgs";
};
flake-root.url = "github:srid/flake-root";
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";

# utils
devshell = {
Expand All @@ -38,29 +37,36 @@
url = "github:srid/devour-flake";
flake = false;
};
lib-extras = {
url = "github:aldoborrero/lib-extras/v0.2.2";
inputs.devshell.follows = "devshell";
inputs.flake-parts.follows = "flake-parts";
inputs.flake-root.follows = "flake-root";
inputs.nixpkgs.follows = "nixpkgs";
inputs.treefmt-nix.follows = "treefmt-nix";
};
};

outputs = inputs @ {
flake-parts,
nixpkgs,
lib-extras,
...
}: let
lib = nixpkgs.lib.extend (final: _: import ./lib.nix final);
lib = nixpkgs.lib.extend (l: _: {
extras = (lib-extras.lib l) // (import ./lib.nix l);
});
in
flake-parts.lib.mkFlake {
inherit inputs;
specialArgs = {inherit lib;};
}
rec {
{
imports = [
inputs.devshell.flakeModule
inputs.flake-parts.flakeModules.easyOverlay
inputs.flake-root.flakeModule
inputs.hercules-ci-effects.flakeModule
inputs.treefmt-nix.flakeModule
./checks.nix
./flake-shell.nix
./formatter.nix
./mkdocs.nix
./modules
./packages
Expand All @@ -71,18 +77,86 @@
"x86_64-darwin"
"aarch64-darwin"
];
perSystem = {system, ...}: {
perSystem = {
config,
pkgs,
pkgsUnstable,
system,
...
}: {
# pkgs
_module.args = {
pkgs = lib.mkNixpkgs {
pkgs = lib.extras.nix.mkNixpkgs {
inherit system;
inherit (inputs) nixpkgs;
};
pkgsUnstable = lib.mkNixpkgs {
pkgsUnstable = lib.extras.nix.mkNixpkgs {
inherit system;
nixpkgs = inputs.nixpkgs-unstable;
};
};

# devshell
devshells.default = {
name = "ethereum.nix";
packages = with pkgsUnstable; [
nix-update
statix
mkdocs
pkgs.python310Packages.mkdocs-material
];
commands = [
{
category = "Tools";
name = "fmt";
help = "Format the source tree";
command = "nix fmt";
}
{
category = "Tools";
name = "check";
help = "Checks the source tree";
command = "nix flake check";
}
];
};

# formatter
treefmt.config = {
inherit (config.flake-root) projectRootFile;
package = pkgs.treefmt;
flakeFormatter = true;
flakeCheck = true;
programs = {
alejandra.enable = true;
deadnix.enable = true;
prettier.enable = true;
statix.enable = true;
};
};

# checks
checks = let
devour-flake = pkgs.callPackage inputs.devour-flake {};
in
{
nix-build-all = pkgs.writeShellApplication {
name = "nix-build-all";
runtimeInputs = [
pkgs.nix
devour-flake
];
text = ''
# Make sure that flake.lock is sync
nix flake lock --no-update-lock-file
# Do a full nix build (all outputs)
devour-flake . "$@"
'';
};
}
# mix in tests
// config.testing.checks;
};
herculesCI.ciSystems = with builtins; filter (system: (match ".*-darwin" system) == null) systems;
};
}
29 changes: 0 additions & 29 deletions formatter.nix

This file was deleted.

Loading

0 comments on commit 33580b5

Please sign in to comment.