Compare commits

..

2 commits

Author SHA1 Message Date
34246c71d4
Manage pre-commit hooks with devenv
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 0s
2025-08-02 22:29:10 -07:00
8268528dd2
Fix broken context7 mcp 2025-08-02 21:51:47 -07:00
6 changed files with 267 additions and 6 deletions

4
.gitignore vendored
View file

@ -8,4 +8,8 @@
# build artifacts # build artifacts
result result
# devenv artifacts
.direnv
.devenv
tmp tmp

34
AGENTS.md Normal file
View file

@ -0,0 +1,34 @@
# Agent Guidelines for NixOS Dotfiles
## Development Environment
- **Enter shell**: `nix develop --no-pure-eval` or automatic via direnv
- **Run pre-commit hooks**: `devenv test` (also runs automatically on git commit)
- **Start services**: `devenv up` (if any processes are defined)
## Build/Test Commands
- **Build system**: `nix build .#nixosConfigurations.<hostname>` (e.g., `nix build .#nixosConfigurations.carbon`)
- **Build home config**: `nix build .#homeConfigurations."alejandro@<hostname>"`
- **Test configuration**: `nix flake check` (validates all configurations)
- **Format code**: `nixfmt .` (Nix formatter, available in devenv shell)
- **Deploy**: `nix run github:serokell/deploy-rs -- .#<hostname>` (e.g., `.#gospel`)
## Code Style Guidelines
- **Formatter**: Use nixfmt-rfc-style for Nix code formatting (managed by devenv pre-commit hooks)
- **Pre-commit**: Hooks run automatically on commit via devenv (trailing whitespace, YAML validation, etc.)
- **Imports**: Group function parameters in curly braces, use `...` for extensibility
- **Naming**: Use camelCase for variables, kebab-case for hostnames/services
- **Module structure**: Follow `{ config, lib, pkgs, namespace, ... }:` pattern
- **Options**: Use `lib.mkEnableOption` and `lib.mkOption` with proper types and descriptions
- **Conditionals**: Use `lib.mkIf` for conditional configuration, `lib.mkMerge` for combining configs
- **Namespace**: Use `aa` namespace for custom modules (defined in flake.nix)
- **Comments**: Add descriptive comments for complex logic, especially in system configurations
- **Error handling**: Leverage Nix's built-in evaluation errors, use `lib.assertMsg` for custom assertions
## Repository Structure
- `flake.nix`: Main entry point using Snowfall lib with devenv integration
- `devenv.nix`: Development environment configuration with pre-commit hooks
- `systems/`: NixOS system configurations
- `homes/`: Home Manager configurations
- `modules/`: Reusable modules (nixos/ and home/)
- `packages/`: Custom package definitions
- `.envrc`: Direnv configuration for automatic shell activation

21
devenv.nix Normal file
View file

@ -0,0 +1,21 @@
{ pkgs, ... }:
{
packages = [
pkgs.nixfmt-rfc-style
pkgs.nixd
pkgs.deploy-rs
pkgs.git
];
git-hooks.hooks = {
# Basic file hygiene
trim-trailing-whitespace.enable = true;
end-of-file-fixer.enable = true;
check-yaml.enable = true;
check-added-large-files = {
enable = true;
excludes = [ ".*\\.png$" ];
};
nixfmt-rfc-style.enable = true;
};
}

188
flake.lock generated
View file

