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.nix | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 flake.nix (limited to 'flake.nix') 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