feat: added deployment flow

This commit is contained in:
Leyla Becker 2026-02-11 15:16:35 -06:00
parent af43876fcb
commit f0a030c44a
5 changed files with 186 additions and 2 deletions

View file

@ -1,5 +1,5 @@
{
description = "A Nix-flake-based Node.js development environment";
description = "Volpe Blog";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
@ -19,9 +19,39 @@
pkgs = import nixpkgs {inherit overlays system;};
});
in {
packages = forEachSupportedSystem ({pkgs}: {
default = pkgs.callPackage ./nix/package.nix {};
volpe = pkgs.callPackage ./nix/package.nix {};
});
devShells = forEachSupportedSystem ({pkgs}: {
default = pkgs.mkShell {
packages = with pkgs; [node2nix nodejs pnpm sqlite];
packages = with pkgs; [
nodejs
nodePackages.pnpm
];
};
});
nixosConfigurations.volpe = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{nixpkgs.overlays = overlays;}
./nix/configuration.nix
];
};
# Deployment helper - use with: nix run .#deploy
apps = forEachSupportedSystem ({pkgs}: {
deploy = {
type = "app";
program = toString (pkgs.writeShellScript "deploy-volpe" ''
set -e
echo "Building and deploying to cyberian@69.61.19.180..."
nixos-rebuild switch --flake .#volpe \
--target-host cyberian@69.61.19.180 \
--sudo
'');
};
});
};

44
nix/configuration.nix Normal file
View file

@ -0,0 +1,44 @@
{
config,
pkgs,
...
}: {
imports = [
./hardware-configuration.nix
./module.nix
];
nix.settings.experimental-features = ["nix-command" "flakes"];
nix.settings.trusted-users = ["root" "cyberian"];
swapDevices = [
{
device = "/swapfile";
size = 2 * 1024; # 2GB
}
];
boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/vda";
system.stateVersion = "24.11";
users.users.cyberian = {
isNormalUser = true;
extraGroups = ["wheel"];
};
security.sudo.wheelNeedsPassword = false;
services.qemuGuest.enable = true;
services.acpid.enable = true;
services.openssh = {
enable = true;
settings.PasswordAuthentication = false;
};
# Enable the volpe service
services.volpe = {
enable = true;
domain = "69.61.19.180";
};
}

View file

@ -0,0 +1,30 @@
# Do not modify this file! It was generated by 'nixos-generate-config'
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["ata_piix" "virtio_pci" "floppy" "sr_mod" "virtio_blk"];
boot.initrd.kernelModules = [];
boot.kernelModules = ["kvm-amd"];
boot.extraModulePackages = [];
fileSystems."/" = {
device = "/dev/disk/by-uuid/1195bb4c-ddcb-4ad6-8109-d28170f169b1";
fsType = "ext4";
};
swapDevices = [];
networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

33
nix/module.nix Normal file
View file

@ -0,0 +1,33 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.services.volpe;
pkg = pkgs.callPackage ./package.nix {};
in {
options.services.volpe = {
enable = lib.mkEnableOption "volpe blog";
domain = lib.mkOption {
type = lib.types.str;
default = "localhost";
description = "Domain name for nginx virtual host.";
};
};
config = lib.mkIf cfg.enable {
services.nginx = {
enable = true;
virtualHosts.${cfg.domain} = {
root = "${pkg}";
locations."/" = {
tryFiles = "$uri $uri/ /index.html";
};
};
};
networking.firewall.allowedTCPPorts = [80 443];
};
}

47
nix/package.nix Normal file
View file

@ -0,0 +1,47 @@
{
lib,
stdenv,
nodejs_latest,
pnpm_10,
fetchPnpmDeps,
pnpmConfigHook,
}: let
nodejs = nodejs_latest;
pnpm = pnpm_10;
in
stdenv.mkDerivation (finalAttrs: {
pname = "volpe";
version = "1.0.0";
src = lib.cleanSource ./..;
nativeBuildInputs = [
nodejs
pnpm
pnpmConfigHook
];
# fetchPnpmDeps creates the offline store
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-AiyDVGSxlfdqzuei0N0F3UOXlQVztxqyU7gBkZbUqOI=";
fetcherVersion = 3; # pnpm store version
};
buildPhase = ''
runHook preBuild
pnpm build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r _site/* $out/
runHook postInstall
'';
})