Compare commits

..

6 commits

9 changed files with 39 additions and 102 deletions

View file

@ -1,10 +1,8 @@
#!/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)

View file

@ -37,7 +37,6 @@
}@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;
@ -97,15 +96,10 @@
# Garbage collection root # # Garbage collection root #
########################### ###########################
packages.${system} = packages.${system} = {
let default = vm.config.system.build.vm;
localPkgs = import ./pkgs { inherit pkgs; }; }
in // import ./pkgs { pkgs = nixpkgs.legacyPackages.${system}; };
{
default = vm.config.system.build.vm;
crowdsec-hub = localPkgs.crowdsec.hub;
crowdsec-firewall-bouncer = localPkgs.crowdsec.firewall-bouncer;
};
################### ###################
# Utility scripts # # Utility scripts #
@ -116,7 +110,7 @@
run-vm = { run-vm = {
type = "app"; type = "app";
program = program =
(pkgs.writeShellScript "" '' (nixpkgs.legacyPackages.${system}.writeShellScript "" ''
${vm.config.system.build.vm.outPath}/bin/run-testvm-vm ${vm.config.system.build.vm.outPath}/bin/run-testvm-vm
'').outPath; '').outPath;
}; };
@ -131,16 +125,16 @@
"./keys/hosts/" "./keys/hosts/"
"./keys/users/" "./keys/users/"
]; ];
nativeBuildInputs = [ sops-nix.packages.${system}.sops-import-keys-hook ];
packages = with pkgs; [ packages = nixpkgs.lib.attrValues {
sops-nix.packages.${system}.sops-init-gpg-key inherit (sops-nix.packages.${system}) sops-import-keys-hook sops-init-gpg-key;
deploy-rs.packages.${system}.default inherit (deploy-rs.packages.${system}) default;
nixpkgs-fmt };
]; };
minecraft = nixpkgs.legacyPackages.${system}.mkShell {
packages = nixpkgs.lib.attrValues { inherit (nixpkgs.legacyPackages.${system}) packwiz; };
}; };
}; };
minecraft = nixpkgs.legacyPackages.${system}.mkShell { packages = [ pkgs.packwiz ]; };
}; };
} }

View file

@ -1,9 +0,0 @@
{ 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 { };
}

View file

@ -1,5 +1,5 @@
{ pkgs }: { pkgs }:
{ pkgs.lib.packagesFromDirectoryRecursive {
crowdsec = import ./crowdsec { inherit pkgs; }; inherit (pkgs) callPackage;
starbound = pkgs.callPackage ./starbound { }; directory = ./packages;
} }

View file

@ -1,37 +0,0 @@
{
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}"
'';
}

View file

@ -1,32 +0,0 @@
#!/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

23
pkgs/update.nu Normal file
View file

@ -0,0 +1,23 @@
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'
}