From a4d6a5dd98953bf76585d3901b91278f447b3164 Mon Sep 17 00:00:00 2001 From: rotterdam Date: Tue, 4 Apr 2023 09:57:48 -0300 Subject: [PATCH] Added nixfmt pre-commit-hook --- .pre-commit-config.yaml | 1 + flake.lock | 133 +++++++++++++++++++++++++---------- flake.nix | 33 +++++---- hosts/servers/alexandria.nix | 15 ++-- 4 files changed, 122 insertions(+), 60 deletions(-) create mode 120000 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 120000 index 0000000..b852231 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1 @@ +/nix/store/iin4xcfplzr1p8vd5j54scff6cvy21vk-pre-commit-config.json \ No newline at end of file diff --git a/flake.lock b/flake.lock index 90253bf..a5a2014 100644 --- a/flake.lock +++ b/flake.lock @@ -115,6 +115,58 @@ "type": "github" } }, + "flake-compat_2": { + "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": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "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": [ @@ -137,28 +189,6 @@ "type": "github" } }, - "home-manager-stable": { - "inputs": { - "nixpkgs": [ - "nixpkgs-stable" - ], - "utils": "utils_3" - }, - "locked": { - "lastModified": 1680554735, - "narHash": "sha256-42x6bGJzlEQ/a+QpaSZBk5nKRDXJIXN7poAdYOldtbc=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "dd73caf55cd4a70b0c31ac4fe11b0bd1cf5e8518", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "release-22.11", - "repo": "home-manager", - "type": "github" - } - }, "homepage": { "flake": false, "locked": { @@ -265,6 +295,22 @@ "type": "github" } }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1680398059, @@ -281,6 +327,30 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable_2" + }, + "locked": { + "lastModified": 1680599552, + "narHash": "sha256-rQQJFGvWQ3Sr+m/r5KGIFN0iVaVKr6u9uraCz6jSKj4=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "3342d7c51119030490fdcd07351b53b10806891c", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", @@ -288,12 +358,12 @@ "deploy-rs": "deploy-rs", "dotfiles": "dotfiles", "home-manager": "home-manager", - "home-manager-stable": "home-manager-stable", "homepage": "homepage", "kmonad": "kmonad", "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs_2", - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs-stable": "nixpkgs-stable", + "pre-commit-hooks": "pre-commit-hooks" } }, "utils": { @@ -325,21 +395,6 @@ "repo": "flake-utils", "type": "github" } - }, - "utils_3": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 262ad3c..a4b614f 100644 --- a/flake.nix +++ b/flake.nix @@ -9,10 +9,6 @@ url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = "nixpkgs"; }; - home-manager-stable = { - url = "github:nix-community/home-manager/release-22.11"; - inputs.nixpkgs.follows = "nixpkgs-stable"; - }; baduhai-nur.url = "github:baduhai/nur"; @@ -45,11 +41,16 @@ url = "github:baduhai/dotfiles"; flake = false; }; + + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs@{ self, nixpkgs, home-manager, baduhai-nur, kmonad - , nixpkgs-stable, home-manager-stable, deploy-rs, agenix, nixos-generators - , homepage, dotfiles, ... }: { + , nixpkgs-stable, deploy-rs, agenix, nixos-generators, homepage, dotfiles + , pre-commit-hooks, ... }: { nixosConfigurations = { rotterdam = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; @@ -100,17 +101,13 @@ server = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; extraSpecialArgs = { inherit inputs; }; - modules = [ - ./users/servers/user.nix - ]; + modules = [ ./users/servers/user.nix ]; }; desktop = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; extraSpecialArgs = { inherit inputs; }; - modules = [ - ./users/desktops/user.nix - ]; + modules = [ ./users/desktops/user.nix ]; }; }; @@ -131,6 +128,18 @@ }; }; + checks.x86_64-linux = { + pre-commit-check = pre-commit-hooks.lib."x86_64-linux".run { + src = ./.; + hooks = { nixfmt.enable = true; }; + }; + }; + + devShells.x86_64-linux.default = + nixpkgs.legacyPackages."x86_64-linux".mkShell { + inherit (self.checks."x86_64-linux".pre-commit-check) shellHook; + }; + nixosModules.qbittorrent = import ./modules/qbittorrent.nix; packages.x86_64-linux = { diff --git a/hosts/servers/alexandria.nix b/hosts/servers/alexandria.nix index 34b2fc5..70ba998 100644 --- a/hosts/servers/alexandria.nix +++ b/hosts/servers/alexandria.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ...}: +{ config, pkgs, lib, ... }: { imports = [ @@ -12,16 +12,13 @@ nix.nixPath = [ "nixos-config=${./alexandria.nix}" ]; - swapDevices = [ { device = "/swapfile"; size = 8192; } ]; + swapDevices = [{ + device = "/swapfile"; + size = 8192; + }]; networking = { hostName = "alexandria"; - firewall = { - allowedTCPPorts = [ - 80 - 443 - 9666 - ]; - }; + firewall = { allowedTCPPorts = [ 80 443 9666 ]; }; }; }