@ -25,6 +25,38 @@
"type": "github" "type": "github"
} }
}, },
"cachix": {
"inputs": {
"devenv": [
"devenv"
],
"flake-compat": [
"devenv"
],
"git-hooks": [
"devenv",
"git-hooks"
],
"nixpkgs": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1748883665,
"narHash": "sha256-R0W7uAg+BLoHjMRMQ8+oiSbTq8nkGz5RDpQ+ZfxxP3A=",
"owner": "cachix",
"repo": "cachix",
"rev": "f707778d902af4d62d8dd92c269f8e70de09acbe",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "latest",
"repo": "cachix",
"type": "github"
}
},
"catppuccin": { "catppuccin": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
@ -65,6 +97,30 @@
"type": "github" "type": "github"
} }
}, },
"devenv": {
"inputs": {
"cachix": "cachix",
"flake-compat": "flake-compat_2",
"git-hooks": "git-hooks",
"nix": "nix",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1754158015,
"narHash": "sha256-B/o0XiDj06Knm7t/9KmLKnkrpI9s5O13qU+SNL/4Gp8=",
"owner": "cachix",
"repo": "devenv",
"rev": "062f3f42de2f6bb7382f88f6dbcbbbaa118a3791",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -82,6 +138,22 @@
} }
}, },
"flake-compat_2": { "flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_3": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1650374568, "lastModified": 1650374568,
@ -98,6 +170,28 @@
} }
}, },
"flake-parts": { "flake-parts": {
"inputs": {
"nixpkgs-lib": [
"devenv",
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1733312601,
"narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
@ -115,7 +209,7 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts_2": { "flake-parts_3": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
"nixvim", "nixvim",
@ -192,6 +286,54 @@
"type": "github" "type": "github"
} }
}, },
"git-hooks": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1750779888,
"narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"devenv",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -243,6 +385,43 @@
"type": "github" "type": "github"
} }
}, },
"nix": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"flake-parts": "flake-parts",
"git-hooks-nix": [
"devenv",
"git-hooks"
],
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-23-11": [
"devenv"
],
"nixpkgs-regression": [
"devenv"
]
},
"locked": {
"lastModified": 1752773918,
"narHash": "sha256-dOi/M6yNeuJlj88exI+7k154z+hAhFcuB8tZktiW7rg=",
"owner": "cachix",
"repo": "nix",
"rev": "031c3cf42d2e9391eee373507d8c12e0f9606779",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "devenv-2.30",
"repo": "nix",
"type": "github"
}
},
"nixlib": { "nixlib": {
"locked": { "locked": {
"lastModified": 1736643958, "lastModified": 1736643958,
@ -360,7 +539,7 @@
}, },
"nixvim": { "nixvim": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
@ -383,7 +562,7 @@
}, },
"nixvim_2": { "nixvim_2": {
"inputs": { "inputs": {
"flake-parts": "flake-parts_2", "flake-parts": "flake-parts_3",
"nixpkgs": "nixpkgs_3", "nixpkgs": "nixpkgs_3",
"nuschtosSearch": "nuschtosSearch", "nuschtosSearch": "nuschtosSearch",
"systems": "systems_4" "systems": "systems_4"
@ -448,6 +627,7 @@
"agenix": "agenix", "agenix": "agenix",
"catppuccin": "catppuccin", "catppuccin": "catppuccin",
"deploy-rs": "deploy-rs", "deploy-rs": "deploy-rs",
"devenv": "devenv",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixos-generators": "nixos-generators", "nixos-generators": "nixos-generators",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
@ -460,7 +640,7 @@
}, },
"snowfall-lib": { "snowfall-lib": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_3",
"flake-utils-plus": "flake-utils-plus", "flake-utils-plus": "flake-utils-plus",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"

View file

@ -28,6 +28,9 @@
nixvim.url = "git+https://git.alejandr0angul0.dev/alejandro-angulo/nixvim-config?ref=main"; nixvim.url = "git+https://git.alejandr0angul0.dev/alejandro-angulo/nixvim-config?ref=main";
nixvim.inputs.nixpkgs.follows = "nixpkgs"; nixvim.inputs.nixpkgs.follows = "nixpkgs";
devenv.url = "github:cachix/devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs";
zsh-syntax-highlighting.url = "github:zsh-users/zsh-syntax-highlighting/master"; zsh-syntax-highlighting.url = "github:zsh-users/zsh-syntax-highlighting/master";
zsh-syntax-highlighting.flake = false; zsh-syntax-highlighting.flake = false;
@ -54,6 +57,14 @@
homes.modules = with inputs; [ catppuccin.homeModules.catppuccin ]; homes.modules = with inputs; [ catppuccin.homeModules.catppuccin ];
outputs-builder = channels: {
devShells.default = inputs.devenv.lib.mkShell {
inherit inputs;
pkgs = channels.nixpkgs;
modules = [ ./devenv.nix ];
};
};
deploy.nodes = { deploy.nodes = {
node = { node = {
hostname = "node"; hostname = "node";

View file

@ -2,10 +2,19 @@
config, config,
lib, lib,
namespace, namespace,
pkgs,
... ...
}: }:
let let
cfg = config.${namespace}.programs.opencode; cfg = config.${namespace}.programs.opencode;
context7 = pkgs.writeShellApplication {
name = "context7-mcp";
runtimeInputs = [ pkgs.nodejs_24 ];
text = ''
npx -y @upstash/context7-mcp
'';
};
in in
{ {
options.${namespace}.programs.opencode = { options.${namespace}.programs.opencode = {
@ -19,8 +28,10 @@ in
theme = "catppuccin"; theme = "catppuccin";
mcp = { mcp = {
context7 = { context7 = {
type = "remote"; type = "local";
url = "https://mcp.context7.com/mcp"; command = [
"${context7}/bin/context7-mcp"
];
enabled = true; enabled = true;
}; };
}; };