Format with nixpkgs-fmt

This commit is contained in:
adisbladis 2020-12-03 16:16:08 +01:00
parent bb2553fa3e
commit 929d740884
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7
3 changed files with 53 additions and 42 deletions

View file

@ -29,4 +29,4 @@ jobs:
steps:
- uses: cachix/install-nix-action@v12
- uses: actions/checkout@v1
- run: make
- run: nix-shell --run 'make'

View file

@ -6,52 +6,59 @@
, removeReferencesTo
, pkgs
}:
let
# Patch go to lift restrictions on
# This patch should be upstreamed in Nixpkgs & in Go proper
go = pkgs.go.overrideAttrs(old: {
go = pkgs.go.overrideAttrs (old: {
patches = old.patches ++ [ ./go_no_vendor_checks.patch ];
});
removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
buildGoApplication =
{
modules
, src
, CGO_ENABLED ? "0"
, nativeBuildInputs ? []
, allowGoReference ? false
, meta ? {}
, passthru ? {}
, ...
}@attrs: let
{ modules
, src
, CGO_ENABLED ? "0"
, nativeBuildInputs ? [ ]
, allowGoReference ? false
, meta ? { }
, passthru ? { }
, ...
}@attrs:
let
modulesStruct = builtins.fromTOML (builtins.readFile modules);
vendorEnv = runCommand "vendor-env" {
nativeBuildInputs = [ go ];
json = builtins.toJSON modulesStruct;
vendorEnv = runCommand "vendor-env"
{
nativeBuildInputs = [ go ];
json = builtins.toJSON modulesStruct;
sources = builtins.toJSON (lib.mapAttrs (goPackagePath: meta: let
src = fetchgit {
inherit (meta.fetch) url sha256 rev;
fetchSubmodules = true;
};
srcPath = "${src}/${meta.relPath or ""}";
in srcPath) modulesStruct);
sources = builtins.toJSON (lib.mapAttrs
(goPackagePath: meta:
let
src = fetchgit {
inherit (meta.fetch) url sha256 rev;
fetchSubmodules = true;
};
srcPath = "${src}/${meta.relPath or ""}";
in
srcPath)
modulesStruct);
passAsFile = [ "json" "sources" ];
} (''
mkdir vendor
passAsFile = [ "json" "sources" ];
}
(
''
mkdir vendor
export GOCACHE=$TMPDIR/go-cache
export GOPATH="$TMPDIR/go"
export GOCACHE=$TMPDIR/go-cache
export GOPATH="$TMPDIR/go"
go run ${./symlink.go}
go run ${./symlink.go}
mv vendor $out
'');
mv vendor $out
''
);
removeReferences = [ ] ++ lib.optional (!allowGoReference) go;
@ -180,6 +187,8 @@ let
meta = { platforms = go.meta.platforms or lib.platforms.all; } // meta;
});
in package;
in
package;
in buildGoApplication
in
buildGoApplication

View file

@ -5,16 +5,18 @@
inputs.utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; };
in {
overlay = final: prev: {
buildGoApplication = final.callPackage ./builder { };
gomod2nix = final.callPackage ./default.nix { };
};
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
overlay = final: prev: {
buildGoApplication = final.callPackage ./builder { };
gomod2nix = final.callPackage ./default.nix { };
};
defaultPackage = pkgs.callPackage ./default.nix { };
defaultPackage = pkgs.callPackage ./default.nix { };
});
});
}