From 029932873ab2b5449ad4f377ffd6d1704c837a19 Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Mon, 4 Aug 2025 10:32:18 +0200 Subject: [PATCH] Add flake Signed-off-by: Nikolaos Karaolidis --- .envrc | 1 + flake.lock | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 33 +++++++++++++++++++++ treefmt.nix | 19 +++++++++++++ 4 files changed, 135 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100755 flake.nix create mode 100755 treefmt.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/flake.lock b/flake.lock new file mode 100644 index 0000000..fa660e8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1753939845, + "narHash": "sha256-K2ViRJfdVGE8tpJejs8Qpvvejks1+A4GQej/lBk5y7I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "94def634a20494ee057c76998843c015909d6311", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754061284, + "narHash": "sha256-ONcNxdSiPyJ9qavMPJYAXDNBzYobHRxw0WbT38lKbwU=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "58bd4da459f0a39e506847109a2a5cfceb837796", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100755 index 0000000..f5f9848 --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + flake-utils.url = "github:numtide/flake-utils"; + + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + inputs: + ( + let + system = "x86_64-linux"; + + pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + }; + + treefmt = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix; + in + { + devShells.${system}.default = pkgs.mkShell { packages = with pkgs; [ hugo ]; }; + + formatter.${system} = treefmt.config.build.wrapper; + checks.formatting.${system} = treefmt.config.build.check inputs.self; + } + ); +} diff --git a/treefmt.nix b/treefmt.nix new file mode 100755 index 0000000..092ee3c --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,19 @@ +{ ... }: +{ + projectRootFile = "flake.nix"; + + programs = { + nixfmt = { + enable = true; + strict = true; + }; + + prettier.enable = true; + }; + + settings = { + global = { + excludes = [ ".envrc" ]; + }; + }; +}