-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
112 lines (112 loc) · 3.59 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = {
self,
nixpkgs,
vscode-extensions,
flake-parts,
}: let
main = {
name,
port ? 2352,
systems ? ["x86_64-linux"],
extensions ? _: [],
nixpkgsConfig ? {},
overlays ? [],
deps ? _: [],
devDeps ? pkgs: [pkgs.nix pkgs.git],
extraShells ? system: pkgs: {},
packages ? system: pkgs: {},
patches ? {},
functor ? builtins.throw "flake ${name} cannot be invoked",
}:
builtins.foldl'
nixpkgs.lib.attrsets.recursiveUpdate
{}
(builtins.map
(system: let
encase = args:
import ./encase.nix ({
name = "${name}-encase";
inherit system pkgs;
}
// args);
pkgs = import ((import nixpkgs {
inherit system;
}).applyPatches {
name = "nixpkgs-patched-${name}";
src = nixpkgs;
patches = patches.nixpkgs or [./vscode-serve-web.patch];
patchFlags = ["-t" "-p1"];
}) {
inherit system overlays;
config = { allowUnfree = true; } // nixpkgsConfig; # vscodium serve-web doesn't work
};
mkVsCode = vscode:
pkgs.vscode-with-extensions.override {
vscode = vscode;
vscodeExtensions = extensions vscode-extensions.extensions.${system}.open-vsx;
};
in {
devShells.${system} = {
default = pkgs.mkShell {
name = "${name}-dev";
buildInputs = deps pkgs ++ devDeps pkgs;
};
} // extraShells system pkgs;
apps.${system} = {
ide.type = "app";
ide.program = "${encase {
rw.work.${name} = "$origdir";
rw.run = /run;
ro.nix = /nix;
ro.dev = /dev;
ro.etc = /etc;
wd = /work/${name};
net = true;
proc = /proc;
tmp = /tmp;
command = ''
TMPDIR=/tmp HOME=/tmp/home exec nix develop path:. -c ${mkVsCode pkgs.vscodium-fhs}/bin/codium --in-process-gpu --disable-software-rasterizer --disable-gpu --no-sandbox -w . --user-data-dir /tmp/vscode
'';
}}";
web-ide.type = "app";
web-ide.program = "${encase {
rw.work.${name} = "$origdir";
rw.run = /run;
ro.nix = /nix;
ro.dev = /dev;
ro.etc = /etc;
wd = /work/${name};
net = true;
proc = /proc;
tmp = /tmp;
command = ''
TMPDIR=/tmp HOME=/tmp/home exec nix develop path:. -c ${mkVsCode pkgs.vscode-fhs}/bin/code serve-web --host 0.0.0.0 --port ${toString port} --without-connection-token --verbose --user-data-dir /tmp/vscode
'';
}}";
};
formatter.${system} = pkgs.alejandra;
packages.${system} = packages system pkgs;
__functor = self: functor;
})
systems);
in
main {
name = "stddev";
devDeps = pkgs: [pkgs.nix pkgs.nil pkgs.git];
extensions = exts: [exts.jnoortheen.nix-ide];
packages = system: pkgs: {
default = pkgs.writeShellScriptBin "stddev" ''
${pkgs.cowsay}/bin/cowsay "The environment is working!"
'';
};
}
// {
__functor = this: main;
};
}