Skip to content

Commit

Permalink
Merge pull request #446 from toastal/flake-utils-drop
Browse files Browse the repository at this point in the history
Drop `flake-utils` dependency
  • Loading branch information
sandydoo authored May 16, 2024
2 parents 9636469 + 8803a39 commit fa606cc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 67 deletions.
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,30 @@ Given the following `flake.nix` example:
description = "An example project.";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, pre-commit-hooks, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
};
outputs = { self, nixpkgs, ... }@inputs:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
checks = forAllSystems (system: {
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
};
};
devShell = nixpkgs.legacyPackages.${system}.mkShell {
});
devShells = forAllSystems (system: {
default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
};
}
);
});
};
}
```

Expand Down
34 changes: 0 additions & 34 deletions flake.lock

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

39 changes: 20 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.11";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
Expand All @@ -13,7 +12,7 @@
inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, flake-utils, gitignore, nixpkgs-stable, ... }:
outputs = { self, nixpkgs, gitignore, nixpkgs-stable, ... }:
let
lib = nixpkgs.lib;
defaultSystems = [
Expand All @@ -22,6 +21,12 @@
"x86_64-darwin"
"x86_64-linux"
];
depsFor = lib.genAttrs defaultSystems (system: {
pkgs = nixpkgs.legacyPackages.${system};
exposed = import ./nix { inherit nixpkgs system; gitignore-nix-src = gitignore; isFlakes = true; };
exposed-stable = import ./nix { nixpkgs = nixpkgs-stable; inherit system; gitignore-nix-src = gitignore; isFlakes = true; };
});
forAllSystems = fn: lib.genAttrs defaultSystems (system: fn depsFor.${system});
in
{
flakeModule = ./flake-module.nix;
Expand All @@ -32,27 +37,23 @@
A template with flake-parts and nixpkgs-fmt.
'';
};
}
// flake-utils.lib.eachSystem defaultSystems (system:
let
exposed = import ./nix { inherit nixpkgs system; gitignore-nix-src = gitignore; isFlakes = true; };
exposed-stable = import ./nix { nixpkgs = nixpkgs-stable; inherit system; gitignore-nix-src = gitignore; isFlakes = true; };
in
{
packages = exposed.packages // {
default = exposed.packages.pre-commit;
};

devShells.default = nixpkgs.legacyPackages.${system}.mkShell {
packages = forAllSystems ({ exposed, ... }: exposed.packages // {
default = exposed.packages.pre-commit;
});

devShells = forAllSystems ({ pkgs, exposed, ... }: {
default = pkgs.mkShellNoCC {
inherit (exposed.checks.pre-commit-check) shellHook;
};
});

checks = lib.filterAttrs (k: v: v != null)
checks = forAllSystems ({ exposed, exposed-stable, ... }:
lib.filterAttrs (k: v: v != null)
(exposed.checks
// (lib.mapAttrs' (name: value: lib.nameValuePair "stable-${name}" value)
exposed-stable.checks));
// (lib.mapAttrs' (name: value: lib.nameValuePair "stable-${name}" value)
exposed-stable.checks)));

lib = { inherit (exposed) run; };
}
);
lib = forAllSystems ({ exposed, ... }: { inherit (exposed) run; });
};
}

0 comments on commit fa606cc

Please sign in to comment.