From 86c5af8045ca1e9d4602b08620bf4445dabac8d1 Mon Sep 17 00:00:00 2001 From: Vikingnope Date: Thu, 11 Dec 2025 13:05:12 +0100 Subject: [PATCH] add flake --- flake.lock | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 62 +++++++++++++++++++ 2 files changed, 241 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e8111af --- /dev/null +++ b/flake.lock @@ -0,0 +1,179 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "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" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "zls", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1762808025, + "narHash": "sha256-XmjITeZNMTQXGhhww6ed/Wacy2KzD6svioyCX7pkUu4=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1765186076, + "narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "zig-overlay": "zig-overlay", + "zls": "zls" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "zig-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1764203689, + "narHash": "sha256-ivb0SqCptyIxx5g8ryRrUL0xrJhLrJPlvZbZjxVaui0=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "8f7347545dea59b75e40247cc1ed55a42f64dbbf", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } + }, + "zls": { + "inputs": { + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "zig-overlay": [ + "zig-overlay" + ] + }, + "locked": { + "lastModified": 1764993315, + "narHash": "sha256-67LhYwmcE/8V/24Tkde1ItxjDEliKqCSVU/oroJ3owM=", + "owner": "zigtools", + "repo": "zls", + "rev": "60cff3d69f6072b840aa588fb8454fac9a95fbe1", + "type": "github" + }, + "original": { + "owner": "zigtools", + "repo": "zls", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..74b29e5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "Ziglings - Learn Zig by fixing tiny broken programs"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + + zig-overlay.url = "github:mitchellh/zig-overlay"; + zig-overlay.inputs.nixpkgs.follows = "nixpkgs"; + + # Added ZLS input + zls.url = "github:zigtools/zls"; + zls.inputs.nixpkgs.follows = "nixpkgs"; + zls.inputs.zig-overlay.follows = "zig-overlay"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + zig-overlay, + zls, # Added zls to arguments + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + # Define the specific Zig version here so we can pass it to ZLS + zig = zig-overlay.packages.${system}.master; + + # Override ZLS to ensure it builds using our specific Zig version + zls-pkg = zls.packages.${system}.zls.overrideAttrs (old: { + nativeBuildInputs = [ zig ]; + }); + in + { + devShells.default = pkgs.mkShell { + nativeBuildInputs = [ + zig + zls-pkg + ]; + + shellHook = '' + echo "=====================================" + echo "Ziglings development environment" + echo "=====================================" + echo "" + echo "Zig version:" + zig version + echo "" + echo "ZLS version:" + zls --version + echo "" + echo "Run 'zig build' to get started!" + echo "=====================================" + ''; + }; + } + ); +}