From 350b811a0225c274e330525a5e338667b61e6b4a Mon Sep 17 00:00:00 2001 From: euxane Date: Sun, 24 Nov 2024 17:17:02 +0100 Subject: nix: add flake --- flake.lock | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 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..10ffe4d --- /dev/null +++ b/flake.lock @@ -0,0 +1,77 @@ +{ + "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" + } + }, + "flaky-utils": { + "locked": { + "lastModified": 1728169353, + "narHash": "sha256-04rRY81iGrQb3lysKTmrBi5O6/0Tej23xplIk9Pp6Dc=", + "ref": "refs/heads/master", + "rev": "3e337302f9fa93a3496aafd7f57223cbd794de28", + "revCount": 43, + "type": "git", + "url": "https://cgit.euxane.net/flaky-utils" + }, + "original": { + "type": "git", + "url": "https://cgit.euxane.net/flaky-utils" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1728158116, + "narHash": "sha256-IN2luH/KYuChBbZLZvI3gI2Lz0fFAQrfAS6hfTOPDu0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7b2fbd28644b04fcd2c8020c38dd3b794c20fdd2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "7b2fbd2", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "flaky-utils": "flaky-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..bbfd8f0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +# Author: Euxane TRAN-GIRARD +# Licence: EUPL-1.2 + +{ + inputs = { + # For Nim 2.2.0 (necessary for generics, also better C compiler on master) + # https://github.com/NixOS/nixpkgs/pull/346578 + nixpkgs.url = "github:NixOS/nixpkgs/7b2fbd2"; + flake-utils.url = "github:numtide/flake-utils"; + flaky-utils.url = "git+https://cgit.euxane.net/flaky-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, flaky-utils }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { inherit system; }; + in { + devShell = flaky-utils.lib.mkDevShell { + inherit pkgs; + + tools = with pkgs; [ + nim + nrpl + nim-atlas + nimble + nimlangserver + nim_lk + ]; + + prePrompt = '' + echo " to exit this development shell." + ''; + + shell = null; + }; + + packages.default = pkgs.stdenv.mkDerivation (final: { + pname = "tickwatch"; + meta.mainProgram = final.pname; + version = "SNAPSHOT"; + src = ./.; + buildInputs = [ pkgs.nim ]; + buildPhase = '' + export VERSION=${final.version} + nim c --nimcache:. -d:release main.nim + ''; + doCheck = true; + checkPhase = '' + nim r --nimcache:. -d:test main.nim + ''; + installPhase = '' + mkdir -p $out/bin + mv main $out/bin/${final.meta.mainProgram} + ''; + }); + }); +} -- cgit v1.2.3