diff --git a/docs/source/dev/README.rst b/docs/source/dev/README.rst index f72c5f6ab85b0ea48302ee86bf2a0ad7b3898523..59d092724be29fad7f63515ac499bb01254d675e 100644 --- a/docs/source/dev/README.rst +++ b/docs/source/dev/README.rst @@ -49,7 +49,7 @@ To update the version of NixOS we deploy with, run: .. code: shell - nix-shell --command 'tools/update-nixpkgs' + nix-shell --command 'update-nixpkgs' That will update ``nixpkgs-2015.json`` to the latest release on the nixos-21.05 channel. diff --git a/shell.nix b/shell.nix index 97814a9c7f169efa267dbdf1ab1155416d8f83e1..abfefabfe37f5f37e05070dbedef96140305a4c4 100644 --- a/shell.nix +++ b/shell.nix @@ -3,25 +3,14 @@ let in { pkgs ? release2105, lib ? pkgs.lib, python ? pkgs.python3 }: let - # This is a python envionment that has the dependencies - # for the development python scripts we use, and the - # helper library. - python-env = python.buildEnv.override { - extraLibs = [ python.pkgs.httpx ]; - # Add `.pth` file pointing at the directory containg our helper library. - # This will get added to `sys.path` by `site.py`. - # See https://docs.python.org/3/library/site.html - postBuild = '' - echo ${lib.escapeShellArg ./tools/pylib} > $out/${lib.escapeShellArg python.sitePackages}/tools.pth - ''; - }; + tools = pkgs.callPackage ./tools {}; in pkgs.mkShell { shellHook = '' export NIX_PATH="nixpkgs=${pkgs.path}"; ''; buildInputs = [ - python-env + tools pkgs.morph pkgs.jp ]; diff --git a/tools/default.nix b/tools/default.nix new file mode 100644 index 0000000000000000000000000000000000000000..fbc46990515dec2d389c8489887fea0cac9f3f3f --- /dev/null +++ b/tools/default.nix @@ -0,0 +1,26 @@ +{ pkgs, lib, makeWrapper, ... }: +let + python = pkgs.python3; + # This is a python envionment that has the dependencies + # for the development python scripts we use, and the + # helper library. + python-env = python.buildEnv.override { + extraLibs = [ python.pkgs.httpx ]; + # Add `.pth` file pointing at the directory containg our helper library. + # This will get added to `sys.path` by `site.py`. + # See https://docs.python.org/3/library/site.html + postBuild = '' + echo ${lib.escapeShellArg ./pylib} > $out/${lib.escapeShellArg python.sitePackages}/tools.pth + ''; + }; +in +# This derivation creates a package that wraps our tools to setup an environment +# with there dependencies available. +pkgs.runCommand "ps_tools" { + nativeBuildInputs = [ makeWrapper ]; +} '' + mkdir -p $out/bin + # makeWrapper <executable> <wrapperfile> <args> + # See https://nixos.org/manual/nixpkgs/stable/#fun-makeWrapper + makeWrapper ${python-env}/bin/python $out/bin/update-nixpkgs --add-flags ${toString ./update-nixpkgs} +''