diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c96fe3f..4f6330a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,22 +7,14 @@ concurrency: cancel-in-progress: true jobs: - test: - if: false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v23 - - run: nix eval --impure .#tests - working-directory: tests - templates: strategy: matrix: template: - name: default command: python --version - + - name: devenv + command: python --version runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -34,3 +26,12 @@ jobs: working-directory: ${{ steps.mktemp.outputs.tmpdir }} - run: nix develop --accept-flake-config -c ${{ matrix.template.command }} working-directory: ${{ steps.mktemp.outputs.tmpdir }} + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v23 + - run: nix eval --impure .#tests + working-directory: tests + diff --git a/templates/devenv/.tool-versions b/templates/devenv/.tool-versions new file mode 100644 index 0000000..1569bf5 --- /dev/null +++ b/templates/devenv/.tool-versions @@ -0,0 +1 @@ +python 3.12.0 diff --git a/templates/devenv/flake.nix b/templates/devenv/flake.nix new file mode 100644 index 0000000..cc5251c --- /dev/null +++ b/templates/devenv/flake.nix @@ -0,0 +1,38 @@ +{ + inputs = { + asdf2nix-python.url = "github:sestrella/asdf2nix?dir=plugins/python"; + asdf2nix.url = "github:sestrella/asdf2nix"; + devenv.url = "github:cachix/devenv"; + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + }; + + nixConfig = { + extra-substituters = "https://cache.nixos.org https://nixpkgs-python.cachix.org"; + extra-trusted-public-keys = "nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU="; + }; + + outputs = inputs@{ self, asdf2nix-python, asdf2nix, devenv, flake-utils, nixpkgs }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + packages = asdf2nix.lib.packagesFromVersionsFile { + inherit system; + versionsFile = ./.tool-versions; + plugins = { + python = asdf2nix-python.lib; + }; + }; + in + { + devShells.default = devenv.lib.mkShell { + inherit inputs pkgs; + modules = [ + ({ pkgs, config, ... }: { + languages.python.enable = true; + languages.python.package = packages.python; + }) + ]; + }; + }); +}