From d5341339678ca8cdbcd337c30280cd03359364e1 Mon Sep 17 00:00:00 2001 From: FidgetingBits Date: Wed, 6 Mar 2024 23:13:58 +0800 Subject: [PATCH] add nix flake files --- .envrc | 1 + flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000000..3550a30f2de --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..a1271a0ba5f --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1709675310, + "narHash": "sha256-w61tqFEmuJ+/1rAwU7nkYZ+dN6sLwyobfLwX2Yn42FE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "43d259f8d726113fac056e8bb17d5ac2dea3e0a8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..25d0a7ce0fa --- /dev/null +++ b/flake.nix @@ -0,0 +1,49 @@ +{ + description = "A Nix-flake-based development environment for Cursorless"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + outputs = { self, nixpkgs }: + let + overlays = [ + (final: prev: rec { + nodejs = prev.nodejs-18_x; + pnpm = prev.nodePackages.pnpm; + }) + ]; + supportedSystems = + [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: + nixpkgs.lib.genAttrs supportedSystems (system: + f { + pkgs = import nixpkgs { + inherit overlays system; + config.allowUnfree = true; + }; + }); + pythonVersion = builtins.replaceStrings + [ "py" ] + [ "python" ] + (nixpkgs.lib.importTOML ./pyproject.toml).tool.ruff.target-version; + in + { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + packages = with pkgs; [ + nodejs + pnpm + pkgs.${pythonVersion} + vsce + pre-commit + ]; + # To prevent weird broken non-interactive bash terminal + buildInputs = [ pkgs.bashInteractive ]; + shellHook = '' + if [ ! -f .git/hooks/pre-commit ]; then + pre-commit install + fi + ''; + }; + }); + }; +}