From 42111721583b0d03a0952e3bd62ec8c333782f20 Mon Sep 17 00:00:00 2001 From: Tom Prince <tom.prince@private.storage> Date: Tue, 21 Sep 2021 10:35:10 -0600 Subject: [PATCH] Use `tools/default.nix` for tools. --- docs/source/dev/README.rst | 2 +- shell.nix | 15 ++------------- tools/default.nix | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 tools/default.nix diff --git a/docs/source/dev/README.rst b/docs/source/dev/README.rst index f72c5f6a..59d09272 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 97814a9c..abfefabf 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 00000000..fbc46990 --- /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} +'' -- GitLab