Add some nix-mode templates

This commit is contained in:
Evie Litherland-Smith 2024-08-08 10:23:47 +01:00
parent 87c4ec61d1
commit a9079cc2e4

View file

@ -203,6 +203,42 @@ python-base-mode
(logg "logger = logging.getLogger(__name__)") (logg "logger = logging.getLogger(__name__)")
(nimp "raise NotImplementedError") (nimp "raise NotImplementedError")
nix-mode
(pkgs "pkgs = import " (p "<nixpkgs>") " {};")
(poetry2nix "poetry2nix = (builtins.getFlake \"github:nix-community/poetry2nix\").lib.mkPoetry2Nix {inherit pkgs;};")
(pythonshell "let" n
> "pkgs = import " (p "<nixpkgs>") " {};" n
> "in pkgs.mkShellNoCC {" n
> "packages = with pkgs; [" n
> "poetry" n
> (p "python3") n
> q n
> "];" n
> "shellHook = ''" n
> "export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.zlib}/lib" n
> "'';" n
> "}")
(poetryshell "# See https://github.com/nix-community/poetry2nix/blob/master/docs/edgecases.md#cases" n
"# for edgecases like setuptools not found" n
"let" n
> "pkgs = import " (p "<nixpkgs>") " {};" n
> "poetry2nix = (builtins.getFlake \"github:nix-community/poetry2nix\").lib.mkPoetry2Nix {inherit pkgs;};" n
> "poetryEnv = let " n
> "projectDir = " (p "./.") ";" n
> "in (poetry2nix.mkPoetryEnv {" n
> "inherit projectDir;" n
> "overrides = poetry2nix.defaultPoetryOverrides;" n
> "python = " (p "pkgs.python3") ";" n
> "editablePackageSources = {" (p "package") "= projectDir;};" n
> "extraPackages = (ps: [" q "]);" n
> "preferWheels = true;" n
> "groups = [\"dev\"];" n
> "extras = [\"*\"];" n
> "});" n
"in" n
> "poetryEnv.env")
envrc-file-mode envrc-file-mode
(python "CC=\"$(nix build nixpkgs#stdenv.cc.cc.lib --print-out-paths --no-link)\"" n (python "CC=\"$(nix build nixpkgs#stdenv.cc.cc.lib --print-out-paths --no-link)\"" n