-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
117 lines (110 loc) · 4.02 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
{
description = "Memex Applications";
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
# Use https://github.com/maximoffua/flutter.nix because the nixpkgs version is outdated
flutter-nix = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:maximoffua/flutter.nix";
};
devshell = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:numtide/devshell";
};
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
};
outputs = { self, nixpkgs, flutter-nix, devshell, flake-utils, nix-filter }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = false;
overlays = [
devshell.overlays.default
# If the flutter.nix flake ever creates problems, remove
# this overlay and the nixpkgs version will be used again.
flutter-nix.overlays.default
];
};
buildMemexApplication = { name, nativeBuildInputs ? [ ] }:
pkgs.flutter.buildFlutterApplication {
pname = name;
version = "git";
src = nix-filter.lib {
root = ./packages;
# This filter limits the source to the package and its dependencies.
# This way, Nix will know not to rebuild packages that did not change.
include = [
"${name}"
"memex_ui"
"memex_data"
"appflowy-editor"
];
};
pubspecLock = pkgs.lib.importJSON ./packages/${name}/pubspec.lock.json;
sourceRoot = "source/${name}";
nativeBuildInputs = nativeBuildInputs;
};
memex_activity_monitor = buildMemexApplication {
name = "memex_activity_monitor";
};
#memex_editor = buildMemexApplication {
# name = "memex_editor";
#};
memex_ui_examples = buildMemexApplication {
name = "memex_ui_examples";
};
memex_music = buildMemexApplication {
name = "memex_music";
};
memex_filepicker = buildMemexApplication {
name = "memex_filepicker";
};
memex_bar = buildMemexApplication {
name = "memex_bar";
nativeBuildInputs = with pkgs; [
pkg-config
gtk-layer-shell.dev
];
};
in
{
packages.activity_monitor = memex_activity_monitor;
# packages.editor = memex_editor;
packages.ui_examples = memex_ui_examples;
packages.music = memex_music;
packages.filepicker = memex_filepicker;
packages.bar = memex_bar;
# The default package contains all applications.
packages.default = pkgs.stdenv.mkDerivation {
name = "memex";
buildInputs = [
memex_activity_monitor
#memex_editor
memex_ui_examples
memex_music
memex_filepicker
memex_bar
];
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/bin;
mkdir -p $out/app/lib;
mkdir -p $out/app/data/flutter_assets/fonts;
mkdir -p $out/app/data/flutter_assets/packages;
mkdir -p $out/app/data/flutter_assets/shaders;
# Loop over all applications and copy their files into the output directory.
for app in $buildInputs; do
cp -rn $app/bin/* $out/bin/ || true;
cp -rn $app/app/lib/* $out/app/lib || true;
cp -rn $app/app/data/flutter_assets/fonts/* $out/app/data/flutter_assets/fonts/ || true;
cp -rn $app/app/data/flutter_assets/packages/* $out/app/data/flutter_assets/packages/ || true;
cp -rn $app/app/data/flutter_assets/shaders/* $out/app/data/flutter_assets/shaders/ || true;
done
'';
};
devShell = import ./devshell.nix { inherit pkgs; };
}
);
}