-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
186 lines (153 loc) · 6.16 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
{
nixConfig.bash-prompt = ''\033[22m\033[31mdev \033[01;34m\W\033[00m ❯❯❯ '';
inputs = {
# nixpkgs 35.11 still contains rust 1.73
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
c2vi-config.url = "github:c2vi/nixos";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, crane, fenix, flake-utils, nixpkgs, c2vi-config, ... }@inputs:
####################################
# some global outputs
{
inherit inputs self;
} //
####################################
# system specific outpugs
flake-utils.outputs.lib.eachSystem flake-utils.outputs.lib.allSystems (system: let
####################################
# let bindings for outputs
pkgs = nixpkgs.legacyPackages.${system};
osCrane = crane.lib.${system}.overrideToolchain fenix.packages.${system}.latest.toolchain;
url = "http://c2vi.dev";
repoUrl = "github:c2vi/victorinix";
buildVicForSystem = import ./build-vic-for-system.nix;
defaultVicConfig = {
inherit url repoUrl;
vic_dir = "~/.victorinix";
vicPkgs_url = "github:c2vi/victorinix#vicPkgs";
};
filteredRustSource = builtins.filterSource (name: type: (
pkgs.lib.strings.hasInfix "src" name ||
baseNameOf name == "Cargo.toml" ||
baseNameOf name == "build.rs" ||
baseNameOf name == "Cargo.lock"
)) ./.;
getTarballClosure = pkgs: system: let
pkgsCross = if pkgs.system == system then
(import nixpkgs { system = pkgs.system; overlays = [ c2vi-config.overlays.static ]; })
else
(import nixpkgs { system = pkgs.system; crossSystem = system; overlays = [ c2vi-config.overlays.static ]; })
;
in rec {
proot = pkgsCross.pkgsStatic.proot;
nix = pkgsCross.pkgsStatic.nix;
busybox = pkgsCross.pkgsStatic.busybox;
cacert = pkgsCross.cacert;
info = pkgs.buildPackages.closureInfo { rootPaths = [ nix busybox cacert ]; };
inherit system;
};
# /*
getVicorinix = pkgs: crossSystem: short: cargoSha256: let
pkgsStatic = if pkgs.system == crossSystem then pkgs.pkgsStatic else pkgs.pkgsCross.${crossSystem}.pkgsStatic;
in pkgsStatic.rustPlatform.buildRustPackage rec {
name = "victorinix-${short}";
VIC_BUILD_CONFIG = pkgs.writeTextFile {
name = "vic-build-config";
text = builtins.toJSON defaultVicConfig;
};
buildInputs = with pkgsStatic; [ libelf openssl ];
nativeBuildInputs = with pkgs; [ pkg-config ];
src = filteredRustSource;
inherit cargoSha256;
#cargoSha256 = "sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=";
};
# */
/*
# this does not work, failing to find cc: error: linker `cc` not found ... No such file or directory (os error 2)
getVicorinix = pkgs: crossSystem: short: cargoSha256 let
pkgsStatic = if pkgs.system == crossSystem then pkgs.pkgsStatic else pkgs.pkgsCross.${crossSystem}.pkgsStatic;
craneLib = crane.mkLib pkgsStatic;
in craneLib.buildPackage {
VIC_BUILD_CONFIG = pkgs.writeTextFile {
name = "victorinix-${short}";
text = builtins.toJSON defaultVicConfig;
};
src = self;
nativeBuildInputs = with pkgsStatic; [ pkg-config ];
buildInputs = with pkgsStatic; [ openssl libelf ];
};
# */
in rec {
packages = rec {
proot-la =
let
pkgs = import nixpkgs { system = system; crossSystem = "aarch64-linux"; overlays = [ c2vi-config.overlays.static ]; };
in pkgs.pkgsStatic.proot;
proot-l =
let
pkgs = import nixpkgs { system = system; crossSystem = "x86_64-linux"; overlays = [ c2vi-config.overlays.static ]; };
in pkgs.pkgsStatic.proot;
victorinix-l = getVicorinix pkgs "x86_64-linux" "l" "sha256-0kAb+sieN+Ipnr8E3CS3oy+9+4qvUQU3rXrhpJyGTIM=";
webfiles = pkgs.callPackage ./webfiles.nix {inherit inputs nixpkgs self c2vi-config url getTarballClosure getVicorinix; vicConfig = defaultVicConfig; };
webrun = pkgs.writeShellScriptBin "vic-webrun" ''
${pkgs.darkhttpd}/bin/darkhttpd ${packages.webfiles} --log ./victorinix-access.log $@
'';
npmPackage = pkgs.buildNpmPackage {
VIC_URL = url;
pname = "victorinix-npmPackage";
version = self.packages.${system}.vic.version;
src = "${self}/npm-package";
};
pkgsStatic.vic = let
craneLib = crane.mkLib pkgs.pkgsStatic;
in craneLib.buildPackage {
VIC_BUILD_CONFIG = pkgs.writeTextFile {
name = "vic-build-config";
text = builtins.toJSON defaultVicConfig;
};
src = self;
nativeBuildInputs = with pkgs.pkgsStatic; [ pkg-config libgcc gcc openssl libelf ];
buildInputs = with pkgs.pkgsStatic; [ libgcc gcc ];
};
victorinix-la = getVicorinix pkgs "aarch64-multiplatform" "la" "sha256-eB/+tcI5+pWSMq2fIKI3qPcuRKOg0r1C3/wm999G8CE=";
vicPkgs = pkgs
// (import vicPkgs { inherit pkgs; }).extra
// (import vicPkgs { inherit pkgs; }).winePkgs
;
} // (c2vi-config.lib.flakeAddCross { inherit system; } ({ crossSystemFullString, ... }:
############## cross compilable packages
let
craneLib = crane.lib.${system}.overrideToolchain fenix.packages.${system}.targets.${crossSystemFullString}.latest.toolchain;
in
{
inherit craneLib;
vic = craneLib.buildPackage {
VIC_BUILD_CONFIG = pkgs.writeTextFile {
name = "vic-build-config";
text = builtins.toJSON defaultVicConfig;
};
src = self;
nativeBuildInputs = with pkgs; [ pkg-config openssl libelf ];
};
}));
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ pkg-config libelf openssl cargo rustc nodePackages.npm gnumake ];
shellHook = ''
export VIC_BUILD_CONFIG=${pkgs.writeTextFile {
name = "vic-build-config";
text = builtins.toJSON defaultVicConfig;
}}
echo "set VIC_BUILD_CONFIG"
'';
};
});
}