-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
134 lines (122 loc) · 3.2 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
{
description = "F# Development Environment";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
devenv = {
url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
devenv,
nixpkgs,
...
}:
let
# System types to support.
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
"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;
}
);
in
{
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor."${system}";
name = "sample";
version = "0.1.0";
in rec
{
# `nix build`
default = pkgs.buildDotnetModule {
pname = name;
version = version;
src = ./.;
projectFile = "src/App/App.fsproj";
nugetDeps = ./deps.nix;
dotnet-sdk =
with pkgs.dotnetCorePackages;
combinePackages [
sdk_8_0
];
dotnet-runtime = pkgs.dotnetCorePackages.sdk_8_0;
};
# nix build .#dockerImage
dockerImage = pkgs.dockerTools.buildLayeredImage {
name = "sample";
tag = "latest";
created = "now";
contents = [ default ];
config = {
Cmd = [
"${default}/bin/App"
];
};
};
}
);
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor."${system}";
dotnet =
with pkgs.dotnetCorePackages;
combinePackages [
sdk_8_0
];
in
{
# `nix develop .#ci`
# reduce the number of packages to the bare minimum needed for CI
ci = pkgs.mkShell {
buildInputs = with pkgs; [
git
just
dotnet
];
};
# `nix develop --impure`
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
(
{ pkgs, lib, ... }:
{
packages = with pkgs; [
bash
just
# for dotnet
netcoredbg
fsautocomplete
fantomas
];
languages.dotnet = {
enable = true;
package = dotnet;
};
# looks for the .env by default additionaly, there is .filename
# if an arbitrary file is desired
dotenv.enable = true;
}
)
];
};
}
);
# nix fmt
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
};
}