Skip to content
Snippets Groups Projects
default.nix 1.14 KiB
Newer Older
  • Learn to ignore specific revisions
  • { 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 ];
    
      shellHook = ''
        if [[ $- == *i* ]]; then
          cat <<MOTD
        Tools (pass --help for details):
        - update-nixpkgs
        MOTD
        fi
      '';
    
    } ''
      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}
    ''