From 208f4e2608484bf5efe4aca58e489e886828ed70 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Thu, 5 Mar 2026 17:56:26 -0800 Subject: change build process to include iso fully; add hook --- README.org | 4 ++-- flake.nix | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/README.org b/README.org index d22f987..4f6e6ba 100644 --- a/README.org +++ b/README.org @@ -16,9 +16,9 @@ as well as writing a lot of things with a literate config. To see more, see my ** So, where is this website of yours located? https://ret2pop.net, it is the road to enlightenment. * Wait, so where are your dotfiles? -To use my dotfiles, download the [[file:robots.txt][ISO image]] (link broken temporarily) for the installer. Note that you can validate the ISO image with the checksum provided: +To use my dotfiles, download the [[file:installer.iso][ISO image]] for the installer. Note that you can validate the ISO image with the [[file:./installer.iso.sha256][checksum provided]]: #+begin_src bash - sha256sum -c nix-installer.iso.sha256 + sha256sum -c installer.iso.sha256 #+end_src with the ISO in the same directory. This install installs a certain commit hash of my monorepo. Flash the image, log into the installer, and run: #+begin_src bash 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; }; -- cgit v1.3 From 471fcf956dc8da511bc9f6563157e70e35dad740 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Thu, 5 Mar 2026 17:56:51 -0800 Subject: add hook --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b1255dc..c5fc309 120000 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1 +1 @@ -/nix/store/dpkk5c7lx4hrkczwjpzi0qzzkr5i1j8k-pre-commit-config.json \ No newline at end of file +/nix/store/7glw6wk3bwhgxx9plk35jigcwziawpjn-pre-commit-config.json \ No newline at end of file -- cgit v1.3 From 134aaffb30c0e2d352e74c3585f88ec567714ad9 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Thu, 5 Mar 2026 18:02:41 -0800 Subject: make push hook actually work by abstracting user --- .pre-commit-config.yaml | 2 +- flake.nix | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c5fc309..a38d569 120000 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1 +1 @@ -/nix/store/7glw6wk3bwhgxx9plk35jigcwziawpjn-pre-commit-config.json \ No newline at end of file +/nix/store/6fvxyam5cy48j363m8r1xf8jddkrsg5s-pre-commit-config.json \ No newline at end of file diff --git a/flake.nix b/flake.nix index dcd9843..de232f7 100644 --- a/flake.nix +++ b/flake.nix @@ -23,18 +23,20 @@ emacsPackages = import "${nixmacs}/modules/home/emacs-packages.nix"; ci-emacs = pkgs.emacs-nox.pkgs.withPackages emacsPackages; + specialArgs = { monorepoSelf = self; }; installer = nixmacs.nixosConfigurations.installer.extendModules { - specialArgs = { monorepoSelf = self; }; + inherit specialArgs; }; - installer-iso = installer.config.system.build.isoImage; - spontaneity = nixmacs.nixosConfigurations.spontaneity.extendModules { - specialArgs = { monorepoSelf = self; }; + inherit specialArgs; }; + installer-iso = installer.config.system.build.isoImage; + spontaneityHost = spontaneity.config.monorepo.vars.orgHost; + spontaneityUser = spontaneity.config.monorepo.vars.userName; pre-commit-check = git-hooks.lib.${system}.run { src = ./.; @@ -96,7 +98,7 @@ 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 +nixos-rebuild switch --flake .#spontaneity --target-host ${spontaneityUser}@${spontaneityHost} if [ $? -eq 0 ]; then echo "Deployment successful!" else -- cgit v1.3