From 70f228c2f057df749bb37ada282660f6791be542 Mon Sep 17 00:00:00 2001 From: ShellTux <115948079+ShellTux@users.noreply.github.com> Date: Thu, 10 Oct 2024 03:05:30 +0100 Subject: [PATCH] feat: add flake --- .envrc | 1 + .gitignore | 1 + flake.lock | 25 +++++++++++++++++++++++++ flake.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index bfa696f..284b1bc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .hugo_build.lock /resources/** *.cast +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..86ed220 --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1721379653, + "narHash": "sha256-8MUgifkJ7lkZs3u99UDZMB4kbOxvMEXQZ31FO3SopZ0=", + "rev": "1d9c2c9b3e71b9ee663d11c5d298727dace8d374", + "revCount": 655136, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.655136%2Brev-1d9c2c9b3e71b9ee663d11c5d298727dace8d374/0190cd4f-c0eb-72cb-834b-ac854aa282dc/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b3fdfd7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "Hugo Blog Flake"; + + # Flake inputs + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; + + # Flake outputs + outputs = { self, nixpkgs }: + let + # The systems supported for this flake + supportedSystems = [ + "x86_64-linux" # 64-bit Intel/AMD Linux + "aarch64-linux" # 64-bit ARM Linux + "x86_64-darwin" # 64-bit Intel macOS + "aarch64-darwin" # 64-bit ARM macOS + ]; + + # Helper to provide system-specific attributes + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; }; + }); + in + { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + packages = with pkgs; [ + hugo + gnumake + ]; + + env = { }; + + shellHook = '' + echo + printf '\033[32mCreate new site:\033[0m\n' + echo hugo new posts/sed.md + echo + printf '\033[32mServe blog locally:\033[0m\n' + echo make serve + ''; + }; + }); + }; +}