mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-25 20:50:44 -06:00
Compare commits
1 commit
69a164e502
...
2369d71814
Author | SHA1 | Date | |
---|---|---|---|
2369d71814 |
8 changed files with 171 additions and 36 deletions
1
.github/workflows/update.yml
vendored
1
.github/workflows/update.yml
vendored
|
@ -16,7 +16,6 @@ jobs:
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: daylin-bot/actions/setup@main
|
- uses: daylin-bot/actions/setup@main
|
||||||
- uses: ./.github/actions/clean-disk
|
|
||||||
|
|
||||||
- run: git checkout -B flake-lock
|
- run: git checkout -B flake-lock
|
||||||
|
|
||||||
|
|
46
flake.lock
46
flake.lock
|
@ -499,11 +499,11 @@
|
||||||
"lix": {
|
"lix": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722529543,
|
"lastModified": 1722371572,
|
||||||
"narHash": "sha256-IDr+fHKwmpaWi4hzD2RYLdiaGEFOrsFm+NeHKETxMhk=",
|
"narHash": "sha256-RFyGpPsBSO9Jkt2zD7wmN89LTeJ5AaazCK7L6VGOtAw=",
|
||||||
"rev": "61a93d53081141d4ab222dcb939dd5caa8ffc767",
|
"rev": "c347d3df8f1aebe124b6a3179d4dd83ccadd44b5",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/61a93d53081141d4ab222dcb939dd5caa8ffc767.tar.gz"
|
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/c347d3df8f1aebe124b6a3179d4dd83ccadd44b5.tar.gz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
|
@ -522,11 +522,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722485024,
|
"lastModified": 1722377924,
|
||||||
"narHash": "sha256-+7RReWaFQUO8MfAhJYNm4FkALuM3rPGy2AlXXv9Jmc8=",
|
"narHash": "sha256-w8C3AWOyasmmIuVSH8YgmpersZ89RIwbDs+vctK9CPg=",
|
||||||
"rev": "e350380d72f94035c309e19fda2fd550f6ab7376",
|
"rev": "550352df73aa82788ad1913b78b2776e9f569072",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/e350380d72f94035c309e19fda2fd550f6ab7376.tar.gz"
|
"url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/550352df73aa82788ad1913b78b2776e9f569072.tar.gz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
|
@ -680,11 +680,11 @@
|
||||||
"nixpkgs": "nixpkgs_7"
|
"nixpkgs": "nixpkgs_7"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722530466,
|
"lastModified": 1722346555,
|
||||||
"narHash": "sha256-9YvLtuLAA+LVmfrvlOsynHkS0DRCYnHFEp72NfXFVnc=",
|
"narHash": "sha256-32XSW4hicoXnVAA8hQ77u6AgtWXiXsPIC2H52WckWXk=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs-wayland",
|
"repo": "nixpkgs-wayland",
|
||||||
"rev": "0bbe640011f1350933109f5450b15f9bd1fb5e9f",
|
"rev": "8badd76557356d94681c0547a4f6ffe7dfd42597",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -743,11 +743,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_5": {
|
"nixpkgs_5": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722415718,
|
"lastModified": 1722141560,
|
||||||
"narHash": "sha256-5US0/pgxbMksF92k1+eOa8arJTJiPvsdZj9Dl+vJkM4=",
|
"narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "c3392ad349a5227f4a3464dce87bcc5046692fce",
|
"rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -775,11 +775,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_7": {
|
"nixpkgs_7": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722421184,
|
"lastModified": 1722185531,
|
||||||
"narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=",
|
"narHash": "sha256-veKR07psFoJjINLC8RK4DiLniGGMgF3QMlS4tb74S6k=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58",
|
"rev": "52ec9ac3b12395ad677e8b62106f0b98c1f8569d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -852,11 +852,11 @@
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722523856,
|
"lastModified": 1722365615,
|
||||||
"narHash": "sha256-hjdIYAuQMWLtlxxj9GpgnfFgmGJhxDDYXnBvEVeNXG8=",
|
"narHash": "sha256-EQVy6zNJRQGUT24+T60d/NgzeYDlw8/LPwqHGkQL3FA=",
|
||||||
"owner": "roc-lang",
|
"owner": "roc-lang",
|
||||||
"repo": "roc",
|
"repo": "roc",
|
||||||
"rev": "790eabd933e13b0836c6ec243c77f873a5956966",
|
"rev": "c59de3cce1227e266ab722f63f045fcc817cdc6e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1151,11 +1151,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722475688,
|
"lastModified": 1722302526,
|
||||||
"narHash": "sha256-b9q/NoJ3I5LtXVvxxjxNRxDEVMd+1daVldCyAYH7aCU=",
|
"narHash": "sha256-91k+3+RQodDH2BqzupmDJz75eVzePZrv/1CnZHW2Gkk=",
|
||||||
"owner": "Cloudef",
|
"owner": "Cloudef",
|
||||||
"repo": "zig2nix",
|
"repo": "zig2nix",
|
||||||
"rev": "b368a9170c6d6727375d2f43baf2565280e86019",
|
"rev": "b00597a45ab999dae54c09b5cd9f4576e32f6868",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{ enabled, ... }:
|
{ pkgs, enabled, ... }:
|
||||||
{
|
{
|
||||||
services.resolved = enabled;
|
services.resolved = enabled;
|
||||||
|
|
||||||
services.fail2ban = {
|
services.fail2ban = {
|
||||||
|
package = pkgs.callPackage ../../pkgs/fail2ban { };
|
||||||
enable = true;
|
enable = true;
|
||||||
maxretry = 5;
|
maxretry = 5;
|
||||||
bantime = "24h";
|
bantime = "24h";
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
quarto
|
quarto
|
||||||
cachix
|
cachix
|
||||||
graphviz
|
graphviz
|
||||||
# nix-du # failing to build suddenly?
|
nix-du
|
||||||
# https://github.com/symphorien/nix-du/issues/23
|
|
||||||
# maybe llvm related?
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
98
pkgs/fail2ban/default.nix
Normal file
98
pkgs/fail2ban/default.nix
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
# pkg: https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/security/fail3ban/default.nix
|
||||||
|
# module: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/security/fail2ban.nix
|
||||||
|
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
fetchFromGitHub,
|
||||||
|
python3,
|
||||||
|
installShellFiles,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
|
||||||
|
rev = "8170e9fe75fd2c2c4c51a1d9972b683401cddccb";
|
||||||
|
in
|
||||||
|
|
||||||
|
python3.pkgs.buildPythonApplication {
|
||||||
|
pname = "fail2ban";
|
||||||
|
# version = "1.0.2";
|
||||||
|
version = "1.1.0-${builtins.substring 0 8 rev}";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "fail2ban";
|
||||||
|
repo = "fail2ban";
|
||||||
|
hash = "sha256-cOHpUPEEp3FoRjywun205ugbV+I51EWVTGwZS0jNRwE=";
|
||||||
|
# rev = version;
|
||||||
|
inherit rev;
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"man"
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = [ installShellFiles ];
|
||||||
|
|
||||||
|
pythonPath = lib.optionals stdenv.isLinux (
|
||||||
|
with python3.pkgs;
|
||||||
|
[
|
||||||
|
systemd
|
||||||
|
pyinotify
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
preConfigure = ''
|
||||||
|
for i in config/action.d/sendmail*.conf; do
|
||||||
|
substituteInPlace $i \
|
||||||
|
--replace /usr/sbin/sendmail sendmail
|
||||||
|
done
|
||||||
|
|
||||||
|
substituteInPlace config/filter.d/dovecot.conf \
|
||||||
|
--replace dovecot.service dovecot2.service
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
preInstall = ''
|
||||||
|
substituteInPlace setup.py --replace /usr/share/doc/ share/doc/
|
||||||
|
|
||||||
|
# see https://github.com/NixOS/nixpkgs/issues/4968
|
||||||
|
${python3.pythonOnBuildForHost.interpreter} setup.py install_data --install-dir=$out --root=$out
|
||||||
|
'';
|
||||||
|
|
||||||
|
postInstall =
|
||||||
|
let
|
||||||
|
sitePackages = "$out/${python3.sitePackages}";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
install -m 644 -D -t "$out/lib/systemd/system" build/fail2ban.service
|
||||||
|
# Replace binary paths
|
||||||
|
sed -i "s#build/bdist.*/wheel/fail2ban.*/scripts/#$out/bin/#g" $out/lib/systemd/system/fail2ban.service
|
||||||
|
# Delete creating the runtime directory, systemd does that
|
||||||
|
sed -i "/ExecStartPre/d" $out/lib/systemd/system/fail2ban.service
|
||||||
|
|
||||||
|
# see https://github.com/NixOS/nixpkgs/issues/4968
|
||||||
|
rm -r "${sitePackages}/etc"
|
||||||
|
|
||||||
|
installManPage man/*.[1-9]
|
||||||
|
|
||||||
|
# This is a symlink to the build python version created by `updatePyExec`, seemingly to assure the same python version is used?
|
||||||
|
rm $out/bin/fail2ban-python
|
||||||
|
ln -s ${python3.interpreter} $out/bin/fail2ban-python
|
||||||
|
|
||||||
|
''
|
||||||
|
+ lib.optionalString stdenv.isLinux ''
|
||||||
|
# see https://github.com/NixOS/nixpkgs/issues/4968
|
||||||
|
rm -r "${sitePackages}/usr"
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
homepage = "https://www.fail2ban.org/";
|
||||||
|
description = "Program that scans log files for repeated failing login attempts and bans IP addresses";
|
||||||
|
license = licenses.gpl2Plus;
|
||||||
|
maintainers = with maintainers; [
|
||||||
|
eelco
|
||||||
|
lovek323
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ var dryCmd = &cobra.Command{
|
||||||
Use: "dry",
|
Use: "dry",
|
||||||
Short: "poor man's nix flake check",
|
Short: "poor man's nix flake check",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
oizys.Dry( minimal, args...)
|
oizys.Dry(verbose, minimal, args...)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,13 +191,13 @@ func parseDryRun2(buf string) ([]string, []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: refactor to account for --debug and not --verbose?
|
// TODO: refactor to account for --debug and not --verbose?
|
||||||
func showDryRunResult(nixOutput string) {
|
func showDryRunResult(nixOutput string, verbose bool) {
|
||||||
toBuild, toFetch := parseDryRun(nixOutput)
|
toBuild, toFetch := parseDryRun(nixOutput)
|
||||||
toFetch.Show(o.debug)
|
toFetch.Show(o.debug)
|
||||||
toBuild.Show(true)
|
toBuild.Show(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Dry(minimal bool, rest ...string) {
|
func Dry(verbose bool, minimal bool, rest ...string) {
|
||||||
cmd := exec.Command("nix", "build", "--dry-run")
|
cmd := exec.Command("nix", "build", "--dry-run")
|
||||||
cmd.Args = append(cmd.Args, rest...)
|
cmd.Args = append(cmd.Args, rest...)
|
||||||
if o.resetCache {
|
if o.resetCache {
|
||||||
|
@ -226,7 +226,7 @@ func Dry(minimal bool, rest ...string) {
|
||||||
if minimal {
|
if minimal {
|
||||||
fmt.Println(string(result))
|
fmt.Println(string(result))
|
||||||
} else {
|
} else {
|
||||||
showDryRunResult(string(result))
|
showDryRunResult(string(result), verbose)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ShowFailedOutput(buf []byte) {
|
func ShowFailedOutput(buf []byte) {
|
||||||
|
@ -22,23 +23,55 @@ func ShowFailedOutput(buf []byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: seperate parsing and displaying of packages
|
||||||
|
func terminalSize() (int, int) {
|
||||||
|
fd := os.Stdout.Fd()
|
||||||
|
if !term.IsTerminal(int(fd)) {
|
||||||
|
log.Error("failed to get terminal size")
|
||||||
|
return 80, 0
|
||||||
|
}
|
||||||
|
w, h, err := term.GetSize(int(fd))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
return w, h
|
||||||
|
}
|
||||||
|
|
||||||
type Packages struct {
|
type Packages struct {
|
||||||
desc string
|
desc string
|
||||||
names []string
|
names []string
|
||||||
|
pad int
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParsePackages(lines []string, desc string) *Packages {
|
func ParsePackages(lines []string, desc string) *Packages {
|
||||||
|
w, _ := terminalSize()
|
||||||
|
maxAcceptable := (w / 4) - 1
|
||||||
|
maxLen := 0
|
||||||
names := make([]string, len(lines))
|
names := make([]string, len(lines))
|
||||||
for i, pkg := range lines {
|
for i, pkg := range lines {
|
||||||
s := strings.SplitN(pkg, "-", 2)
|
s := strings.SplitN(pkg, "-", 2)
|
||||||
if len(s) != 2 {
|
if len(s) != 2 {
|
||||||
log.Fatalf("failed to trim hash path from this line: %s\n ", pkg)
|
log.Fatalf("failed to trim hash path from this line: %s\n ", pkg)
|
||||||
}
|
}
|
||||||
name := strings.Replace(s[1], ".drv", "", 1)
|
name := ellipsis(strings.Replace(s[1], ".drv", "", 1), maxAcceptable)
|
||||||
|
if nameLen := len(name); nameLen > maxLen {
|
||||||
|
maxLen = nameLen
|
||||||
|
}
|
||||||
names[i] = name
|
names[i] = name
|
||||||
}
|
}
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
return &Packages{names: names, desc: desc}
|
return &Packages{names: names, pad: maxLen + 1, desc: desc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ellipsis(s string, maxLen int) string {
|
||||||
|
runes := []rune(s)
|
||||||
|
if len(runes) <= maxLen {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
if maxLen < 3 {
|
||||||
|
maxLen = 3
|
||||||
|
}
|
||||||
|
return string(runes[0:maxLen-3]) + "..."
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Packages) Show(verbose bool) {
|
func (p *Packages) Show(verbose bool) {
|
||||||
|
@ -48,8 +81,14 @@ func (p *Packages) Show(verbose bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgs := p.names
|
pkgs := p.names
|
||||||
for _, pkg := range pkgs {
|
w, _ := terminalSize()
|
||||||
fmt.Printf(" %s\n", pkg)
|
nCols := w / p.pad
|
||||||
|
fmt.Printf("%s\n", strings.Repeat("-", w))
|
||||||
|
for i, pkg := range pkgs {
|
||||||
|
fmt.Printf("%-*s", p.pad, pkg)
|
||||||
|
if (i+1)%nCols == 0 {
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue