Add pre-commit hooks and other fixes

main
mat ess 2022-11-20 17:07:02 -05:00
parent e11c455279
commit 5f6c3ffd97
11 changed files with 113 additions and 46 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
result result
result-* result-*
*.secret.* *.secret.*
.nvimlog .nvimlog
.pre-commit-config.yaml

View File

@ -10,6 +10,7 @@
"https://nix-community.cachix.org" "https://nix-community.cachix.org"
"https://mat.cachix.org" "https://mat.cachix.org"
"https://helix.cachix.org" "https://helix.cachix.org"
"https://pre-commit-hooks.cachix.org"
]; ];
trusted-public-keys = [ trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
@ -17,6 +18,7 @@
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"mat.cachix.org-1:AHqv9SoBEPKlJX2DDZQnjaMcvBAgpH1j8rw5USYDZno=" "mat.cachix.org-1:AHqv9SoBEPKlJX2DDZQnjaMcvBAgpH1j8rw5USYDZno="
"helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="
"pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
]; ];
trusted-users = [ trusted-users = [
"@admin" "@admin"

View File

@ -1,5 +1,3 @@
{ ... }:
{ {
system.defaults.NSGlobalDomain = { system.defaults.NSGlobalDomain = {
AppleInterfaceStyleSwitchesAutomatically = true; AppleInterfaceStyleSwitchesAutomatically = true;

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { pkgs, ... }:
{ {
environment.systemPackages = [ pkgs.terminal-notifier ]; environment.systemPackages = [ pkgs.terminal-notifier ];
@ -10,6 +10,7 @@
inter inter
recursive recursive
(nerdfonts.override { (nerdfonts.override {
enableWindowsFonts = false;
fonts = [ fonts = [
"CascadiaCode" "CascadiaCode"
"iA-Writer" "iA-Writer"

View File

@ -321,6 +321,22 @@
"type": "github" "type": "github"
} }
}, },
"kitty-rose-pine": {
"flake": false,
"locked": {
"lastModified": 1661351382,
"narHash": "sha256-idqwpNC6hWIz5KtEGqL5C+KcUcKc9iPCstP5FQcZZ0I=",
"owner": "rose-pine",
"repo": "kitty",
"rev": "4dd9bbe6f838e61f0ef7e9ab9625adda34e129ef",
"type": "github"
},
"original": {
"owner": "rose-pine",
"repo": "kitty",
"type": "github"
}
},
"nci": { "nci": {
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
@ -396,6 +412,42 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1667292599,
"narHash": "sha256-7ISOUI1aj6UKMPIL+wwthENL22L3+A9V+jS8Is3QsRo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ef2f213d9659a274985778bff4ca322f3ef3ac68",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"pre-commit": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1668973924,
"narHash": "sha256-17VnhpKJRoYdt23SJcUUCi/qEt9d3OyFsz9YRYStrew=",
"owner": "cpcloud",
"repo": "pre-commit-hooks.nix",
"rev": "7ee855668b78b9d7d1b504121c5b146c67a2abd8",
"type": "github"
},
"original": {
"owner": "cpcloud",
"ref": "dot-git-dir",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"dark-mode-notify-src": "dark-mode-notify-src", "dark-mode-notify-src": "dark-mode-notify-src",
@ -408,9 +460,11 @@
"home-manager-atemu": "home-manager-atemu", "home-manager-atemu": "home-manager-atemu",
"homebrew-enabled": "homebrew-enabled", "homebrew-enabled": "homebrew-enabled",
"kitty-icon": "kitty-icon", "kitty-icon": "kitty-icon",
"kitty-rose-pine": "kitty-rose-pine",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-master": "nixpkgs-master", "nixpkgs-master": "nixpkgs-master",
"nixpkgs-unstable": "nixpkgs-unstable" "nixpkgs-unstable": "nixpkgs-unstable",
"pre-commit": "pre-commit"
} }
}, },
"rust-overlay": { "rust-overlay": {

View File

@ -26,10 +26,10 @@
home-manager-atemu.url = "github:Atemu/home-manager/darwin-copy-apps-fully-wip"; home-manager-atemu.url = "github:Atemu/home-manager/darwin-copy-apps-fully-wip";
home-manager-atemu.inputs.nixpkgs.follows = "nixpkgs-unstable"; home-manager-atemu.inputs.nixpkgs.follows = "nixpkgs-unstable";
# Nix language server # pre-commit and hooks
nil.url = "github:oxalica/nil"; # pre-commit.url = "github:cachix/pre-commit-hooks.nix";
nil.inputs.nixpkgs.follows = "nixpkgs-unstable"; pre-commit.url = "github:cpcloud/pre-commit-hooks.nix/dot-git-dir";
nil.inputs.flake-utils.follows = "flake-utils"; pre-commit.inputs.flake-utils.follows = "flake-utils";
# Extra sources # Extra sources
helix.url = "github:helix-editor/helix"; helix.url = "github:helix-editor/helix";
@ -42,7 +42,7 @@
fisher-src.flake = false; fisher-src.flake = false;
}; };
outputs = { self, darwin, home-manager, flake-utils, ... }@inputs: outputs = { self, darwin, home-manager, flake-utils, pre-commit, ... }@inputs:
let let
inherit (darwin.lib) darwinSystem; inherit (darwin.lib) darwinSystem;
@ -55,16 +55,16 @@
nixpkgsConfig = { nixpkgsConfig = {
config = { allowUnfree = true; }; config = { allowUnfree = true; };
overlays = attrValues self.overlays ++ [ overlays = attrValues self.overlays ++ [
(final: prev: (final: _prev:
import ./pkgs { import ./pkgs {
inherit inputs; inherit inputs;
inherit (final) callPackage; inherit (final) callPackage;
inherit (final.stdenv) system; inherit (final.stdenv) system;
}) })
(final: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") (_final: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin")
{ {
# Sub in x86 version of packages that don't build on Apple Silicon yet # Sub in x86 version of packages that don't build on Apple Silicon yet
inherit (final.pkgs-x86); # inherit (final.pkgs-x86);
}) })
]; ];
}; };
@ -90,7 +90,7 @@
# `home-manager` module # `home-manager` module
home-manager.darwinModules.home-manager home-manager.darwinModules.home-manager
( (
{ config, lib, pkgs, ... }: { config, ... }:
let let
inherit (config.users) primaryUser; inherit (config.users) primaryUser;
in in
@ -200,7 +200,7 @@
# Build and activate on new system with: # Build and activate on new system with:
# `nix build .#homeConfigurations.<name>.activationPackage; ./result/activate` # `nix build .#homeConfigurations.<name>.activationPackage; ./result/activate`
homeConfigurations = rec { homeConfigurations = {
cloudVM = home-manager.lib.homeManagerConfiguration { cloudVM = home-manager.lib.homeManagerConfiguration {
pkgs = import inputs.nixpkgs-unstable { pkgs = import inputs.nixpkgs-unstable {
system = "x86_64-linux"; system = "x86_64-linux";
@ -223,21 +223,21 @@
overlays = { overlays = {
# nixpkgs overlays # nixpkgs overlays
pkgs-stable = final: prev: { pkgs-stable = _final: prev: {
pkgs-stable = import inputs.nixpkgs { pkgs-stable = import inputs.nixpkgs {
inherit (prev.stdenv) system; inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config; inherit (nixpkgsConfig) config;
}; };
}; };
pkgs-unstable = final: prev: { pkgs-unstable = _final: prev: {
pkgs-unstable = import inputs.nixpkgs-unstable { pkgs-unstable = import inputs.nixpkgs-unstable {
inherit (prev.stdenv) system; inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config; inherit (nixpkgsConfig) config;
}; };
}; };
pkgs-master = final: prev: { pkgs-master = _final: prev: {
pkgs-master = import inputs.nixpkgs-master { pkgs-master = import inputs.nixpkgs-master {
inherit (prev.stdenv) system; inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config; inherit (nixpkgsConfig) config;
@ -247,7 +247,7 @@
colors = import ./overlays/colors.nix; colors = import ./overlays/colors.nix;
# Overlay useful on Macs with Apple Silicon # Overlay useful on Macs with Apple Silicon
apple-silicon = final: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") { apple-silicon = _final: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
# Add access to x86 packages system is running Apple Silicon # Add access to x86 packages system is running Apple Silicon
pkgs-x86 = import inputs.nixpkgs-unstable { pkgs-x86 = import inputs.nixpkgs-unstable {
system = "x86_64-darwin"; system = "x86_64-darwin";
@ -255,12 +255,10 @@
}; };
}; };
patched = final: prev: optionalAttrs prev.stdenv.isDarwin { patched = _final: prev: optionalAttrs prev.stdenv.isDarwin {
inherit (inputs) kitty-icon fisher-src; inherit (inputs) kitty-icon fisher-src;
lib = prev.lib // { homebrew-enabled = inputs.homebrew-enabled.value; }; lib = prev.lib // { homebrew-enabled = inputs.homebrew-enabled.value; };
}; };
nil = inputs.nil.overlays.default;
}; };
# `nix-darwin` configs and modules # `nix-darwin` configs and modules
@ -305,17 +303,33 @@
}; };
}; };
} // flake-utils.lib.eachDefaultSystem (system: { } // flake-utils.lib.eachDefaultSystem (system:
legacyPackages = import inputs.nixpkgs-unstable { let
inherit system; pkgs = import inputs.nixpkgs-unstable {
inherit (nixpkgsConfig) config; inherit system;
overlays = with self.overlays; [ inherit (nixpkgsConfig) config;
pkgs-master overlays = with self.overlays; [
pkgs-stable pkgs-master
colors pkgs-stable
apple-silicon colors
patched apple-silicon
]; patched
}; ];
}); };
in
{
legacyPackages = pkgs;
checks.pre-commit = pre-commit.lib.${system}.run {
src = ./.;
hooks = {
deadnix.enable = true;
nix-linter.enable = true;
nixpkgs-fmt.enable = true;
statix.enable = true;
};
};
devShells.default = pkgs.mkShell { inherit (self.checks.${system}.pre-commit) shellHook; };
});
} }

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { config, pkgs, ... }:
{ {
# Git # Git

View File

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }: { pkgs, ... }:
# Let-In --------------------------------------------------------------------------------------- {{{ # Let-In --------------------------------------------------------------------------------------- {{{
let let
inherit (lib) mkIf;
colorsToKitty = colors: with colors; { colorsToKitty = colors: with colors; {
inherit inherit
background background

View File

@ -131,12 +131,10 @@ in
}; };
programs.kitty.settings = optionalAttrs cfg.colors.enable programs.kitty.settings = optionalAttrs cfg.colors.enable
( {
{ allow_remote_control = "yes";
allow_remote_control = "yes"; listen_on = "unix:/tmp/mykitty";
listen_on = "unix:/tmp/mykitty"; } // optionalAttrs (cfg.useSymbolsFromNerdFont != "") {
}
) // optionalAttrs (cfg.useSymbolsFromNerdFont != "") {
# https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points # https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points
symbol_map = "U+E5FA-U+E62B,U+E700-U+E7C5,U+F000-U+F2E0,U+E200-U+E2A9,U+F500-U+FD46,U+E300-U+E3EB,U+F400-U+F4A8,U+2665,U+26a1,U+F27C,U+E0A3,U+E0B4-U+E0C8,U+E0CA,U+E0CC-U+E0D2,U+E0D4,U+23FB-U+23FE,U+2B58,U+F300-U+F313,U+E000-U+E00D ${cfg.useSymbolsFromNerdFont}"; symbol_map = "U+E5FA-U+E62B,U+E700-U+E7C5,U+F000-U+F2E0,U+E200-U+E2A9,U+F500-U+FD46,U+E300-U+E3EB,U+F400-U+F4A8,U+2665,U+26a1,U+F27C,U+E0A3,U+E0B4-U+E0C8,U+E0CA,U+E0CC-U+E0D2,U+E0D4,U+23FB-U+23FE,U+2B58,U+F300-U+F313,U+E000-U+E00D ${cfg.useSymbolsFromNerdFont}";

View File

@ -1,4 +1,4 @@
final: prev: { _final: prev: {
lib = prev.lib // { lib = prev.lib // {
colors = { colors = {
tokyonight = import ./colors/tokyonight.nix; tokyonight = import ./colors/tokyonight.nix;

View File

@ -1,4 +1,4 @@
{ stdenv, lib, fetchurl, undmg, unzip, version ? "0.12", ... }: { stdenv, fetchurl, undmg, unzip, version ? "0.12", ... }:
stdenv.mkDerivation { stdenv.mkDerivation {
inherit version; inherit version;