trying out change with formatter

This commit is contained in:
2025-03-18 12:37:04 -05:00
parent 6769b5cbbe
commit cdd7e69dda
3 changed files with 180 additions and 132 deletions

35
flake.lock generated
View File

@@ -16,6 +16,22 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1735554305,
"narHash": "sha256-zExSA1i/b+1NMRhGGLtNfFGXgLtgo+dcuzHzaWA6w3Q=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pyproject-build-systems": {
"inputs": {
"nixpkgs": [
@@ -67,9 +83,28 @@
"nixpkgs": "nixpkgs",
"pyproject-build-systems": "pyproject-build-systems",
"pyproject-nix": "pyproject-nix",
"treefmt-nix": "treefmt-nix",
"uv2nix": "uv2nix"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1742303424,
"narHash": "sha256-2R7cGdcA2npQQcIWu2cTlU63veTzwVZe78BliIuJT00=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "b3b938ab8ba2e8a0ce9ee9b30ccfa5e903ae5753",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"uv2nix": {
"inputs": {
"nixpkgs": [

View File

@@ -2,7 +2,9 @@
description = "Flake that contains an overlay with some mcp servers";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
@@ -27,19 +29,21 @@
# };
};
outputs = { self, nixpkgs, ... }@inputs:
outputs =
{ self, nixpkgs, ... }@inputs:
let
supportedSystems = [ "x86_64-linux"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor = system: nixpkgs.legacyPackages.${system}.extend(
nixpkgs.lib.composeManyExtensions (
[] ++ builtins.attrValues self.overlays
)
supportedSystems = [ "x86_64-linux" ];
pkgsFor =
system:
nixpkgs.legacyPackages.${system}.extend (
nixpkgs.lib.composeManyExtensions ([ ] ++ builtins.attrValues self.overlays)
);
eachSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f (pkgsFor system));
buildUvServers = { pkgs }:
buildUvServers = (
pkgs:
let
inherit (pkgs.callPackage inputs.pyproject-nix.build.util {}) mkApplication;
inherit (pkgs.callPackage inputs.pyproject-nix.build.util { }) mkApplication;
workspace = inputs.uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
overlay = workspace.mkPyprojectOverlay {
sourcePreference = "wheel";
@@ -48,27 +52,29 @@
pyprojectOverrides = final: prev: {
sgmllib3k = prev.sgmllib3k.overrideAttrs (old: {
nativeBuildInputs =
old.nativeBuildInputs or [ ] ++ (
final.resolveBuildSystem {
old.nativeBuildInputs or [ ]
++ (final.resolveBuildSystem {
setuptools-scm = [ ];
setuptools = [ ];
}
);
});
});
};
pythonSet = (pkgs.callPackage inputs.pyproject-nix.build.packages {
pythonSet =
(pkgs.callPackage inputs.pyproject-nix.build.packages {
inherit python;
}).overrideScope (
}).overrideScope
(
nixpkgs.lib.composeManyExtensions [
inputs.pyproject-build-systems.overlays.default
overlay
pyprojectOverrides
]
);
venv = (pythonSet.mkVirtualEnv "uv-mcp-envs" workspace.deps.default).overrideAttrs(old: {
venv = (pythonSet.mkVirtualEnv "uv-mcp-envs" workspace.deps.default).overrideAttrs (_old: {
venvIgnoreCollisions = [ "*" ];
});
in {
in
{
arxiv-mcp-server = mkApplication {
inherit venv;
package = pythonSet.arxiv-mcp-server;
@@ -81,40 +87,27 @@
inherit venv;
package = pythonSet.mcp-text-editor;
};
};
}
);
# Build function for MCP servers
buildMcpServer = { pkgs }:
pkgs.stdenv.mkDerivation {
pname = "mcp-servers";
version = "0.1.0";
src = inputs.mcp-servers;
nativeBuildInputs = [ pkgs.nodejs pkgs.makeWrapper ];
buildPhase = ''
export HOME=$(mktemp -d)
ls -alhR
echo "starting to build..."
npm ci --no-audit --no-fund --loglevel verbose
'';
treefmtEval = eachSystem (pkgs: inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
installPhase = ''
mkdir -p $out/lib $out/bin
cp -r . $out/lib
cp -r node_modules/bin $out/bin
'';
};
in {
in
{
# Formatting
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
# formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
# for `nix flake check`
checks = eachSystem (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
# Overlays
overlays.default = final: prev: {
custom-servers = buildUvServers {
pkgs = prev;
};
overlays.default = _final: prev: {
custom-servers = buildUvServers prev;
};
# Packages
@@ -127,10 +120,12 @@
#);
# Development shell
devShells = forAllSystems (system:
let pkgs = pkgsFor system;
uv-servers = buildUvServers { inherit pkgs; };
in {
devShells = eachSystem (
pkgs:
let
uv-servers = buildUvServers pkgs;
in
{
default = pkgs.mkShell {
packages = [
pkgs.python313

18
treefmt.nix Normal file
View File

@@ -0,0 +1,18 @@
# treefmt.nix
{ ... }:
{
projectRootFile = "treefmt.nix";
settings.global.excludes = [
"*.toml"
"*.txt"
];
programs.deadnix.enable = true;
programs.mdsh.enable = true;
programs.nixfmt.enable = true;
programs.shellcheck.enable = true;
programs.shfmt.enable = true;
programs.yamlfmt.enable = true;
programs.just.enable = true;
}