-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
142 lines (111 loc) · 3.88 KB
/
flake.nix
File metadata and controls
142 lines (111 loc) · 3.88 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
{
description = "An over-engineered Hello World in bash";
# Nixpkgs / NixOS version to use.
inputs.nixpkgs.url = "nixpkgs/nixos-21.05";
outputs =
{ self, nixpkgs }:
let
# inherit nixpkgs;
# to work with older version of flakes
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
# Generate a user-friendly version number.
version = builtins.substring 0 8 lastModifiedDate;
# System types to support.
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (
system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
}
);
FLUTTER_VERSION = "3.27.1";
FILENAME = "flutter_linux_${FLUTTER_VERSION}-stable.tar.xz";
FETCH_URL = "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/${FILENAME}";
in
{
# A Nixpkgs overlay.
overlay = final: prev: {
flutter =
with final;
stdenv.mkDerivation rec {
inherit self;
flutterArchive = builtins.fetchurl {
url = "${FETCH_URL}";
sha256 = "sha256-YUl+tkzXs6qZypkRzNkhyNq3mv2QnKHJ/5VGBn689so=";
executable = false;
};
name = "flutter-${version}";
src = self;
unpackPhase = ":";
buildPhase = ''
tar -xvf "${flutterArchive}"
'';
installPhase = "mkdir -p $out; cp -ar flutter/* $out";
};
};
# Provide some binary packages for selected system types.
packages = forAllSystems (system: {
inherit (nixpkgsFor.${system}) flutter;
});
# The default package for 'nix build'. This makes sense if the
# flake provides only one package or there is a clear "main"
# package.
defaultPackage = forAllSystems (system: self.packages.${system}.flutter);
# A NixOS module, if applicable (e.g. if the package provides a system service).
nixosModules.flutter =
{ pkgs, ... }:
{
nixpkgs.overlays = [ self.overlay ];
environment.systemPackages = [ pkgs.flutter ];
#systemd.services = { ... };
};
# # Tests run by 'nix flake check' and by Hydra.
# checks = forAllSystems
# (system:
# with nixpkgsFor.${system};
# {
# inherit (self.packages.${system}) hello;
# # Additional tests, if applicable.
# test = stdenv.mkDerivation {
# name = "hello-test-${version}";
# buildInputs = [ hello ];
# unpackPhase = "true";
# buildPhase = ''
# echo 'running some integration tests'
# [[ $(hello) = 'Hello Nixers!' ]]
# '';
# installPhase = "mkdir -p $out";
# };
# }
# // lib.optionalAttrs stdenv.isLinux {
# # A VM test of the NixOS module.
# vmTest =
# with import (nixpkgs + "/nixos/lib/testing-python.nix") {
# inherit system;
# };
# makeTest {
# nodes = {
# client = { ... }: {
# imports = [ self.nixosModules.hello ];
# };
# };
# testScript =
# ''
# start_all()
# client.wait_for_unit("multi-user.target")
# client.succeed("hello")
# '';
# };
# }
# );
};
}