🎨 add pre-commit-hooks and cleanup

This commit is contained in:
James Walker 2023-07-26 13:04:43 -04:00
parent 63b05b74b4
commit 35cf87eb2e
Signed by: walkah
GPG Key ID: 3C127179D6086E93
12 changed files with 163 additions and 29 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
result
.direnv
.direnv
/.pre-commit-config.yaml

View File

@ -68,16 +68,14 @@
};
};
system.activationScripts.applications.text = pkgs.lib.mkForce (
''
rm -rf /Applications/Nix
mkdir -p /Applications/Nix
for app in $(find ${config.system.build.applications}/Applications -maxdepth 1 -type l); do
src="$(/usr/bin/stat -f%Y "$app")"
cp -r "$src" /Applications/Nix
done
''
);
system.activationScripts.applications.text = pkgs.lib.mkForce ''
rm -rf /Applications/Nix
mkdir -p /Applications/Nix
for app in $(find ${config.system.build.applications}/Applications -maxdepth 1 -type l); do
src="$(/usr/bin/stat -f%Y "$app")"
cp -r "$src" /Applications/Nix
done
'';
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
_:
{
homebrew = {

View File

@ -1,5 +1,21 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@ -18,6 +34,45 @@
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -25,11 +80,11 @@
]
},
"locked": {
"lastModified": 1690208251,
"narHash": "sha256-eb/KANeuQADVl5j4wVid4jyPCOMTorSI2+gqoXp3LME=",
"lastModified": 1690303752,
"narHash": "sha256-2YiwFHQERGoaORNORmsdmVlPD8CVVwlwbV2+f77sFhg=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "d309a62ee81faec56dd31a263a0184b0e3227e36",
"rev": "ba2c0737cc848db03470828fdb5e86df75ed42a8",
"type": "github"
},
"original": {
@ -40,11 +95,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1690083312,
"narHash": "sha256-I3egwgNXavad1eIjWu1kYyi0u73di/sMmlnQIuzQASk=",
"lastModified": 1690327932,
"narHash": "sha256-Fv7PYZxN4eo0K6zXhHG/vOc+e2iuqQ5ywDrh0yeRjP0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "af8cd5ded7735ca1df1a1174864daab75feeb64a",
"rev": "a9b47d85504bdd199e90846622c76aa0bfeabfac",
"type": "github"
},
"original": {
@ -54,11 +109,52 @@
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1689668210,
"narHash": "sha256-XAATwDkaUxH958yXLs1lcEOmU6pSEIkatY3qjqk8X0E=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "eb433bff05b285258be76513add6f6c57b441775",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"systems": {
@ -75,6 +171,21 @@
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

View File

@ -4,11 +4,18 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, flake-utils, ... }:
outputs = { self, nixpkgs, home-manager, flake-utils, pre-commit-hooks, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]
(system:
let pkgs = nixpkgs.legacyPackages.${system};
@ -28,12 +35,28 @@
packages.default =
self.homeConfigurations.${system}.walkah.activationPackage;
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
deadnix.enable = true;
nixpkgs-fmt.enable = true;
statix.enable = true;
};
};
};
devShells.default = pkgs.mkShell {
name = "dotfiles";
buildInputs = with pkgs; [
deadnix
nil
nixpkgs-fmt
statix
];
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
});
}

View File

@ -1,4 +1,4 @@
{ config, pkgs, ... }: {
{ pkgs, ... }: {
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ ... }:
{
imports = [

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
_:
{
home.file.".ghci".text = ''

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ pkgs, ... }:
{
home.packages = with pkgs; [

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
_:
{
programs = {

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ pkgs, ... }:
{
programs = {

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
_:
{
programs = {
@ -19,6 +19,7 @@
oh-my-zsh = {
enable = true;
plugins = [
"1password"
"bundler"
"direnv"
"docker"