dynatrace-oss / dt-cli

Command line tool for Dynatrace
https://pypi.org/project/dt-cli/
Apache License 2.0
17 stars 12 forks source link

Add nix support #15

Closed allgreed closed 6 months ago

allgreed commented 3 years ago

I'd love to use this tool as much as possible with the internal workflow, however, for that I'd need this package to be buildable with nix.

There is some PR #1 , however I was just trying to hack something quickly, clearly, as mentioned by @wbachnik we need to do better than that.

AC:

Follow up ACs (probably worth splitting, but not sure):

Potential low hanging fruits after this issue:

Potentially useful + thoughs:

Current downstream, working nix expression:

  click-aliases = with pkgs.python38Packages; buildPythonPackage rec {
      pname = "click-aliases";
      version = "1.0.1";

      src = fetchPypi{
        inherit version;
        inherit pname;
        sha256 = "18q5wya46mdlm2g8x6bcxhzqf09nxy7lbvpqyh1fp207gq3i507l";
      };

      buildInputs = [ click ];
  };
  dtcli = with pkgs.python38Packages; buildPythonPackage rec {
      pname = "dt-cli";
      version = "0.0.9a0";

      src = fetchPypi{
        inherit version;
        inherit pname;
        sha256 = "17v90ykiph88dz1pxl801dpv6lc2ajsxns460zjjwbqpi9x2p1bv";
      };

      propagatedBuildInputs = [ pyyaml asn1crypto click click-aliases cryptography ];
  };
vduseev commented 3 years ago

I guess that's totally up to you @allgreed :) None of us currently use nix env in our workflow but being present in this field is a good thing right now. Even Hashicorp started actively delving into nix recently.

allgreed commented 3 years ago

Sure, I've assigned myself. But if anyone else has bandwidth and desire to deal with this before I do feel free to ping me ;)

allgreed commented 2 years ago

Packaging the release binary works ok, but this should stay open as the binary releases are a half-measure ;c

allgreed commented 2 years ago

Following expression works, with the caveats described below:

let
  nixpkgs = builtins.fetchGit {
    url = "https://github.com/nixos/nixpkgs/";
    ref = "refs/heads/nixos-unstable";
    rev = "e10da1c7f542515b609f8dfbcf788f3d85b14936";
    # obtain via `git ls-remote https://github.com/nixos/nixpkgs nixos-unstable`
    # 27-04-2022
  };
  pkgs = import nixpkgs { config = {}; };
  pythonCore = pkgs.python38;
  myAppEnv = pkgs.poetry2nix.mkPoetryEnv {
    projectDir = ./.;
    python = pythonCore;
    overrides = with pkgs; poetry2nix.overrides.withDefaults (self: super: {
      cryptography = super.cryptography.overridePythonAttrs(old:{
        cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
          inherit (old) src;
          name = "${old.pname}-${old.version}";
          sourceRoot = "${old.pname}-${old.version}/src/rust/";
          sha256 = "sha256:01h511h6l4qvjxbaw662m1l84pb4wrhwxmnb3qj6ik13mx2m477m";
        };
        cargoRoot = "src/rust";
        nativeBuildInputs = old.nativeBuildInputs ++ (with pkgs.rustPlatform; [
          rust.rustc
          rust.cargo
          cargoSetupHook
        ]);
      });
      pyparsing = super.pyparsing.overridePythonAttrs (old: {
        buildInputs = (old.buildInputs or [ ]) ++ [
          self.flit-core
        ];
      });
    });
    #editablePackageSources = {
      #my-app = ./dtcli;
    #};
  };
in myAppEnv.env

Following steps need to be taken:

vduseev commented 6 months ago

Closing as this is out of scope now