aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix147
1 files changed, 68 insertions, 79 deletions
diff --git a/flake.nix b/flake.nix
index d258251..6c5553e 100644
--- a/flake.nix
+++ b/flake.nix
@@ -19,15 +19,8 @@
inputs.nixpkgs.follows = "nixpkgs";
};
- flake-utils.url = "github:numtide/flake-utils";
-
pre-commit-hooks = {
- url = "github:cachix/pre-commit-hooks.nix";
- inputs.nixpkgs.follows = "nixpkgs";
- };
-
- devshell = {
- url = "github:numtide/devshell";
+ url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
@@ -35,87 +28,83 @@
# Output config, or config for NixOS system
outputs =
{
- self,
nixpkgs,
darwin,
- flake-utils,
- pre-commit-hooks,
- devshell,
treefmt-nix,
+ pre-commit-hooks,
...
}@inputs:
- flake-utils.lib.eachDefaultSystem (
- system:
- let
- pkgs = import nixpkgs {
- inherit system;
- overlays = [ devshell.overlays.default ];
+ let
+ system = "aarch64-darwin";
+ pkgs = import nixpkgs { inherit system; };
+ mkSystem = import ./nix/lib/mkSystem.nix { inherit nixpkgs inputs; };
+ treefmtEval = treefmt-nix.lib.evalModule pkgs {
+ projectRootFile = "flake.nix";
+ programs = {
+ nixfmt.enable = true;
+ actionlint.enable = true;
+ deadnix.enable = true;
};
- treefmt = (
- treefmt-nix.lib.mkWrapper pkgs {
- projectRootFile = "flake.nix";
- programs = {
- nixfmt.enable = true;
- actionlint.enable = true;
- deadnix.enable = true;
- just.enable = true;
- };
- }
- );
- in
- {
- checks = {
- pre-commit-check = pre-commit-hooks.lib.${system}.run {
- src = ./.;
- hooks = {
- check-merge-conflicts.enable = true;
- end-of-file-fixer.enable = true;
- treefmt-check = {
- enable = true;
- entry = "${treefmt}/bin/treefmt --fail-on-change";
- pass_filenames = false;
- };
+ };
+ in
+ {
+ # nix fmt
+ formatter.${system} = treefmtEval.config.build.wrapper;
+
+ # nix flake check
+ checks.${system} = {
+ pre-commit-check = inputs.pre-commit-hooks.lib.${pkgs.system}.run {
+ src = ./.;
+ hooks = {
+ actionlint.enable = true;
+ check-merge-conflicts.enable = true;
+ deadnix.enable = true;
+ detect-private-keys.enable = true;
+ end-of-file-fixer.enable = true;
+ mixed-line-endings.enable = true;
+ shellcheck.enable = true;
+ treefmt = {
+ enable = true;
+ entry = "${treefmtEval.config.build.wrapper}/bin/treefmt --ci";
};
+ trim-trailing-whitespace.enable = true;
};
};
+ };
- formatter = treefmt;
+ # my personal MacBook Air
+ darwinConfigurations.mba-m2 = mkSystem "mba-m2" {
+ system = "aarch64-darwin";
+ user = "fcuny";
+ darwin = true;
+ };
- devShells.default = pkgs.devshell.mkShell {
- packages = with pkgs; [
- just
- treefmt
- ];
- devshell.startup.pre-commit.text = self.checks.${system}.pre-commit-check.shellHook;
- env = [
- {
- name = "DEVSHELL_NO_MOTD";
- value = "1";
- }
- ];
- };
+ # work laptop
+ darwinConfigurations.hq-kwny2vh41p = mkSystem "hq-kwny2vh41p" {
+ system = "aarch64-darwin";
+ user = "fcuny";
+ darwin = true;
+ };
- }
- )
- // (flake-utils.lib.eachDefaultSystemPassThrough (
- system:
- let
- mkSystem = import ./nix/lib/mkSystem.nix { inherit nixpkgs inputs; };
- in
- {
- # my personal MacBook Air
- darwinConfigurations.mba-m2 = mkSystem "mba-m2" {
- system = "aarch64-darwin";
- user = "fcuny";
- darwin = true;
- };
-
- # work laptop
- darwinConfigurations.hq-kwny2vh41p = mkSystem "hq-kwny2vh41p" {
- system = "aarch64-darwin";
- user = "fcuny";
- darwin = true;
- };
- }
- ));
+ devShells.${system}.default = pkgs.mkShellNoCC {
+ packages = with pkgs; [
+ git
+ (writeScriptBin "build" ''
+ set -e
+ echo "> Running darwin-rebuild switch..."
+ ${inputs.darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild build --flake .
+ echo "> darwin-rebuild build was successful ✅"
+ echo "> macOS config was successfully applied 🚀"
+ '')
+ (writeScriptBin "switch" ''
+ set -e
+ echo "> Running darwin-rebuild switch..."
+ ${inputs.darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild switch --flake .
+ echo "> darwin-rebuild build was successful ✅"
+ echo "> macOS config was successfully applied 🚀"
+ '')
+ (writeScriptBin "update-deps" "nix flake update --commit-lock-file")
+ ];
+ };
+ };
}