nix-community / gomod2nix

Convert applications using Go modules to Nix expressions [maintainer=@marcusramberg]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get gomod2nix on nox-flake setups ?

573 opened this issue · comments

Is your feature request related to a problem? Please describe.
If I want to generate a gomod2nix.toml file on systems that are not flake-enabled I currently use a binary generated by starting a nix-shell of https://github.com/GTrunSec/photoprism2nix after adding buildInputs = [ pkgs.gomod2nix ]; to their flake.nix file (devShell = mkShell { buildInputs = [ pkgs.gomod2nix ]; (...)). This is tedious.

Describe the solution you'd like
It would be cool to just nix-shell in a checkout of https://github.com/tweag/gomod2nix to achieve this.

Describe alternatives you've considered
I have tried to run a nix-shell of https://github.com/tweag/gomod2nix already but this gave me no gomod2nix binary.

nix-shell this derivation:

let
  pkgs = import <nixpkgs> {
    overlays = [
      (self: super: {
        buildGoApplication = pkgs.callPackage ("${builtins.fetchTarball {
          url =  https://github.com/tweag/gomod2nix/archive/67f22dd738d092c6ba88e420350ada0ed4992ae8.tar.gz;
          sha256 = "0a9rhw6djgcrky5nzly3srsl8095q42f2nyzxyisp9fh9fg70nih";
        }}/builder") {};
        gomod2nix = pkgs.callPackage ("${builtins.fetchTarball {
          url =  https://github.com/tweag/gomod2nix/archive/67f22dd738d092c6ba88e420350ada0ed4992ae8.tar.gz;
          sha256 = "0a9rhw6djgcrky5nzly3srsl8095q42f2nyzxyisp9fh9fg70nih";
        }}/default.nix") {};
      })
    ];
  };
in pkgs.mkShell {
  buildInputs = [ pkgs.gomod2nix ];
}

You can simplify that a bit:

let
  pkgs = import <nixpkgs> {
    overlays = [
      (import "${builtins.fetchTarball {
        url =  https://github.com/tweag/gomod2nix/archive/67f22dd738d092c6ba88e420350ada0ed4992ae8.tar.gz;
        sha256 = "0a9rhw6djgcrky5nzly3srsl8095q42f2nyzxyisp9fh9fg70nih";
      }}/overlay.nix")
    ];
  };
in pkgs.mkShell {
  buildInputs = [ pkgs.gomod2nix ];
}