summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2023-03-06 10:06:40 -0500
committerseth <[email protected]>2023-03-06 10:07:00 -0500
commit08224d0cda2374648cfe4e8400f5f6643be06751 (patch)
tree434918a534eae39a2aa5b9505abbe269aee06e3d
parentbb057765034c9fa8b93d92218d2b0a2686e680de (diff)
feat(infra): add pre-commit hooks and devshell
-rw-r--r--.envrc1
-rw-r--r--.gitignore2
-rw-r--r--PACKAGES.md2
-rw-r--r--README.md17
-rw-r--r--flake.lock80
-rw-r--r--flake.nix27
6 files changed, 122 insertions, 7 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..3550a30
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
diff --git a/.gitignore b/.gitignore
index b2be92b..fad2ec0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
result
+.direnv/
+.pre-commit-config.yaml
diff --git a/PACKAGES.md b/PACKAGES.md
index 6fb2800..e516b76 100644
--- a/PACKAGES.md
+++ b/PACKAGES.md
@@ -1,3 +1,5 @@
+# packages list
+
## original packages
- [treefetch](https://github.com/angelofallars/treefetch)
diff --git a/README.md b/README.md
index 0338820..76fd673 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ see [PACKAGES.md](https://github.com/getchoo/overlay/blob/main/PACKAGES.md)
## how to use
-### flake configuration:
+### flake configuration
```nix
{
@@ -38,7 +38,7 @@ see [PACKAGES.md](https://github.com/getchoo/overlay/blob/main/PACKAGES.md)
}
```
-### home-manager:
+### home-manager
```nix
{
@@ -49,7 +49,7 @@ see [PACKAGES.md](https://github.com/getchoo/overlay/blob/main/PACKAGES.md)
}
```
-### `configuration.nix`:
+### `configuration.nix`
```nix
_: let
@@ -61,17 +61,20 @@ in {
### cli support
-`nixpkgs.overlays` does not configure overlays for tools such as `nix(-)run`, `nix(-)shell`, etc.
-the best way to make this overlay available to them is to add it to your flake registry or `~/.config/nixpkgs/overlays.nix`.
+`nixpkgs.overlays` does not configure overlays for tools
+such as `nix(-)run`, `nix(-)shell`, etc.
-#### flake registry:
+the best way to make this overlay available to them is to
+add it to your flake registry or `~/.config/nixpkgs/overlays.nix`.
+
+#### flake registry
```shell
nix registry add getchoo github:getchoo/overlay
nix run getchoo#treefetch
```
-#### overlays.nix:
+#### overlays.nix
in `~/.config/nixpkgs/overlays.nix` (or a nix file in `~/.config/nixpkgs/overlays/`):
diff --git a/flake.lock b/flake.lock
index e997044..d3b3c5f 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,42 @@
{
"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"
+ }
+ },
+ "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"
+ }
+ },
"naersk": {
"inputs": {
"nixpkgs": [
@@ -34,10 +71,53 @@
"type": "indirect"
}
},
+ "nixpkgs-stable": {
+ "locked": {
+ "lastModified": 1673800717,
+ "narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-22.11",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "pre-commit-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "flake-utils": [
+ "utils"
+ ],
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "nixpkgs-stable": "nixpkgs-stable"
+ },
+ "locked": {
+ "lastModified": 1677832802,
+ "narHash": "sha256-XQf+k6mBYTiQUjWRf/0fozy5InAs03O1b30adCpWeXs=",
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "rev": "382bee738397ca005206eefa36922cc10df8a21c",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "type": "github"
+ }
+ },
"root": {
"inputs": {
"naersk": "naersk",
"nixpkgs": "nixpkgs",
+ "pre-commit-hooks": "pre-commit-hooks",
"utils": "utils"
}
},
diff --git a/flake.nix b/flake.nix
index eebf6e8..b8b5c78 100644
--- a/flake.nix
+++ b/flake.nix
@@ -5,12 +5,19 @@
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
+ pre-commit-hooks = {
+ url = "github:cachix/pre-commit-hooks.nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ inputs.flake-utils.follows = "utils";
+ };
};
outputs = {
+ self,
nixpkgs,
utils,
naersk,
+ pre-commit-hooks,
...
}: let
supportedSystsems = with utils.lib.system; [
@@ -32,7 +39,27 @@
utils.lib.eachSystem supportedSystsems (system: let
pkgs = import nixpkgs {inherit system;};
in {
+ checks = {
+ pre-commit-check = pre-commit-hooks.lib.${system}.run {
+ src = ./.;
+ hooks = {
+ # formatting is taken care of by gh actions :)
+ deadnix.enable = true;
+ markdownlint.enable = true;
+ };
+ };
+ };
+
+ devShells.default = pkgs.mkShell {
+ inherit (self.checks.${system}.pre-commit-check) shellHook;
+ packages = with pkgs; [
+ nodePackages.markdownlint-cli
+ deadnix
+ ];
+ };
+
formatter = pkgs.alejandra;
+
packages = let
p = packageSet pkgs;
in