Compare commits
No commits in common. "1cf721170b5bc6f8ecd7be2ebcec3e002fc26bfb" and "6d09746bb1afa22a51992478a722c8de3ffea4a3" have entirely different histories.
1cf721170b
...
6d09746bb1
14 changed files with 223 additions and 128 deletions
|
|
@ -1,8 +1,10 @@
|
||||||
#!/usr/bin/env nu
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
|
let shell_files = ls **/*.sh | get name
|
||||||
let nix_files = ls **/*.nix | where name !~ "hardware-configuration.nix|_sources" | get name
|
let nix_files = ls **/*.nix | where name !~ "hardware-configuration.nix|_sources" | get name
|
||||||
|
|
||||||
let linters = [
|
let linters = [
|
||||||
|
([shellcheck] ++ $shell_files)
|
||||||
([nixfmt --check --strict] ++ $nix_files)
|
([nixfmt --check --strict] ++ $nix_files)
|
||||||
([deadnix --fail] ++ $nix_files)
|
([deadnix --fail] ++ $nix_files)
|
||||||
([statix check] ++ $nix_files)
|
([statix check] ++ $nix_files)
|
||||||
|
|
|
||||||
44
flake.nix
44
flake.nix
|
|
@ -37,6 +37,7 @@
|
||||||
}@inputs:
|
}@inputs:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
|
||||||
vm = nixpkgs.lib.nixosSystem {
|
vm = nixpkgs.lib.nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
@ -96,10 +97,15 @@
|
||||||
# Garbage collection root #
|
# Garbage collection root #
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
packages.${system} = {
|
packages.${system} =
|
||||||
|
let
|
||||||
|
localPkgs = import ./pkgs { inherit pkgs; };
|
||||||
|
in
|
||||||
|
{
|
||||||
default = vm.config.system.build.vm;
|
default = vm.config.system.build.vm;
|
||||||
}
|
crowdsec-hub = localPkgs.crowdsec.hub;
|
||||||
// import ./pkgs { pkgs = nixpkgs.legacyPackages.${system}; };
|
crowdsec-firewall-bouncer = localPkgs.crowdsec.firewall-bouncer;
|
||||||
|
};
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Utility scripts #
|
# Utility scripts #
|
||||||
|
|
@ -110,10 +116,26 @@
|
||||||
run-vm = {
|
run-vm = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program =
|
program =
|
||||||
(nixpkgs.legacyPackages.${system}.writeShellScript "" ''
|
(pkgs.writeShellScript "" ''
|
||||||
${vm.config.system.build.vm.outPath}/bin/run-testvm-vm
|
${vm.config.system.build.vm.outPath}/bin/run-testvm-vm
|
||||||
'').outPath;
|
'').outPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
update-crowdsec-packages =
|
||||||
|
let
|
||||||
|
git = pkgs.lib.getExe pkgs.git;
|
||||||
|
nvfetcher = pkgs.lib.getExe pkgs.nvfetcher;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
type = "app";
|
||||||
|
program =
|
||||||
|
(pkgs.writeShellScript "update-crowdsec-packages" ''
|
||||||
|
cd "$(${git} rev-parse --show-toplevel)"
|
||||||
|
cd ./pkgs/crowdsec
|
||||||
|
${nvfetcher}
|
||||||
|
echo 'Remember to update the vendorHash of any go packages!'
|
||||||
|
'').outPath;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
|
|
@ -125,16 +147,16 @@
|
||||||
"./keys/hosts/"
|
"./keys/hosts/"
|
||||||
"./keys/users/"
|
"./keys/users/"
|
||||||
];
|
];
|
||||||
|
nativeBuildInputs = [ sops-nix.packages.${system}.sops-import-keys-hook ];
|
||||||
|
|
||||||
packages = nixpkgs.lib.attrValues {
|
packages = with pkgs; [
|
||||||
inherit (sops-nix.packages.${system}) sops-import-keys-hook sops-init-gpg-key;
|
sops-nix.packages.${system}.sops-init-gpg-key
|
||||||
inherit (deploy-rs.packages.${system}) default;
|
deploy-rs.packages.${system}.default
|
||||||
|
nixpkgs-fmt
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
minecraft = nixpkgs.legacyPackages.${system}.mkShell {
|
minecraft = nixpkgs.legacyPackages.${system}.mkShell { packages = [ pkgs.packwiz ]; };
|
||||||
packages = nixpkgs.lib.attrValues { inherit (nixpkgs.legacyPackages.${system}) packwiz; };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
44
pkgs/crowdsec/_sources/generated.json
Normal file
44
pkgs/crowdsec/_sources/generated.json
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
"crowdsec-firewall-bouncer": {
|
||||||
|
"cargoLocks": null,
|
||||||
|
"date": null,
|
||||||
|
"extract": null,
|
||||||
|
"name": "crowdsec-firewall-bouncer",
|
||||||
|
"passthru": null,
|
||||||
|
"pinned": false,
|
||||||
|
"src": {
|
||||||
|
"deepClone": false,
|
||||||
|
"fetchSubmodules": false,
|
||||||
|
"leaveDotGit": false,
|
||||||
|
"name": null,
|
||||||
|
"owner": "crowdsecurity",
|
||||||
|
"repo": "cs-firewall-bouncer",
|
||||||
|
"rev": "v0.0.34",
|
||||||
|
"sha256": "sha256-lDO9pwPkbI+FDTdXBv03c0p8wbkRUiIDNl1ip3AZo2g=",
|
||||||
|
"sparseCheckout": [],
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"version": "v0.0.34"
|
||||||
|
},
|
||||||
|
"crowdsec-hub": {
|
||||||
|
"cargoLocks": null,
|
||||||
|
"date": "2025-08-17",
|
||||||
|
"extract": null,
|
||||||
|
"name": "crowdsec-hub",
|
||||||
|
"passthru": null,
|
||||||
|
"pinned": false,
|
||||||
|
"src": {
|
||||||
|
"deepClone": false,
|
||||||
|
"fetchSubmodules": false,
|
||||||
|
"leaveDotGit": false,
|
||||||
|
"name": null,
|
||||||
|
"owner": "crowdsecurity",
|
||||||
|
"repo": "hub",
|
||||||
|
"rev": "fc59f78180f3edfce76df3e77b001c454f567d3d",
|
||||||
|
"sha256": "sha256-Ejx3ta05SMvV/Dj7wy2iF9QYbGoRvxPB3+QuCIoTX4Q=",
|
||||||
|
"sparseCheckout": [],
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"version": "fc59f78180f3edfce76df3e77b001c454f567d3d"
|
||||||
|
}
|
||||||
|
}
|
||||||
27
pkgs/crowdsec/_sources/generated.nix
Normal file
27
pkgs/crowdsec/_sources/generated.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# This file was generated by nvfetcher, please do not modify it manually.
|
||||||
|
{ fetchgit, fetchurl, fetchFromGitHub, dockerTools }:
|
||||||
|
{
|
||||||
|
crowdsec-firewall-bouncer = {
|
||||||
|
pname = "crowdsec-firewall-bouncer";
|
||||||
|
version = "v0.0.34";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "crowdsecurity";
|
||||||
|
repo = "cs-firewall-bouncer";
|
||||||
|
rev = "v0.0.34";
|
||||||
|
fetchSubmodules = false;
|
||||||
|
sha256 = "sha256-lDO9pwPkbI+FDTdXBv03c0p8wbkRUiIDNl1ip3AZo2g=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
crowdsec-hub = {
|
||||||
|
pname = "crowdsec-hub";
|
||||||
|
version = "fc59f78180f3edfce76df3e77b001c454f567d3d";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "crowdsecurity";
|
||||||
|
repo = "hub";
|
||||||
|
rev = "fc59f78180f3edfce76df3e77b001c454f567d3d";
|
||||||
|
fetchSubmodules = false;
|
||||||
|
sha256 = "sha256-Ejx3ta05SMvV/Dj7wy2iF9QYbGoRvxPB3+QuCIoTX4Q=";
|
||||||
|
};
|
||||||
|
date = "2025-08-17";
|
||||||
|
};
|
||||||
|
}
|
||||||
9
pkgs/crowdsec/default.nix
Normal file
9
pkgs/crowdsec/default.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{ pkgs }:
|
||||||
|
let
|
||||||
|
sources = pkgs.callPackage ./_sources/generated.nix { };
|
||||||
|
callPackage = pkgs.lib.callPackageWith (pkgs // { inherit sources; });
|
||||||
|
in
|
||||||
|
{
|
||||||
|
hub = callPackage ./hub.nix { };
|
||||||
|
firewall-bouncer = callPackage ./firewall-bouncer.nix { };
|
||||||
|
}
|
||||||
26
pkgs/crowdsec/firewall-bouncer.nix
Normal file
26
pkgs/crowdsec/firewall-bouncer.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
sources,
|
||||||
|
buildGoModule,
|
||||||
|
envsubst,
|
||||||
|
coreutils,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
envsubstBin = lib.getExe envsubst;
|
||||||
|
in
|
||||||
|
buildGoModule {
|
||||||
|
inherit (sources.crowdsec-firewall-bouncer) pname version src;
|
||||||
|
|
||||||
|
vendorHash = "sha256-SbpclloBgd9vffC0lBduGRqPOqmzQ0J91/KeDHCh0jo=";
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $out/lib/systemd/system
|
||||||
|
|
||||||
|
CFG=/var/lib/crowdsec/config BIN=$out/bin/cs-firewall-bouncer ${envsubstBin} \
|
||||||
|
-i ./config/crowdsec-firewall-bouncer.service \
|
||||||
|
-o $out/lib/systemd/system/crowdsec-firewall-bouncer.service
|
||||||
|
|
||||||
|
substituteInPlace $out/lib/systemd/system/crowdsec-firewall-bouncer.service \
|
||||||
|
--replace-fail /bin/sleep ${coreutils}/bin/sleep
|
||||||
|
'';
|
||||||
|
}
|
||||||
1
pkgs/crowdsec/hub.nix
Normal file
1
pkgs/crowdsec/hub.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ sources }: sources.crowdsec-hub.src
|
||||||
7
pkgs/crowdsec/nvfetcher.toml
Normal file
7
pkgs/crowdsec/nvfetcher.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[crowdsec-hub]
|
||||||
|
src.git = "https://github.com/crowdsecurity/hub.git"
|
||||||
|
fetch.github = "crowdsecurity/hub"
|
||||||
|
|
||||||
|
[crowdsec-firewall-bouncer]
|
||||||
|
src.github = "crowdsecurity/cs-firewall-bouncer"
|
||||||
|
fetch.github = "crowdsecurity/cs-firewall-bouncer"
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{ pkgs }:
|
{ pkgs }:
|
||||||
pkgs.lib.packagesFromDirectoryRecursive {
|
{
|
||||||
inherit (pkgs) callPackage;
|
crowdsec = import ./crowdsec { inherit pkgs; };
|
||||||
directory = ./packages;
|
starbound = pkgs.callPackage ./starbound { };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
fetchFromGitHub,
|
|
||||||
buildGoModule,
|
|
||||||
envsubst,
|
|
||||||
coreutils,
|
|
||||||
|
|
||||||
writers,
|
|
||||||
nix-update,
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
envsubstBin = lib.getExe envsubst;
|
|
||||||
in
|
|
||||||
buildGoModule (drv: {
|
|
||||||
pname = "crowdsec-firewall-bouncer";
|
|
||||||
version = drv.src.rev;
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "crowdsecurity";
|
|
||||||
repo = "cs-firewall-bouncer";
|
|
||||||
rev = "0.0.34";
|
|
||||||
sha256 = "sha256-lDO9pwPkbI+FDTdXBv03c0p8wbkRUiIDNl1ip3AZo2g=";
|
|
||||||
};
|
|
||||||
|
|
||||||
vendorHash = "sha256-SbpclloBgd9vffC0lBduGRqPOqmzQ0J91/KeDHCh0jo=";
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
mkdir -p $out/lib/systemd/system
|
|
||||||
|
|
||||||
CFG=/var/lib/crowdsec/config BIN=$out/bin/cs-firewall-bouncer ${envsubstBin} \
|
|
||||||
-i ./config/crowdsec-firewall-bouncer.service \
|
|
||||||
-o $out/lib/systemd/system/crowdsec-firewall-bouncer.service
|
|
||||||
|
|
||||||
substituteInPlace $out/lib/systemd/system/crowdsec-firewall-bouncer.service \
|
|
||||||
--replace-fail /bin/sleep ${coreutils}/bin/sleep
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru.updateScript =
|
|
||||||
writers.writeNuBin "update-crowdsec-firewall-bouncer"
|
|
||||||
{
|
|
||||||
makeWrapperArgs = [
|
|
||||||
"--prefix"
|
|
||||||
"PATH"
|
|
||||||
":"
|
|
||||||
(lib.makeBinPath [ nix-update ])
|
|
||||||
];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
nix-update --flake --format crowdsec-firewall-bouncer
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
fetchFromGitHub,
|
|
||||||
stdenvNoCC,
|
|
||||||
|
|
||||||
writers,
|
|
||||||
nix-update,
|
|
||||||
}:
|
|
||||||
# Using `mkDerivation` so nix-update can pick up the version
|
|
||||||
stdenvNoCC.mkDerivation (drv: {
|
|
||||||
pname = "crowdsec-hub";
|
|
||||||
version = drv.src.rev;
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "crowdsecurity";
|
|
||||||
repo = "hub";
|
|
||||||
rev = "fc59f78180f3edfce76df3e77b001c454f567d3d";
|
|
||||||
hash = "sha256-Ejx3ta05SMvV/Dj7wy2iF9QYbGoRvxPB3+QuCIoTX4Q=";
|
|
||||||
};
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
cp -r $src $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru.updateScript =
|
|
||||||
writers.writeNuBin "update-crowdsec-hub"
|
|
||||||
{
|
|
||||||
makeWrapperArgs = [
|
|
||||||
"--prefix"
|
|
||||||
"PATH"
|
|
||||||
":"
|
|
||||||
(lib.makeBinPath [ nix-update ])
|
|
||||||
];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
nix-update --flake --format --version=branch crowdsec-hub
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
37
pkgs/starbound/default.nix
Normal file
37
pkgs/starbound/default.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
lib,
|
||||||
|
makeWrapper,
|
||||||
|
patchelf,
|
||||||
|
steamPackages,
|
||||||
|
replace-secret,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
# Use the directory in which starbound is installed so steamcmd
|
||||||
|
# doesn't have to be reinstalled constantly (we're using DynamicUser
|
||||||
|
# with StateDirectory to persist this).
|
||||||
|
steamcmd = steamPackages.steamcmd.override { steamRoot = "/var/lib/starbound/.steamcmd"; };
|
||||||
|
wrapperPath = lib.makeBinPath [
|
||||||
|
patchelf
|
||||||
|
steamcmd
|
||||||
|
replace-secret
|
||||||
|
];
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "starbound-update-script";
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
dontUnpack = true;
|
||||||
|
patchPhase = ''
|
||||||
|
interpreter="$(cat $NIX_CC/nix-support/dynamic-linker)"
|
||||||
|
substitute ${./launch-starbound.sh} launch-starbound --subst-var interpreter
|
||||||
|
'';
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp launch-starbound $out/bin/launch-starbound
|
||||||
|
chmod +x $out/bin/launch-starbound
|
||||||
|
'';
|
||||||
|
postFixup = ''
|
||||||
|
wrapProgram $out/bin/launch-starbound \
|
||||||
|
--prefix PATH : "${wrapperPath}"
|
||||||
|
'';
|
||||||
|
}
|
||||||
32
pkgs/starbound/launch-starbound.sh
Normal file
32
pkgs/starbound/launch-starbound.sh
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if ! [[ -v STATE_DIRECTORY && -v CREDENTIALS_DIRECTORY ]]; then
|
||||||
|
echo "Error: Runtime dir or credential not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update the server to the latest version
|
||||||
|
echo "Updating/installing starbound"
|
||||||
|
|
||||||
|
mkdir -p "${STATE_DIRECTORY}/.steamcmd"
|
||||||
|
steamcmd <<EOF
|
||||||
|
force_install_dir $STATE_DIRECTORY
|
||||||
|
login tlater $(cat "$CREDENTIALS_DIRECTORY/steam")
|
||||||
|
app_update 211820
|
||||||
|
quit
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Updating config"
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
mkdir -p ./storage
|
||||||
|
cp "$1" ./storage/starbound_server.config
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running starbound server"
|
||||||
|
patchelf --set-interpreter '@interpreter@' ./linux/starbound_server
|
||||||
|
# Must be run from the directory that the binary is in (why do game
|
||||||
|
# devs do this?)
|
||||||
|
cd linux
|
||||||
|
./starbound_server
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
use std/log
|
|
||||||
|
|
||||||
let packages_with_updatescript = (
|
|
||||||
nix flake show --json
|
|
||||||
| from json
|
|
||||||
| $in.packages.x86_64-linux
|
|
||||||
| columns
|
|
||||||
| filter {|p| nix eval $'.#($p)' --apply 'builtins.hasAttr "updateScript"' | $in == 'true' }
|
|
||||||
)
|
|
||||||
|
|
||||||
for $package in $packages_with_updatescript {
|
|
||||||
log info $'Updating ($package)'
|
|
||||||
nix run $'.#($package).updateScript'
|
|
||||||
}
|
|
||||||
|
|
||||||
log info 'Committing changes'
|
|
||||||
|
|
||||||
try {
|
|
||||||
git add pkgs
|
|
||||||
git commit -m 'update(pkgs): Update sources of all downstream packages'
|
|
||||||
} catch {
|
|
||||||
log warning 'No changes to commit'
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue