-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
146 lines (133 loc) · 4.34 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
{
inputs = {
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
nci = {
url = "github:yusdacra/nix-cargo-integration";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devshell.flakeModule
inputs.flake-parts.flakeModules.easyOverlay
inputs.nci.flakeModule
inputs.pre-commit-hooks.flakeModule
inputs.treefmt-nix.flakeModule
];
systems = [
"x86_64-linux"
"aarch64-linux"
];
flake =
{ config, ... }:
{
nixosModules.default = {
imports = [ ./nix/nixosModules/idmail.nix ];
nixpkgs.overlays = [ config.overlays.default ];
};
};
perSystem =
{
config,
lib,
pkgs,
...
}:
let
projectName = "idmail";
tailwindcss = pkgs.nodePackages.tailwindcss.overrideAttrs (_prevAttrs: {
plugins = [
pkgs.nodePackages."@tailwindcss/aspect-ratio"
pkgs.nodePackages."@tailwindcss/forms"
pkgs.nodePackages."@tailwindcss/language-server"
pkgs.nodePackages."@tailwindcss/line-clamp"
pkgs.nodePackages."@tailwindcss/typography"
];
});
extraNativeBuildInputs = [
pkgs.wasm-bindgen-cli
pkgs.binaryen
pkgs.cargo-leptos
tailwindcss
];
in
{
devshells.default = {
packages =
[
config.treefmt.build.wrapper
pkgs.cargo-release
]
# FIXME: why is this necessary? nci doesn't seem to add them automatically.
++ extraNativeBuildInputs;
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
};
pre-commit.settings.hooks.treefmt.enable = true;
treefmt = {
projectRootFile = "flake.nix";
programs = {
deadnix.enable = true;
statix.enable = true;
nixfmt.enable = true;
rustfmt.enable = true;
};
};
nci.projects.${projectName} = {
path = ./.;
numtideDevshell = "default";
};
nci.crates.${projectName} = {
drvConfig = {
mkDerivation = {
# add trunk and other dependencies
nativeBuildInputs = [
pkgs.makeWrapper
] ++ extraNativeBuildInputs;
# override build phase to build with trunk instead
buildPhase = ''
export -n CARGO_BUILD_TARGET
cargo leptos build --release -vvv
'';
installPhase = ''
mkdir -p $out/bin $out/share
cp target/release/${projectName} $out/bin/
cp -r target/site $out/share/
wrapProgram $out/bin/${projectName} \
--set LEPTOS_SITE_ROOT $out/share/site
'';
meta = {
description = "idmail, an email alias and account management interface for self-hosted mailservers";
homepage = "https://github.com/oddlama/idmail";
license = lib.licenses.mit;
#maintainers = with lib.maintainers; [oddlama];
mainProgram = "idmail";
};
};
env.RUSTFLAGS = "--cfg=web_sys_unstable_apis";
env.LEPTOS_ENV = "PROD";
};
};
packages.default = config.nci.outputs.${projectName}.packages.release;
packages.nixosTest = import ./nix/tests/idmail.nix {
inherit (inputs) self;
inherit pkgs lib;
};
overlayAttrs.idmail = config.packages.default;
};
};
}