From fd5cc50e0ff1e0c90b365825e22a9ef94b251d37 Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Sun, 17 Mar 2024 14:39:43 +0100 Subject: [PATCH] Added direnv and pre-commit. --- .envrc | 2 + .gitignore | 2 + flake.lock | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++-- flake.nix | 41 ++++++++----- shell.nix | 7 +++ 5 files changed, 201 insertions(+), 22 deletions(-) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..29da48d --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +watch_file shell.nix +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..410621b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.direnv/ +.pre-commit-config.yaml diff --git a/flake.lock b/flake.lock index 6082e93..637358b 100644 --- a/flake.lock +++ b/flake.lock @@ -2,7 +2,7 @@ "nodes": { "devshell": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixvim", "nixpkgs" @@ -52,6 +52,22 @@ "type": "github" } }, + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -78,11 +94,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -109,6 +125,42 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -131,6 +183,27 @@ "type": "github" } }, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "hb-downloader": { "inputs": { "nixpkgs": [ @@ -229,6 +302,38 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1704874635, + "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1704842529, + "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixvim": { "inputs": { "devshell": "devshell", @@ -258,7 +363,7 @@ "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "gitignore": "gitignore", "nixpkgs": [ "nixvim", @@ -283,12 +388,36 @@ "type": "github" } }, + "pre-commit-hooks_2": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_4", + "gitignore": "gitignore_2", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1708018599, + "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { + "flake-utils": "flake-utils", "hb-downloader": "hb-downloader", "home-manager": "home-manager", "nixpkgs": "nixpkgs", - "nixvim": "nixvim" + "nixvim": "nixvim", + "pre-commit-hooks": "pre-commit-hooks_2" } }, "systems": { @@ -320,6 +449,36 @@ "repo": "default", "type": "github" } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "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", diff --git a/flake.nix b/flake.nix index d6b9991..2dfec92 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,10 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -20,23 +24,28 @@ }; }; - outputs = inputs@{ self, nixpkgs, home-manager, ... }: { - nixosConfigurations = { - default = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./nixos/configuration.nix + outputs = inputs@{ self, nixpkgs, flake-utils, pre-commit-hooks, home-manager + , ... }: { + nixosConfigurations = { + default = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./nixos/configuration.nix - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.extraSpecialArgs = { inherit inputs; }; - home-manager.users.crony = { - imports = [ ./home-manager/home.nix ]; - }; - } - ]; + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.extraSpecialArgs = { inherit inputs; }; + home-manager.users.crony = { + imports = [ ./home-manager/home.nix ]; + }; + } + ]; + }; }; + devShells.x86_64-linux.default = let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in (import ./shell.nix { inherit pkgs pre-commit-hooks; }); }; - }; } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..927e82c --- /dev/null +++ b/shell.nix @@ -0,0 +1,7 @@ +{ pkgs ? import { }, pre-commit-hooks, ... }: +let + pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run { + src = "."; + hooks = { nixfmt.enable = true; }; + }; +in pkgs.mkShell { inherit (pre-commit-check) shellHook; }