-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
143 lines (123 loc) · 4.96 KB
/
Copy pathflake.nix
File metadata and controls
143 lines (123 loc) · 4.96 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
outputs = { self, flake-utils, gitignore, haskellNix, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
haskellNix.overlay
(import ./nix/fix-ghc-pkgs-overlay.nix)
];
inherit (haskellNix) config;
};
src = gitignore.lib.gitignoreSource ./.;
compilerNixName = "ghc9122";
flake = (pkgs.haskell-nix.hix.project {
inherit src;
evalSystem = "x86_64-linux";
compiler-nix-name = compilerNixName;
projectFileName = "stack.yaml";
modules = [
(import ./nix/fix-ghc-pkgs-module.nix)
(import ./nix/os-string-module.nix)
(import ./nix/module-normal.nix { inherit (pkgs) gcc lib stdenv; })
];
}).flake {};
flakeStatic = (pkgs.pkgsCross.musl64.haskell-nix.hix.project {
inherit src;
evalSystem = "x86_64-linux";
compiler-nix-name = compilerNixName;
projectFileName = "stack.yaml";
modules = [
(import ./nix/fix-ghc-pkgs-module.nix)
(import ./nix/os-string-module.nix)
(import ./nix/module-static.nix { inherit (pkgs) pkgsCross; })
];
}).flake {};
flakeDarwinStatic = (pkgs.haskell-nix.hix.project {
inherit src;
evalSystem = "x86_64-linux";
compiler-nix-name = compilerNixName;
projectFileName = "stack.yaml";
modules = [
(import ./nix/fix-ghc-pkgs-module.nix)
(import ./nix/os-string-module.nix)
(import ./nix/module-darwin-static.nix { inherit (pkgs) clang pkgsStatic; })
];
}).flake {};
flakeWindows = (pkgs.pkgsCross.mingwW64.haskell-nix.hix.project {
inherit src;
compiler-nix-name = compilerNixName;
projectFileName = "stack.yaml";
modules = [
(import ./nix/os-string-module.nix)
(import ./nix/module-windows.nix {})
];
}).flake {};
version = flake.packages."sauron:exe:sauron".version;
mkGithubArtifacts = binary: system: exeSuffix:
with pkgs; runCommand "github-artifacts-${system}-${version}" {} ''
mkdir $out
BINARY="sauron${exeSuffix}"
cp "${binary}/bin/$BINARY" "$out/$BINARY"
tar -czvf "$out/sauron-${system}-${version}.tar.gz" -C "$out" "$BINARY"
rm "$out/$BINARY"
'';
in
{
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
gmp
ncurses
pcre
pkg-config
zlib
pkgs.haskell.compiler.ghc9122
(pkgs.haskell-language-server.override { supportedGhcVersions = ["9122"]; })
(pkgs.vhs.overrideAttrs (old: {
patches = (old.patches or []) ++ [
./nix/vhs-add-home-end-keys.patch
];
}))
];
};
};
packages = rec {
dynamic = flake.packages."sauron:exe:sauron";
static = flakeStatic.packages."sauron:exe:sauron";
darwin-static = flakeDarwinStatic.packages."sauron:exe:sauron";
windows = flakeWindows.packages."sauron:exe:sauron";
default = dynamic;
githubArtifacts = let
binary = if pkgs.stdenv.hostPlatform.isDarwin then darwin-static
else if pkgs.stdenv.hostPlatform.isWindows then windows
else if pkgs.stdenv.hostPlatform.isLinux && pkgs.stdenv.hostPlatform.isAarch64 then dynamic
else if pkgs.stdenv.hostPlatform.isLinux then static
else throw "Unrecognized platform: ${pkgs.stdenv.hostPlatform.system}";
exeSuffix = if pkgs.stdenv.hostPlatform.isWindows then ".exe" else "";
in
mkGithubArtifacts binary pkgs.stdenv.hostPlatform.system exeSuffix;
windowsGithubArtifacts = mkGithubArtifacts windows "x86_64-windows" ".exe";
grandCombinedGithubArtifacts = pkgs.symlinkJoin {
name = "sauron-grand-combined-artifacts";
paths = [
self.packages.x86_64-linux.githubArtifacts
self.packages.aarch64-linux.githubArtifacts
self.packages.x86_64-darwin.githubArtifacts
self.packages.aarch64-darwin.githubArtifacts
self.packages.x86_64-linux.windowsGithubArtifacts
];
};
inherit version;
};
}
);
}