diff --git a/flake.nix b/flake.nix index 1f508b2..3c8e3e5 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,16 @@ path = ./simple-container; description = "A NixOS container running apache-httpd"; }; + + python = { + path = ./python; + description = "Python template, using poetry2nix"; + }; + + rust = { + path = ./rust; + description = "Rust template, using Naersk"; + }; }; diff --git a/python/.envrc b/python/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/python/.envrc @@ -0,0 +1 @@ +use flake diff --git a/python/.github/workflows/build_nix.yml b/python/.github/workflows/build_nix.yml new file mode 100644 index 0000000..2f684e1 --- /dev/null +++ b/python/.github/workflows/build_nix.yml @@ -0,0 +1,13 @@ +name: "Build legacy Nix package on Ubuntu" + +on: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v12 + - name: Building package + run: nix-build . -A defaultPackage.x86_64-linux diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 0000000..3fba40a --- /dev/null +++ b/python/.gitignore @@ -0,0 +1,6 @@ +__pycache__ +secrets.py +runs +.ipynb_* +*.csv +.direnv diff --git a/python/default.nix b/python/default.nix new file mode 100644 index 0000000..39bacff --- /dev/null +++ b/python/default.nix @@ -0,0 +1,7 @@ +(import ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } +) { + src = ./.; +}).defaultNix diff --git a/python/flake.nix b/python/flake.nix new file mode 100644 index 0000000..859989f --- /dev/null +++ b/python/flake.nix @@ -0,0 +1,29 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = {self, nixpkgs, utils}: + let out = system: + let pkgs = nixpkgs.legacyPackages."${system}"; + in { + + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ + python3Packages.poetry + ]; + }; + + defaultPackage = with pkgs.poetry2nix; mkPoetryApplication { + projectDir = ./.; + preferWheels = true; + }; + + defaultApp = utils.lib.mkApp { + drv = self.defaultPackage."${system}"; + }; + + }; in with utils.lib; eachSystem defaultSystems out; + +} diff --git a/python/shell.nix b/python/shell.nix new file mode 100644 index 0000000..77db547 --- /dev/null +++ b/python/shell.nix @@ -0,0 +1,7 @@ +(import ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } +) { + src = ./.; +}).shellNix diff --git a/rust/.envrc b/rust/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/rust/.envrc @@ -0,0 +1 @@ +use flake diff --git a/rust/.github/workflows/build_nix.yml b/rust/.github/workflows/build_nix.yml new file mode 100644 index 0000000..2f684e1 --- /dev/null +++ b/rust/.github/workflows/build_nix.yml @@ -0,0 +1,13 @@ +name: "Build legacy Nix package on Ubuntu" + +on: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v12 + - name: Building package + run: nix-build . -A defaultPackage.x86_64-linux diff --git a/rust/default.nix b/rust/default.nix new file mode 100644 index 0000000..39bacff --- /dev/null +++ b/rust/default.nix @@ -0,0 +1,7 @@ +(import ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } +) { + src = ./.; +}).defaultNix diff --git a/rust/flake.nix b/rust/flake.nix new file mode 100644 index 0000000..3b77f3b --- /dev/null +++ b/rust/flake.nix @@ -0,0 +1,29 @@ +{ + + inputs = { + naersk.url = "github:nmattia/naersk/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils, naersk }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + naersk-lib = pkgs.callPackage naersk {}; + in { + + defaultPackage = naersk-lib.buildPackage ./.; + + defaultApp = utils.mkApp { + drv = self.defaultPackage."${system}"; + }; + + devShell = with pkgs; mkShell { + buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy ]; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + }; + + }); + +} diff --git a/rust/shell.nix b/rust/shell.nix new file mode 100644 index 0000000..77db547 --- /dev/null +++ b/rust/shell.nix @@ -0,0 +1,7 @@ +(import ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } +) { + src = ./.; +}).shellNix