-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathflake.nix
152 lines (142 loc) · 4.86 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
{
description = "Flake for the precice-Nix research project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# This allows us to use the garnix binary cache which the GitHub CI job
# copies the binaries to, so we don't have to build anything locally
nixConfig = {
extra-substituters = [ "https://cache.garnix.io" ];
extra-trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
};
# deadnix: skip
outputs =
{
self,
nixpkgs,
home-manager,
nixos-generators,
}:
let
precice-system-light = {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
./configuration-light.nix
];
};
precice-system-virtualbox-light = precice-system-light // {
modules = precice-system-light.modules ++ [
{
virtualbox = {
memorySize = 2048;
vmName = "preCICE-VM";
params = {
cpus = 2;
vram = 64;
graphicscontroller = "vmsvga"; # This is default
};
};
}
];
};
precice-system = {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
./configuration.nix
];
};
precice-system-vm = {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
./configuration.nix
{
virtualisation.memorySize = 4096;
virtualisation.diskSize = 4096;
}
];
};
precice-system-virtualbox = precice-system // {
modules = precice-system.modules ++ [
{
virtualbox = {
memorySize = 2048;
vmName = "preCICE-VM";
params = {
cpus = 2;
vram = 64;
graphicscontroller = "vmsvga"; # This is default
};
};
}
];
};
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = import ./precice-packages;
config.allowUnfree = true;
config.permittedInsecurePackages = [ "hdf5-1.10.9" ];
};
# This simply reads all defined names of the packages specified in the overlay, so it results in
# a list of package names: [ "blacs" "dealii" ... ]
precice-package-names = builtins.attrNames (
(builtins.elemAt (import ./precice-packages) 1) null { callPackage = { }; }
);
# This expands "dealii" to `{ dealii = pkgs.dealii; }`
precice-packages = pkgs.lib.genAttrs precice-package-names (name: pkgs.${name});
in
rec {
# Access by running `nixos-rebuild --flake .#precice-vm build`
nixosConfigurations.precice-vm = nixpkgs.lib.nixosSystem precice-system;
# Access by running `nix build .#<attribute>`
packages.x86_64-linux =
{
# These are packages that are already available upstream.
# We simply re-expose them to allow for easy access by the nix tools.
inherit (pkgs) precice;
}
// precice-packages
// {
# Custom build packages for preCICE
iso = nixos-generators.nixosGenerate (precice-system // { format = "iso"; });
iso-light = nixos-generators.nixosGenerate (precice-system-light // { format = "iso"; });
vagrant-vbox-image = nixos-generators.nixosGenerate (
precice-system-virtualbox // { format = "vagrant-virtualbox"; }
);
vagrant-vbox-image-light = nixos-generators.nixosGenerate (
precice-system-virtualbox-light // { format = "vagrant-virtualbox"; }
);
vm = nixos-generators.nixosGenerate (precice-system-vm // { format = "vm"; });
vm-light = nixos-generators.nixosGenerate (precice-system-light // { format = "vm"; });
};
# Access by running `nix run`
apps.x86_64-linux.default = {
type = "app";
program = "${packages.x86_64-linux.vm}/bin/run-precice-vm-vm";
};
# Access by running `nix develop`
devShells.x86_64-linux.default = pkgs.mkShell {
buildInputs =
(import ./configuration.nix {
inherit pkgs;
inherit (nixpkgs) lib;
config = null;
}).environment.systemPackages;
shellHook = ''
source ${pkgs.openfoam}/bin/set-openfoam-vars
source ${pkgs.precice-dune}/bin/set-dune-vars
export LD_LIBRARY_PATH=${pkgs.precice-openfoam-adapter}/lib:$LD_LIBRARY_PATH
'';
};
};
}