From 8525f7f0e5f8c7a2697a6fde7b36d06457afd874 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Fri, 2 Sep 2022 16:09:30 +1200 Subject: [PATCH] Remove generic builder expression This was an attempt to get maximal sharing with Nixpkgs but in hindsight it's better to just have some code duplication. --- default.nix | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- flake.nix | 2 +- generic.nix | 45 --------------------------------------------- overlay.nix | 2 +- 4 files changed, 48 insertions(+), 52 deletions(-) delete mode 100644 generic.nix diff --git a/default.nix b/default.nix index a8fedbc..111fab8 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,20 @@ -{ lib }: -(import ./generic.nix { - version = "1.4.0"; +{ stdenv +, callPackage +, go +, lib +, makeWrapper +, installShellFiles +, fetchFromGitHub +, buildGoApplication +, mkGoEnv +}: + +buildGoApplication { + pname = "gomod2nix"; + version = "dev"; + + modules = ./gomod2nix.toml; + src = lib.cleanSourceWith { filter = name: type: builtins.foldl' (v: s: v && ! lib.hasSuffix s name) true [ "tests" @@ -9,5 +23,32 @@ ]; src = lib.cleanSource ./.; }; - modules = ./gomod2nix.toml; -}) + + inherit go; + + allowGoReference = true; + + subPackages = [ "." ]; + + nativeBuildInputs = [ makeWrapper installShellFiles ]; + + passthru = { + inherit buildGoApplication mkGoEnv; + }; + + postInstall = lib.optionalString (stdenv.buildPlatform == stdenv.targetPlatform) '' + installShellCompletion --cmd gomod2nix \ + --bash <($out/bin/gomod2nix completion bash) \ + --fish <($out/bin/gomod2nix completion fish) \ + --zsh <($out/bin/gomod2nix completion zsh) + '' + '' + wrapProgram $out/bin/gomod2nix --prefix PATH : ${lib.makeBinPath [ go ]} + ''; + + meta = { + description = "Convert applications using Go modules -> Nix"; + homepage = "https://github.com/nix-community/gomod2nix"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.adisbladis ]; + }; +} diff --git a/flake.nix b/flake.nix index a71e681..85ee185 100644 --- a/flake.nix +++ b/flake.nix @@ -29,7 +29,7 @@ }; in { - packages.default = pkgs.callPackage (pkgs.callPackage ./default.nix { }) { }; + packages.default = pkgs.callPackage ./. { }; devShells.default = import ./shell.nix { inherit pkgs; }; }) ); diff --git a/generic.nix b/generic.nix deleted file mode 100644 index 5be3532..0000000 --- a/generic.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ version -, src -, modules -}: -{ stdenv -, callPackage -, go -, lib -, makeWrapper -, installShellFiles -, fetchFromGitHub -, buildGoApplication ? (callPackage ./builder { }).buildGoApplication -, mkGoEnv ? (callPackage ./builder { }).buildGoApplication -}: - -buildGoApplication { - pname = "gomod2nix"; - inherit version modules src go; - - allowGoReference = true; - - subPackages = [ "." ]; - - nativeBuildInputs = [ makeWrapper installShellFiles ]; - - passthru = { - inherit buildGoApplication mkGoEnv; - }; - - postInstall = lib.optionalString (stdenv.buildPlatform == stdenv.targetPlatform) '' - installShellCompletion --cmd gomod2nix \ - --bash <($out/bin/gomod2nix completion bash) \ - --fish <($out/bin/gomod2nix completion fish) \ - --zsh <($out/bin/gomod2nix completion zsh) - '' + '' - wrapProgram $out/bin/gomod2nix --prefix PATH : ${lib.makeBinPath [ go ]} - ''; - - meta = { - description = "Convert applications using Go modules -> Nix"; - homepage = "https://github.com/nix-community/gomod2nix"; - license = lib.licenses.mit; - maintainers = [ lib.maintainers.adisbladis ]; - }; -} diff --git a/overlay.nix b/overlay.nix index 6629049..9010386 100644 --- a/overlay.nix +++ b/overlay.nix @@ -6,5 +6,5 @@ let in { inherit (callPackage ./builder { }) buildGoApplication mkGoEnv; - gomod2nix = callPackage (callPackage ./default.nix { }) { }; + gomod2nix = callPackage ./default.nix { }; }