From 547d252ad268252fd35543069b43fadfd9a01fbc Mon Sep 17 00:00:00 2001 From: Sam Willcocks Date: Fri, 3 Jul 2026 10:19:14 +0100 Subject: [PATCH] add basic python --- flake.nix | 4 ++++ python/flake.nix | 39 +++++++++++++++++++++++++++++++++++++++ python/treefmt.nix | 5 +++++ 3 files changed, 48 insertions(+) create mode 100644 python/flake.nix create mode 100644 python/treefmt.nix diff --git a/flake.nix b/flake.nix index 2984555..6f4a1a4 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,10 @@ path = ./devshell; description = "A basic devshell setup"; }; + python = { + path = ./python; + description = "A basic python setup"; + }; }; } // utils.lib.eachDefaultSystem (system: let diff --git a/python/flake.nix b/python/flake.nix new file mode 100644 index 0000000..f161eb8 --- /dev/null +++ b/python/flake.nix @@ -0,0 +1,39 @@ +{ + description = "Python spaghetti from samw"; + + inputs = { + treefmt-nix.url = "github:numtide/treefmt-nix"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + { + self, + nixpkgs, + treefmt-nix, + ... + }: + let + systems = [ + "aarch64-darwin" + "x86_64-linux" + ]; + eachSystem = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); + treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix); + in + { + devShells = eachSystem (pkgs: { + default = pkgs.mkShellNoCC { + buildInputs = with pkgs; [ + uv + ty + ]; + }; + }); + formatter = eachSystem (pkgs: treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.wrapper); + # for `nix flake check` + checks = eachSystem (pkgs: { + formatting = treefmtEval.${pkgs.system}.config.build.check self; + }); + }; +} diff --git a/python/treefmt.nix b/python/treefmt.nix new file mode 100644 index 0000000..7993d77 --- /dev/null +++ b/python/treefmt.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: { + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + programs.ruff.enable = true; +}