summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorPreston Pan <ret2pop@nullring.xyz>2026-03-03 13:52:39 -0800
committerPreston Pan <ret2pop@nullring.xyz>2026-03-03 13:52:39 -0800
commitd9ed2a0e3c67b182291022fece53981120236d8c (patch)
tree9e0342f025455a5d3aa61edf9f210a47c77dc7a3 /flake.nix
parentc4e73ca0f05373f9a0000a70b68784024fd8778e (diff)
initial top level flake commit
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix80
1 files changed, 80 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..2efcdef
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,80 @@
+{
+ description = "Build my static site";
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ git-hooks = {
+ url = "github:cachix/git-hooks.nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ hyprnixmacs.url = "path:./nix";
+ };
+ outputs = { nixpkgs, git-hooks, hyprnixmacs, self, ... }:
+ let
+ system = "x86_64-linux";
+ pkgs = import nixpkgs { inherit system; };
+ pre-commit-check = git-hooks.lib.${system}.run {
+ src = ./.;
+ hooks = {
+ deadnix.enable = true;
+ prevent-direct-main-commits = {
+ enable = true;
+ name = "Prevent direct commits to main";
+ description = "Blocks commits to main unless they are merge commits";
+ pass_filenames = false;
+ entry = "${pkgs.writeShellScript "block-main-commits" ''
+BRANCH=$(git branch --show-current)
+GIT_DIR=$(git rev-parse --git-dir)
+if [ "$BRANCH" = "main" ] && [ ! -f "$GIT_DIR/MERGE_HEAD" ]; then
+ echo "Direct commits to 'main' are blocked."
+ echo "Please commit to a feature branch and merge it into main."
+ exit 1
+fi
+ ''}";
+ };
+ };
+ };
+
+ emacsPackages = import ./nix/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 ./.;
+ buildInputs = [ ci-emacs ];
+ buildPhase = ''
+mkdir -p public
+emacs -Q --batch \
+ --eval '(setq system-email "ci@dummy.local")' \
+ --eval '(setq system-username "ci-runner")' \
+ --eval '(setq system-fullname "CI Pipeline")' \
+ --eval '(setq system-gpgkey "00000000")' \
+ -l ./nix/init.el \
+ --eval '(org-publish-all t)'
+ '';
+
+ installPhase = ''
+mkdir -p $out
+cp -r public/* $out/
+ '';
+ };
+ in
+ {
+ nixosConfigurations.installer = hyprnixmacs.nixosConfigurations.installer.extendModules {
+ specialArgs = { monorepoSelf = self; };
+ };
+
+ checks."${system}" = {
+ build-website = website;
+ };
+
+ packages."${system}" = {
+ default = website;
+ installer = self.nixosConfigurations.installer.config.system.build.isoImage;
+ };
+ devShells."${system}".default = with pkgs; mkShell {
+ inherit (pre-commit-check) shellHook;
+ buildInputs = [
+ deadnix
+ ];
+ };
+ };
+}