-
-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathflake.nix
More file actions
131 lines (118 loc) · 3.55 KB
/
flake.nix
File metadata and controls
131 lines (118 loc) · 3.55 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
crane = {
url = "github:ipetkov/crane";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
crane,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.stable.latest.default;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter =
path: type:
(pkgs.lib.hasSuffix "\.css" path)
|| (pkgs.lib.hasSuffix "\.js" path)
|| (pkgs.lib.hasSuffix "\.svg" path)
|| (pkgs.lib.hasSuffix "\.sqlite3" path)
|| (craneLib.filterCargoSources path type);
};
commonArgs = {
inherit src;
buildInputs = [
pkgs.git
pkgs.pkg-config
];
nativeBuildInputs = [ pkgs.openssl ];
};
ui = pkgs.buildNpmPackage {
pname = "ui";
version = "0.0.0";
src = ./ui;
npmDepsHash = "sha256-4mDe8b5J1wrHz7OCClkE5WTbtfs3TMZB/vhiVuaHiyQ=";
installPhase = ''
cp -pr --reflink=auto -- dist "$out/"
'';
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
bin = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
preBuild = ''
cp -pr --reflink=auto -- ${ui} ui/dist
'';
}
);
docker = pkgs.dockerTools.buildLayeredImage {
name = "sql-studio";
tag = "latest";
created = "now";
contents = [ bin ];
};
version = "0.1.46";
deploy = pkgs.writeShellScriptBin "deploy" ''
${pkgs.skopeo}/bin/skopeo --insecure-policy copy docker-archive:${docker} docker://docker.io/frectonz/sql-studio:${version} --dest-creds="frectonz:$ACCESS_TOKEN"
${pkgs.skopeo}/bin/skopeo --insecure-policy copy docker://docker.io/frectonz/sql-studio:${version} docker://docker.io/frectonz/sql-studio:latest --dest-creds="frectonz:$ACCESS_TOKEN"
'';
in
{
packages = {
inherit deploy docker ui;
default = bin;
};
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.bacon
pkgs.emmet-ls
pkgs.cargo-dist
pkgs.cargo-watch
pkgs.rust-analyzer
pkgs.cargo-outdated
rustToolchain
pkgs.nodejs
pkgs.nodePackages.typescript-language-server
pkgs.nodePackages.vscode-langservers-extracted
pkgs.nodePackages."@tailwindcss/language-server"
pkgs.httpie
pkgs.sqlite
pkgs.prefetch-npm-deps
];
};
formatter = pkgs.treefmt.withConfig {
runtimeInputs = [ pkgs.nixfmt-rfc-style ];
settings = {
# Log level for files treefmt won't format
on-unmatched = "info";
# Configure nixfmt for .nix files
formatter.nixfmt = {
command = "nixfmt";
includes = [ "*.nix" ];
};
};
};
}
);
}