From bc8bc281ab84376abeb5e523034773e95e4a7655 Mon Sep 17 00:00:00 2001 From: clerie Date: Thu, 14 Mar 2024 19:17:47 +0100 Subject: [PATCH] Init repo --- README.md | 5 +++++ flake.nix | 18 ++++++++++++++++++ pyproject/.gitignore | 2 ++ pyproject/flake.nix | 33 +++++++++++++++++++++++++++++++++ pyproject/pyproject.toml | 18 ++++++++++++++++++ pyscript/.gitignore | 2 ++ pyscript/flake.nix | 35 +++++++++++++++++++++++++++++++++++ 7 files changed, 113 insertions(+) create mode 100644 README.md create mode 100644 flake.nix create mode 100644 pyproject/.gitignore create mode 100644 pyproject/flake.nix create mode 100644 pyproject/pyproject.toml create mode 100644 pyscript/.gitignore create mode 100644 pyscript/flake.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..c5727f2 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# flake-templates + +A collection of templates for software projects I regularly use. + +See `flake.nix` and directories for available templates. diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..920fed3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,18 @@ +{ + outputs = { ... }: { + templates = { + pyproject = { + path = ./pyproject; + description = "Python project with pyproject.toml"; + }; + pyscript = { + path = ./pyscript; + description = "Simple python script as application"; + }; + rust = { + path = ./rust; + description = "Rust cargo project"; + }; + }; + }; +} diff --git a/pyproject/.gitignore b/pyproject/.gitignore new file mode 100644 index 0000000..5599f5d --- /dev/null +++ b/pyproject/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +result diff --git a/pyproject/flake.nix b/pyproject/flake.nix new file mode 100644 index 0000000..1ae8e16 --- /dev/null +++ b/pyproject/flake.nix @@ -0,0 +1,33 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + outputs = { self, nixpkgs, ... }: { + packages.x86_64-linux = let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + in { + my_project = pkgs.python311Packages.buildPythonPackage rec { + pname = "my_project"; + version = "0.0.1"; + + src = ./.; + + format = "pyproject"; + + buildInputs = [ pkgs.python311Packages.hatchling ]; + propagatedBuildInputs = with pkgs.python311Packages; [ + ]; + + pythonImportsCheck = [ "my_project" ]; + }; + default = self.packages.x86_64-linux.my_project; + }; + + hydraJobs = { + inherit (self) + packages; + }; + }; +} diff --git a/pyproject/pyproject.toml b/pyproject/pyproject.toml new file mode 100644 index 0000000..8b94b7a --- /dev/null +++ b/pyproject/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "my_project" +version = "0.0.1" +authors = [ + { name="clerie", email="hallo@clerie.de" }, +] +description = "" +readme = "README.md" +license = { file="LICENSE" } +requires-python = ">=3.11" + +dependencies = [ +] + diff --git a/pyscript/.gitignore b/pyscript/.gitignore new file mode 100644 index 0000000..5599f5d --- /dev/null +++ b/pyscript/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +result diff --git a/pyscript/flake.nix b/pyscript/flake.nix new file mode 100644 index 0000000..c9d5f98 --- /dev/null +++ b/pyscript/flake.nix @@ -0,0 +1,35 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + outputs = { self, nixpkgs, ... }: { + packages.x86_64-linux = let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + in { + my_project = pkgs.python311Packages.buildPythonPackage rec { + pname = "my_project"; + version = "0.0.1"; + + src = ./.; + + format = "other"; + + propagatedBuildInputs = with pkgs.python311Packages; [ + ]; + + installPhase = '' + mkdir -p $out/bin + cp my_project.py $out/bin/my_project + ''; + }; + default = self.packages.x86_64-linux.my_project; + }; + + hydraJobs = { + inherit (self) + packages; + }; + }; +}