-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
153 lines (133 loc) · 4.75 KB
/
flake.nix
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
144
145
146
147
148
149
150
151
152
153
{
description = "Build termusix app with flake.nix";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = inputs @ {
self,
nixpkgs,
crane,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (localSystem: let
pkgs = nixpkgs.legacyPackages.${localSystem};
in {
packages = let
definetermusixPkgs = {}:
rec {
termusix_aarch64-linux = import ./nix/cross-build.nix {
inherit localSystem inputs;
pathCwd = ./.;
crossSystem = "aarch64-linux";
rustTargetTriple = "aarch64-unknown-linux-gnu";
};
termusix_x86_64-linux = import ./nix/cross-build.nix {
inherit localSystem inputs;
pathCwd = ./.;
crossSystem = "x86_64-linux";
rustTargetTriple = "x86_64-unknown-linux-gnu";
};
termusix_x86_64-windows = import ./nix/window-build.nix {
inherit localSystem inputs;
pathCwd = ./.;
};
termusix-pkgbuild = pkgs.callPackage ./nix/pkgbuild.nix {
termusix = self.packages.${localSystem}.termusix_x86_64-linux;
};
termusix-appmanifest = pkgs.callPackage ./nix/scoop-appmanifest.nix {
termusix = termusix_x86_64-windows;
};
get_termusix_version =
pkgs.runCommand "get_termusix_version" {
} ''
mkdir -p $out
echo ${self.packages.${localSystem}.termusix_x86_64-linux.version} > $out/version.txt
'';
zip-termusix-windows =
pkgs.runCommand "zip-termusix-windows" {
buildInputs = [pkgs.zip];
} ''
mkdir -p $out
cp ${termusix_x86_64-windows}/bin/termusix.exe $out/termusix.exe
cd $out
zip -j termusix_x86_64-windows-v${termusix_x86_64-windows.version}.zip termusix.exe
rm termusix.exe
'';
}
// (
if localSystem == "aarch64-darwin"
then {
termusix_aarch64-apple = import ./nix/cross-build.nix {
inherit localSystem inputs;
pathCwd = ./.;
crossSystem = "aarch64-darwin";
rustTargetTriple = "aarch64-apple-darwin";
};
tar-darwin-arm = pkgs.callPackage ./nix/tar-package.nix {
termusix = self.packages.${localSystem}.termusix_aarch64-apple;
architecture = "arm";
};
get_termusix_version_darwin =
pkgs.runCommand "get_termusix_version_darwin" {
} ''
mkdir -p $out
echo ${self.packages.${localSystem}.termusix_aarch64-apple.version} > $out/version.txt
'';
}
else if localSystem == "x86_64-darwin"
then {
termusix_x86_64-apple = import ./nix/cross-build.nix {
inherit localSystem inputs;
pathCwd = ./.;
crossSystem = "x86_64-darwin";
rustTargetTriple = "x86_64-apple-darwin";
};
tar-darwin-x86_64 = pkgs.callPackage ./nix/tar-package.nix {
termusix = self.packages.${localSystem}.termusix_x86_64-apple;
architecture = "intel";
};
}
else {}
);
in
definetermusixPkgs {};
defaultPackage =
if localSystem == "x86_64-linux"
then self.packages.${localSystem}.termusix_x86_64-linux
else if localSystem == "aarch64-linux"
then self.packages.${localSystem}.termusix_aarch64-linux
else if localSystem == "x86_64-darwin"
then self.packages.${localSystem}.termusix_x86_64-apple
else if localSystem == "aarch64-darwin"
then self.packages.${localSystem}.termusix_aarch64-apple
else null;
apps.default = flake-utils.lib.mkApp {
drv = nixpkgs.lib.getAttr "termusix_${localSystem}" self.packages.${localSystem};
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
patchelf
];
};
})
// {
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
};
}