-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
111 lines (91 loc) · 2.89 KB
/
flake.nix
File metadata and controls
111 lines (91 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{
description = "Development environment for Introduction to Functional Programming using Miranda";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }:
let
systems = nixpkgs.lib.systems.flakeExposed;
forEachSystem = nixpkgs.lib.genAttrs systems;
in
rec {
packages = forEachSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
miranda = pkgs.stdenv.mkDerivation {
pname = "miranda";
version = "2.067";
src = pkgs.fetchurl {
url = "https://codeberg.org/DATurner/miranda/archive/miranda-2.067.tar.gz";
sha256 = "sha256-8geE3+Y61gC9UoP79kN/blY+amJJn8wIG38ab/gQiF4=";
};
nativeBuildInputs = [
pkgs.byacc
pkgs.makeWrapper
pkgs.gcc
];
dontConfigure = true;
buildPhase = ''
runHook preBuild
export BUILD_DATE="$(date '+%d %b %Y')"
# Create a proper .host file instead of relying on gcc -v
echo "compiled on Nix build system" > .host
make
runHook postBuild
'';
postPatch = ''
substituteInPlace Makefile \
--replace "CC = clang" "CC ?= clang" \
--replace "\`git show -s --format=%cd --date=format:'%d %b %Y'\`" '$(BUILD_DATE)' \
--replace '$(CC) -v 2>> .host' '$(CC) -v 2>> .host || true'
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/bin"
mkdir -p "$out/lib/miralib"
mkdir -p "$out/share/man/man1"
cp mira "$out/bin/"
cp -r miralib/. "$out/lib/miralib/"
cp mira.1 "$out/share/man/man1/"
wrapProgram "$out/bin/mira" \
--set MIRALIB "$out/lib/miralib"
runHook postInstall
'';
meta = with pkgs.lib; {
description = "Miranda functional programming language implementation";
homepage = "https://codeberg.org/DATurner/miranda";
license = licenses.gpl2;
maintainers = [];
platforms = platforms.unix;
};
};
in
{
inherit miranda;
default = miranda;
}
);
devShells = forEachSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
miranda = packages.${system}.miranda;
in
{
default = pkgs.mkShell {
packages = [
miranda
pkgs.gnumake
pkgs.git
];
shellHook = ''
export MIRA=${miranda}/bin/mira
'';
};
}
);
};
}