summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdback <tyler@tdback.net>2025-03-03 21:20:12 -0500
committertdback <tyler@tdback.net>2025-03-03 21:20:12 -0500
commit89ec44a7d3fc46b9ff41ccb059abd2e74d5f26dd (patch)
tree1ff64a6a02f4eb8ebe48e512e4af1512b3d98729
parentc59033510f0c872fdfddd03f453d105e9580e57e (diff)
flake: add nix build steps and README
-rw-r--r--.gitignore4
-rw-r--r--README.org8
-rw-r--r--default.nix20
-rw-r--r--flake.nix26
4 files changed, 44 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 195bece..b114772 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
/public
/resources
-/.direnv/
+/result
+/.direnv
+/.hugo_build.lock
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..ddfcc8f
--- /dev/null
+++ b/README.org
@@ -0,0 +1,8 @@
+* tdback.net
+Source code for my personal website/blog.
+
+To build and deploy to my web server:
+#+begin_src shell
+ nix build ".?submodules=1#" -L
+ rsync -avz --delete result/ thor:/var/www/tdback.net/
+#+end_src
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..f1bc7f6
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,20 @@
+{
+ hugo,
+ stdenv,
+ self ? null
+}:
+stdenv.mkDerivation {
+ pname = "tdback-net";
+ version = if self ? rev then self.rev else "dirty";
+ src = ./.;
+
+ nativeBuildInputs = [ hugo ];
+
+ buildPhase = ''
+ hugo build --minify
+ '';
+
+ installPhase = ''
+ mv public $out
+ '';
+}
diff --git a/flake.nix b/flake.nix
index ced5e60..152f7d0 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,4 +1,6 @@
{
+ description = "tdback's website source code (tdback.net)";
+
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs =
@@ -9,27 +11,25 @@
"x86_64-linux"
];
eachSystem = nixpkgs.lib.genAttrs supportedSystems;
+ forPkgs =
+ fn:
+ nixpkgs.lib.mapAttrs (system: pkgs: (fn pkgs)) (
+ nixpkgs.lib.getAttrs supportedSystems nixpkgs.legacyPackages
+ );
in
{
+ packages = forPkgs (pkgs: {
+ default = pkgs.callPackage ./default.nix { };
+ });
+
devShells = eachSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
- default = pkgs.mkShell {
- buildInputs = with pkgs; [
- hugo
- rsync
- ];
-
- shellHook = ''
- SITE="$HOME/projects/tdback.net"
-
- publish() {
- hugo && rsync -avz --delete public/ thor:/var/www/tdback.net/
- }
- '';
+ default = with pkgs; mkShell {
+ buildInputs = [ hugo ];
};
}
);