summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix57
1 files changed, 48 insertions, 9 deletions
diff --git a/flake.nix b/flake.nix
index 603c15a..dcd9843 100644
--- a/flake.nix
+++ b/flake.nix
@@ -21,6 +21,20 @@
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
+ emacsPackages = import "${nixmacs}/modules/home/emacs-packages.nix";
+ ci-emacs = pkgs.emacs-nox.pkgs.withPackages emacsPackages;
+
+ installer = nixmacs.nixosConfigurations.installer.extendModules {
+ specialArgs = { monorepoSelf = self; };
+ };
+
+ installer-iso = installer.config.system.build.isoImage;
+
+ spontaneity = nixmacs.nixosConfigurations.spontaneity.extendModules {
+ specialArgs = { monorepoSelf = self; };
+ };
+
+ spontaneityHost = spontaneity.config.monorepo.vars.orgHost;
pre-commit-check = git-hooks.lib.${system}.run {
src = ./.;
@@ -67,14 +81,39 @@ if [ "$BRANCH" = "main" ] && [ ! -f "$GIT_DIR/MERGE_HEAD" ]; then
fi
''}";
};
+
+ deploy-spontaneity = {
+ enable = true;
+ name = "Deploy to Spontaneity VPS";
+ description = "Automatically deploys the NixOS configuration to the VPS on push to main";
+ stages = [ "pre-push" ];
+ pass_filenames = false;
+ always_run = true;
+ entry = "${pkgs.writeShellScript "deploy-spontaneity-hook" ''
+BRANCH=$(git branch --show-current)
+
+if [ "$BRANCH" != "main" ]; then
+ exit 0
+fi
+echo "Pushing to main detected. Deploying to ${spontaneityHost}..."
+nixos-rebuild switch --flake .#spontaneity --target-host root@${spontaneityHost} --build-host localhost
+if [ $? -eq 0 ]; then
+ echo "Deployment successful!"
+else
+ echo "Deployment failed. Aborting."
+ exit 1
+fi
+ ''}";
+ };
};
};
- emacsPackages = import "${nixmacs}/modules/home/emacs-packages.nix";
- ci-emacs = pkgs.emacs-nox.pkgs.withPackages emacsPackages;
website = pkgs.stdenv.mkDerivation {
name = "org-publish-website";
src = pkgs.lib.cleanSource ./.;
+ nativeBuildInputs = [
+ installer-iso
+ ];
buildInputs = [
ci-emacs
pkgs.git
@@ -95,6 +134,7 @@ fi
})
];
+
buildPhase = ''
export HOME=$TMPDIR/fake-home
mkdir -p $HOME/.emacs.d
@@ -169,17 +209,16 @@ ${publish-org-roam-ui.packages.${system}.default}/bin/build-org-roam-graph \
installPhase = ''
mkdir -p $out
cp -r $HOME/website_html/. $out/
+cp ${installer-iso}/iso/*.iso $out/installer.iso
+cd $out
+sha256sum installer.iso > installer.iso.sha256
'';
};
in
{
nixosConfigurations = {
- installer = nixmacs.nixosConfigurations.installer.extendModules {
- specialArgs = { monorepoSelf = self; };
- };
- spontaneity = nixmacs.nixosConfigurations.spontaneity.extendModules {
- specialArgs = { monorepoSelf = self; };
- };
+ inherit installer;
+ inherit spontaneity;
};
checks."${system}" = {
@@ -188,7 +227,7 @@ cp -r $HOME/website_html/. $out/
packages."${system}" = {
website = website;
- installer = self.nixosConfigurations.installer.config.system.build.isoImage;
+ installer = installer-iso;
spontaneity = self.nixosConfigurations.spontaneity.config.system.build.toplevel;
};