Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nix configuration #8452

Merged
merged 13 commits into from
Nov 16, 2023
24 changes: 21 additions & 3 deletions .github/workflows/nix-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@ on:
- "flake.nix"
- "nix/**"
jobs:
tests:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix run .#lint
- run: nix build --print-build-logs
- run: nix run --print-build-logs .#lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix run --print-build-logs .#test
packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix build --print-build-logs .#logcli
- run: nix build --print-build-logs .#loki
- run: nix build --print-build-logs .#loki-canary
- run: nix build --print-build-logs .#promtail
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ linters-settings:
- desc: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log"
pkg: github.com/go-kit/kit/log

misspell:
ignore-words:
- strat

linters:
enable:
- errcheck
Expand Down
30 changes: 24 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 28 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@
in
{
overlays = {
golangci-lint = import ./nix/overlays/golangci-lint.nix;
helm-docs = import ./nix/overlays/helm-docs.nix;
default = nix.overlay;
};
} //
flake-utils.lib.eachDefaultSystem (system:
let

pkgs = import nixpkgs {
inherit system;
overlays = [
(import ./nix/overlays/golangci-lint.nix)
(import ./nix/overlays/helm-docs.nix)
nix.overlay
];
config = { allowUnfree = true; };
Expand All @@ -40,9 +35,12 @@

packages = with pkgs; {
inherit
logcli
loki
loki-canary
loki-helm-test
loki-helm-test-docker;
loki-helm-test-docker
promtail;
};

apps = {
Expand All @@ -56,21 +54,30 @@
}/bin/lint.sh";
};

test = {
type = "app";
program = with pkgs; "${
(writeShellScriptBin "test.sh" ''
${loki.overrideAttrs(old: { doCheck = true; })}/bin/loki --version
'')
}/bin/test.sh";
};

loki = {
type = "app";
program = with pkgs; "${loki.overrideAttrs(old: rec { doCheck = false; })}/bin/loki";
program = with pkgs; "${loki}/bin/loki";
};
promtail = {
type = "app";
program = with pkgs; "${loki.overrideAttrs(old: rec { doCheck = false; })}/bin/promtail";
program = with pkgs; "${promtail}/bin/promtail";
};
logcli = {
type = "app";
program = with pkgs; "${loki.overrideAttrs(old: rec { doCheck = false; })}/bin/logcli";
program = with pkgs; "${logcli}/bin/logcli";
};
loki-canary = {
type = "app";
program = with pkgs; "${loki.overrideAttrs(old: rec { doCheck = false; })}/bin/loki-canary";
program = with pkgs; "${loki-canary}/bin/loki-canary";
};
loki-helm-test = {
type = "app";
Expand All @@ -80,20 +87,22 @@

devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
(import ./packages/chart-releaser.nix {
inherit (prev) pkgs lib buildGoModule fetchFromGitHub;
})

chart-testing
faillint
gcc
go
systemd
yamllint
nixpkgs-fmt
statix
nettools

golangci-lint
gotools
helm-docs
faillint
chart-testing
chart-releaser
nettools
nixpkgs-fmt
statix
systemd
yamllint
];
};
});
Expand Down
50 changes: 42 additions & 8 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,55 @@
rev = gitRevision;
};
in
{
rec {
inherit (loki-helm-test) loki-helm-test loki-helm-test-docker;

loki = prev.callPackage ./loki.nix {
loki = prev.callPackage ./packages/loki.nix {
inherit imageTag;
version = shortGitRevsion;
pkgs = prev;
};

faillint = prev.callPackage ./faillint.nix {
inherit (prev) lib buildGoModule fetchFromGitHub;
};
logcli = loki.overrideAttrs (oldAttrs: rec {
pname = "logcli";

chart-releaser = prev.callPackage ./chart-releaser.nix {
inherit (prev) pkgs lib buildGoModule fetchFromGitHub;
};
buildPhase = ''
export GOCACHE=$TMPDIR/go-cache
make clean logcli
'';

installPhase = ''
mkdir -p $out/bin
install -m755 cmd/logcli/logcli $out/bin/logcli
'';
});

loki-canary = loki.overrideAttrs (oldAttrs: rec {
pname = "loki-canary";

buildPhase = ''
export GOCACHE=$TMPDIR/go-cache
make clean loki-canary
'';

installPhase = ''
mkdir -p $out/bin
install -m755 cmd/loki-canary/loki-canary $out/bin/loki-canary
'';
});

promtail = loki.overrideAttrs (oldAttrs: rec {
pname = "promtail";

buildPhase = ''
export GOCACHE=$TMPDIR/go-cache
make clean promtail
'';

installPhase = ''
mkdir -p $out/bin
install -m755 clients/cmd/promtail/promtail $out/bin/promtail
'';
});
};
}
28 changes: 0 additions & 28 deletions nix/overlays/golangci-lint.nix

This file was deleted.

25 changes: 0 additions & 25 deletions nix/overlays/helm-docs.nix

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading
Loading