diff --git a/.gitignore b/.gitignore index 430a8c8720..5fe70512df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea .env .envrc +.direnv __pycache__ binaries/* !binaries/README.md diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..f8629f43ba --- /dev/null +++ b/default.nix @@ -0,0 +1,12 @@ +# flake-compat shim for usage without flakes +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).defaultNix + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..e20463ede2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,76 @@ +{ + "nodes": { + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1729239738, + "narHash": "sha256-JMCUax/2NQYflc9tQ2kmMNpxI3BZPvtvceoFExpwTng=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a8f84a9dffb7805a2668004e1a3e427bdbc48413", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..5a131b9dbe --- /dev/null +++ b/flake.nix @@ -0,0 +1,65 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/master"; + + # cross-platform convenience + flake-utils.url = "github:numtide/flake-utils"; + + # backwards compatibility with nix-build and nix-shell + flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; + }; + + outputs = { self, nixpkgs, flake-utils, flake-compat }: + # resolve for all platforms in turn + flake-utils.lib.eachDefaultSystem (system: + let + # packages for this system platform + pkgs = nixpkgs.legacyPackages.${system}; + + # control versions + + # get these python packages from nix + python_packages = python-packages: [ + python-packages.pip + ]; + + # use this pyton version, and include the abvoe packages + python = pkgs.python312.withPackages python_packages; + in { + devShell = pkgs.stdenv.mkDerivation { + name = "devshell"; + + buildInputs = with pkgs; [ + # version to use + default packages are declared above + python + + + # linters + shellcheck + + # for scripts + bash + fswatch + rsync + ] ++ lib.optionals (pkgs.stdenv.isDarwin) [ + # for python watchdog package + darwin.apple_sdk.frameworks.CoreServices + ]; + + + shellHook = '' + export PYTHON_VERSION="$(python -c 'import platform; import re; print(re.sub(r"\.\d+$", "", platform.python_version()))')" + + # replicate virtualenv behaviour + export PIP_PREFIX="$PWD/vendor/python/$PYTHON_VERSION/packages" + export PYTHONPATH="$PIP_PREFIX/lib/python$PYTHON_VERSION/site-packages:$PYTHONPATH" + unset SOURCE_DATE_EPOCH + export PATH="$PIP_PREFIX/bin:$PATH" + + # hack: can't find libstdc++.so.8 otherwise + export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib" + ''; + }; + } + ); +} diff --git a/shell.nix b/shell.nix index 6bda0280d2..950c1c8180 100644 --- a/shell.nix +++ b/shell.nix @@ -1,45 +1,11 @@ -{ - # use the environment channel - pkgs ? import {}, - - # use a pinned package state - pinned ? import(fetchTarball("https://github.com/NixOS/nixpkgs/archive/c75037bbf909.tar.gz")) {}, -}: -let - # get these python packages from nix - python_packages = python-packages: [ - python-packages.pip - ]; - - # use this pyton version, and include the abvoe packages - python = pinned.python39.withPackages python_packages; -in pinned.stdenv.mkDerivation { - # unique project name for this environment derivation - name = "system-tests.devshell"; - - buildInputs = [ - # version to use + default packages are declared above - python - - # linters - pinned.shellcheck - - # for scripts - pinned.bash - pinned.fswatch - pinned.rsync - ]; - - shellHook = '' - export PYTHON_VERSION="$(python -c 'import platform; import re; print(re.sub(r"\.\d+$", "", platform.python_version()))')" - - # replicate virtualenv behaviour - export PIP_PREFIX="$PWD/vendor/python/$PYTHON_VERSION/packages" - export PYTHONPATH="$PIP_PREFIX/lib/python$PYTHON_VERSION/site-packages:$PYTHONPATH" - unset SOURCE_DATE_EPOCH - export PATH="$PIP_PREFIX/bin:$PATH" - - # hack: can't find libstdc++.so.8 otherwise - export LD_LIBRARY_PATH="${pinned.stdenv.cc.cc.lib}/lib" - ''; -} +# flake-compat shim for usage without flakes +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).shellNix diff --git a/utils/scripts/compute_impacted_scenario.py b/utils/scripts/compute_impacted_scenario.py index 4dcbe22814..216799f567 100644 --- a/utils/scripts/compute_impacted_scenario.py +++ b/utils/scripts/compute_impacted_scenario.py @@ -179,7 +179,9 @@ def main(): r"format\.sh": None, r"pyproject\.toml": None, r"scenario_groups\.yml": None, - r"shell\.nix": None, + ## Nix + r".*\.nix": None, + r"flake\.lock": None, ## few files with lot of effect r"requirements\.txt": ScenarioGroup.ALL.value, r"run\.sh": ScenarioGroup.ALL.value,