Hoang Nguyen
c991be4740
Nothing to see here yet, except: - Add `nogo` support. Closes #2 (I only use the analyzers from golang.org/x/tools, so nogo right now is not really on par with golangci-lint) - Remove golangci-lint - Fill out providers.toml file (it was daunting -_-) - Update bazel deps
109 lines
3.4 KiB
Nix
109 lines
3.4 KiB
Nix
# SPDX-FileCopyrightText: 2023 Hoang Nguyen <folliekazetani@protonmail.com>
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
treefmt-nix = {
|
|
url = "github:numtide/treefmt-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
flake-compat = {
|
|
url = "github:edolstra/flake-compat";
|
|
flake = false;
|
|
};
|
|
};
|
|
outputs = { self, nixpkgs, flake-utils, treefmt-nix, ... }:
|
|
flake-utils.lib.eachDefaultSystem
|
|
(system:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
|
|
|
|
# Information to be put into reuse's arguments
|
|
copyright = "Hoang Nguyen <folliekazetani@protonmail.com>";
|
|
licenses = [ "Apache-2.0" "CC0-1.0" ];
|
|
|
|
apps = {
|
|
# Wrap bazel with `nix run .#bazel`, for convenience
|
|
inherit (pkgs) bazel cue;
|
|
|
|
# Run `go mod tidy` then update BUILD.bazel files
|
|
gazelle =
|
|
let
|
|
arguments = [
|
|
[ "@rules_go//go" "--" "mod" "tidy" "-v" ]
|
|
[ "//:gazelle" ]
|
|
];
|
|
in
|
|
pkgs.writeShellScriptBin "gazelle-update" (with lib; concatStringsSep "\n"
|
|
(forEach
|
|
arguments
|
|
(x: "${pkgs.bazel}/bin/bazel run " + (concatStringsSep " " x))
|
|
)
|
|
);
|
|
|
|
# FIXME: doesn't work yet (https://github.com/cue-lang/cue/issues/2654)
|
|
package-metaschema = with pkgs;
|
|
writeShellScriptBin "package-metaschema" ''
|
|
set -e
|
|
INPUT_SCHEMA=/tmp/pulumi.json
|
|
OUTFILE=./schemata/pulumi/package.cue
|
|
|
|
${curl}/bin/curl -fsSL \
|
|
-o "$INPUT_SCHEMA" \
|
|
https://raw.githubusercontent.com/pulumi/pulumi/master/pkg/codegen/schema/pulumi.json
|
|
|
|
${cue}/bin/cue import --force \
|
|
--package="pulumi" \
|
|
--path="#Package" \
|
|
--outfile="$OUTFILE" \
|
|
"$INPUT_SCHEMA"
|
|
|
|
# Re-add the SPDX header, to make `reuse lint` happy
|
|
${reuse}/bin/reuse annotate \
|
|
--copyright="${copyright}" \
|
|
--license="${builtins.elemAt licenses 0}" \
|
|
--style=c \
|
|
"$OUTFILE"
|
|
'';
|
|
}
|
|
// (lib.listToAttrs (
|
|
builtins.map
|
|
(x: {
|
|
name = x;
|
|
value = with pkgs; writeShellScriptBin x ''
|
|
${bazel-buildtools}/bin/${x} "$@"
|
|
'';
|
|
})
|
|
[ "buildifier" "buildozer" ]));
|
|
in
|
|
{
|
|
apps = lib.mapAttrs
|
|
(_: value:
|
|
flake-utils.lib.mkApp { drv = value; })
|
|
apps;
|
|
|
|
formatter = treefmtEval.config.build.wrapper;
|
|
|
|
checks = {
|
|
treefmt = treefmtEval.config.build.check self;
|
|
license = pkgs.writeShellScriptBin "reuse-lint" ''
|
|
${pkgs.reuse}/bin/reuse lint
|
|
'';
|
|
};
|
|
|
|
devShells.default = with pkgs; mkShellNoCC {
|
|
name = "cuelumi-dev-shell";
|
|
inputsFrom = [ treefmtEval.config.build.devShell ];
|
|
packages = [ bazel ];
|
|
};
|
|
}
|
|
);
|
|
}
|