vendorhash calc automation

This commit is contained in:
41666 2025-03-24 23:21:33 -07:00
parent e1909b04b2
commit 1321374a90
7 changed files with 40 additions and 52 deletions

4
.gitignore vendored
View file

@ -1,2 +1,4 @@
.direnv .direnv
.env .env
.storage
result

22
default.nix Normal file
View file

@ -0,0 +1,22 @@
{
pkgs ? import <nixpkgs> {},
vendorHash ? "sha256-YRteL/3725Hm+fdXO+wPYX9nFNbdAHsAwCo3xuVPrwI=",
}:
rec {
default = roleypoly;
roleypoly = pkgs.buildGoModule {
inherit vendorHash;
name = "roleypoly";
src = ./.;
};
container = pkgs.dockerTools.buildImage {
name = "roleypoly/roleypoly";
tag = "latest";
copyToRoot = [
pkgs.dockerTools.caCertificates
];
config = {
Cmd = [ "${roleypoly}/bin/roleypoly" ];
};
};
}

View file

@ -8,29 +8,10 @@
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" ]; systems = [ "x86_64-linux" "aarch64-linux" ];
perSystem = { config, self', pkgs, lib, system, ... }: rec { perSystem = { config, self', pkgs, lib, system, ... }: {
devShells.default = import ./shell.nix { inherit pkgs; }; devShells.default = import ./shell.nix { inherit pkgs; };
packages = let packages = import ./default.nix { inherit pkgs; };
vendorHash = "sha256-A5hZxo0zZ3w6qryV24PjYaKQatN2G2heyuee6QaU55M=";
in rec {
default = roleypoly;
roleypoly = pkgs.buildGoModule {
inherit vendorHash;
name = "roleypoly";
src = ./.;
};
container = pkgs.dockerTools.buildImage {
name = "roleypoly/roleypoly";
tag = "latest";
copyToRoot = [
pkgs.dockerTools.caCertificates
];
config = {
Cmd = [ "${roleypoly}/bin/roleypoly" ];
};
};
};
}; };
}; };
} }

View file

@ -1,7 +1,4 @@
package roleypoly package roleypoly
import "github.com/gofiber/fiber/v3/middleware/session"
type Roleypoly struct { type Roleypoly struct {
SessionStore *session.Store
} }

10
scripts/update-vendor-hash.sh Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix -p coreutils -p gnused -p gawk
set -exuo pipefail
go mod tidy
failedbuild=$(nix build --impure --expr '(with import <nixpkgs> {}; pkgs.callPackage ./. { vendorHash = ""; }).roleypoly' 2>&1 || true)
echo "$failedbuild"
checksum=$(echo "$failedbuild" | awk '/got:.*sha256/ { print $2 }')
sed -i -e "s|vendorHash ? \".*\"|vendorHash ? \"$checksum\"|" default.nix

View file

@ -1,33 +1,8 @@
{ pkgs ? import <nixpkgs> {} }: let { pkgs ? import <nixpkgs> {} }: pkgs.mkShell {
podmanSetupScript = let
registriesConf = pkgs.writeText "registries.conf" ''
[registries.search]
registries = ['docker.io']
[registries.block]
registries = []
'';
in pkgs.writeScript "podman-setup" ''
#!${pkgs.runtimeShell}
# Dont overwrite customised configuration
if ! test -f ~/.config/containers/policy.json; then
install -Dm555 ${pkgs.skopeo.src}/default-policy.json ~/.config/containers/policy.json
fi
if ! test -f ~/.config/containers/registries.conf; then
install -Dm555 ${registriesConf} ~/.config/containers/registries.conf
fi
'';
# Provides a fake "docker" binary mapping to podman
dockerCompat = pkgs.runCommandNoCC "docker-podman-compat" {} ''
mkdir -p $out/bin
ln -s ${pkgs.podman}/bin/podman $out/bin/docker
'';
in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
go go
just just
docker-compose
sqlite
nil nil
nix-prefetch
]; ];
} }

View file

@ -0,0 +1 @@
package stores