Skip to content

Commit

Permalink
build(nix): separate develop only flakes with a subflake
Browse files Browse the repository at this point in the history
Inspired by NixOS/nix#6124
  • Loading branch information
EricCrosson committed May 7, 2023
1 parent e939195 commit 1f87151
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use flake
use flake ./nix
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v2

- run: nix flake check
- run: nix flake check ./nix
57 changes: 1 addition & 56 deletions flake.lock

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

23 changes: 0 additions & 23 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
pre-commit-hooks,
}: let
forEachSystem = nixpkgs.lib.genAttrs [
"aarch64-darwin"
Expand All @@ -21,24 +16,6 @@
"x86_64-linux"
];
in {
devShells = forEachSystem (system: let
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
prettier.enable = true;
shellcheck.enable = true;
shfmt.enable = true;
};
};
};
in {
default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (checks.pre-commit-check) shellHook;
};
});

packages = forEachSystem (system: {
default = nixpkgs.legacyPackages.${system}.writeShellApplication {
name = "git-diff-regex";
Expand Down
82 changes: 82 additions & 0 deletions nix/flake.lock

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

42 changes: 42 additions & 0 deletions nix/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
description = "git-diff-regex dev shell";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
pre-commit-hooks,
}: let
forEachSystem = nixpkgs.lib.genAttrs [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
in {
devShells = forEachSystem (system: let
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ../.;
hooks = {
alejandra.enable = true;
prettier.enable = true;
shellcheck.enable = true;
shfmt.enable = true;
};
};
};
in {
default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (checks.pre-commit-check) shellHook;
};
});
};
}

0 comments on commit 1f87151

Please sign in to comment.