aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreuxane2024-11-24 17:17:02 +0100
committereuxane2024-11-24 17:17:02 +0100
commit350b811a0225c274e330525a5e338667b61e6b4a (patch)
treeb829723f334234e53897807714c37445dd85b9a1
parent58541ee9e74b71b870f1773030f0a61b86fd0300 (diff)
downloadtickwatch-350b811a0225c274e330525a5e338667b61e6b4a.tar.gz
nix: add flake
-rw-r--r--flake.lock77
-rw-r--r--flake.nix56
2 files changed, 133 insertions, 0 deletions
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..10ffe4d
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,77 @@
1{
2 "nodes": {
3 "flake-utils": {
4 "inputs": {
5 "systems": "systems"
6 },
7 "locked": {
8 "lastModified": 1731533236,
9 "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
10 "owner": "numtide",
11 "repo": "flake-utils",
12 "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
13 "type": "github"
14 },
15 "original": {
16 "owner": "numtide",
17 "repo": "flake-utils",
18 "type": "github"
19 }
20 },
21 "flaky-utils": {
22 "locked": {
23 "lastModified": 1728169353,
24 "narHash": "sha256-04rRY81iGrQb3lysKTmrBi5O6/0Tej23xplIk9Pp6Dc=",
25 "ref": "refs/heads/master",
26 "rev": "3e337302f9fa93a3496aafd7f57223cbd794de28",
27 "revCount": 43,
28 "type": "git",
29 "url": "https://cgit.euxane.net/flaky-utils"
30 },
31 "original": {
32 "type": "git",
33 "url": "https://cgit.euxane.net/flaky-utils"
34 }
35 },
36 "nixpkgs": {
37 "locked": {
38 "lastModified": 1728158116,
39 "narHash": "sha256-IN2luH/KYuChBbZLZvI3gI2Lz0fFAQrfAS6hfTOPDu0=",
40 "owner": "NixOS",
41 "repo": "nixpkgs",
42 "rev": "7b2fbd28644b04fcd2c8020c38dd3b794c20fdd2",
43 "type": "github"
44 },
45 "original": {
46 "owner": "NixOS",
47 "ref": "7b2fbd2",
48 "repo": "nixpkgs",
49 "type": "github"
50 }
51 },
52 "root": {
53 "inputs": {
54 "flake-utils": "flake-utils",
55 "flaky-utils": "flaky-utils",
56 "nixpkgs": "nixpkgs"
57 }
58 },
59 "systems": {
60 "locked": {
61 "lastModified": 1681028828,
62 "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
63 "owner": "nix-systems",
64 "repo": "default",
65 "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
66 "type": "github"
67 },
68 "original": {
69 "owner": "nix-systems",
70 "repo": "default",
71 "type": "github"
72 }
73 }
74 },
75 "root": "root",
76 "version": 7
77}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..bbfd8f0
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,56 @@
1# Author: Euxane TRAN-GIRARD
2# Licence: EUPL-1.2
3
4{
5 inputs = {
6 # For Nim 2.2.0 (necessary for generics, also better C compiler on master)
7 # https://github.com/NixOS/nixpkgs/pull/346578
8 nixpkgs.url = "github:NixOS/nixpkgs/7b2fbd2";
9 flake-utils.url = "github:numtide/flake-utils";
10 flaky-utils.url = "git+https://cgit.euxane.net/flaky-utils";
11 };
12
13 outputs = { self, nixpkgs, flake-utils, flaky-utils }:
14 flake-utils.lib.eachDefaultSystem (system: let
15 pkgs = import nixpkgs { inherit system; };
16 in {
17 devShell = flaky-utils.lib.mkDevShell {
18 inherit pkgs;
19
20 tools = with pkgs; [
21 nim
22 nrpl
23 nim-atlas
24 nimble
25 nimlangserver
26 nim_lk
27 ];
28
29 prePrompt = ''
30 echo "<C-d> to exit this development shell."
31 '';
32
33 shell = null;
34 };
35
36 packages.default = pkgs.stdenv.mkDerivation (final: {
37 pname = "tickwatch";
38 meta.mainProgram = final.pname;
39 version = "SNAPSHOT";
40 src = ./.;
41 buildInputs = [ pkgs.nim ];
42 buildPhase = ''
43 export VERSION=${final.version}
44 nim c --nimcache:. -d:release main.nim
45 '';
46 doCheck = true;
47 checkPhase = ''
48 nim r --nimcache:. -d:test main.nim
49 '';
50 installPhase = ''
51 mkdir -p $out/bin
52 mv main $out/bin/${final.meta.mainProgram}
53 '';
54 });
55 });
56}