diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 188 |
1 files changed, 98 insertions, 90 deletions
@@ -1,99 +1,107 @@ | |||
1 | { | 1 | { |
2 | inputs = { | 2 | inputs = { |
3 | |||
4 | nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | 3 | nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; |
5 | |||
6 | }; | 4 | }; |
7 | 5 | ||
8 | outputs = | 6 | outputs = { |
9 | { self | 7 | self, |
10 | , nixpkgs | 8 | nixpkgs, |
11 | }: | 9 | }: let |
12 | let | 10 | supportedSystems = ["x86_64-linux"]; |
13 | supportedSystems = [ "x86_64-linux" ]; | 11 | forAllSystems = nixpkgs.lib.genAttrs supportedSystems; |
14 | forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | 12 | nixpkgsFor = forAllSystems (system: |
15 | nixpkgsFor = forAllSystems (system: | 13 | import nixpkgs { |
16 | import nixpkgs { | 14 | inherit system; |
17 | inherit system; | 15 | overlays = [self.overlays.default]; |
18 | overlays = [ self.overlays.default ]; | 16 | }); |
19 | }); | 17 | in { |
20 | 18 | overlays.default = final: prev: { | |
21 | in | 19 | node_modules = with final; |
22 | { | 20 | stdenv.mkDerivation { |
23 | overlays.default = final: prev: { | 21 | pname = "readit-node-modules"; |
24 | node_modules = with final; stdenv.mkDerivation { | 22 | version = "0.0.1"; |
25 | pname = "readit-node-modules"; | 23 | impureEnvVars = |
26 | version = "0.0.1"; | 24 | lib.fetchers.proxyImpureEnvVars |
27 | impureEnvVars = lib.fetchers.proxyImpureEnvVars | 25 | ++ ["GIT_PROXY_COMMAND" "SOCKS_SERVER"]; |
28 | ++ [ "GIT_PROXY_COMMAND" "SOCKS_SERVER" ]; | 26 | src = ./.; |
29 | src = ./.; | 27 | nativeBuildInputs = [bun]; |
30 | nativeBuildInputs = [ bun ]; | 28 | buildInputs = [nodejs-slim_latest]; |
31 | buildInputs = [ nodejs-slim_latest ]; | 29 | dontConfigure = true; |
32 | dontConfigure = true; | 30 | dontFixup = true; |
33 | dontFixup = true; | 31 | buildPhase = '' |
34 | buildPhase = '' | 32 | bun install --no-progress --frozen-lockfile |
35 | bun install --no-progress --frozen-lockfile | 33 | ''; |
36 | ''; | 34 | installPhase = '' |
37 | installPhase = '' | 35 | mkdir -p $out/node_modules |
38 | mkdir -p $out/node_modules | 36 | cp -R ./node_modules/* $out/node_modules |
39 | cp -R ./node_modules/* $out/node_modules | 37 | ls -la $out/node_modules |
40 | ls -la $out/node_modules | 38 | ''; |
41 | ''; | 39 | outputHash = "sha256-qFYgRIarDChHQu0ZrUKd/Y61gxaagMWpf2h9xizwGv4="; |
42 | outputHash = "sha256-qFYgRIarDChHQu0ZrUKd/Y61gxaagMWpf2h9xizwGv4="; | 40 | outputHashAlgo = "sha256"; |
43 | outputHashAlgo = "sha256"; | 41 | outputHashMode = "recursive"; |
44 | outputHashMode = "recursive"; | ||
45 | }; | ||
46 | readit = with final; stdenv.mkDerivation { | ||
47 | pname = "readit"; | ||
48 | version = "0.0.1"; | ||
49 | src = ./.; | ||
50 | nativeBuildInputs = [ makeBinaryWrapper ]; | ||
51 | buildInputs = [ bun ]; | ||
52 | |||
53 | buildPhase = '' | ||
54 | runHook preBuild | ||
55 | |||
56 | |||
57 | runHook postBuild | ||
58 | ''; | ||
59 | |||
60 | dontFixup = true; | ||
61 | |||
62 | installPhase = '' | ||
63 | runHook preInstall | ||
64 | |||
65 | mkdir -p $out/bin | ||
66 | |||
67 | # cp app.js $out/app.js | ||
68 | cp -R ./* $out | ||
69 | |||
70 | # bun is referenced naked in the package.json generated script | ||
71 | # makeBinaryWrapper ${bun}/bin/bun $out/bin/$pname \ | ||
72 | # --add-flags "run --prefer-offline --no-install $out/app.js" | ||
73 | |||
74 | makeBinaryWrapper ${bun}/bin/bun $out/bin/$pname \ | ||
75 | --prefix PATH : ${lib.makeBinPath [ bun ]} \ | ||
76 | --add-flags "run --prefer-offline --no-install $out/src/index.js" | ||
77 | |||
78 | ''; | ||
79 | }; | ||
80 | }; | 42 | }; |
43 | readit = with final; | ||
44 | stdenv.mkDerivation { | ||
45 | pname = "readit"; | ||
46 | version = "0.0.1"; | ||
47 | src = ./.; | ||
48 | nativeBuildInputs = [makeBinaryWrapper]; | ||
49 | buildInputs = [bun]; | ||
81 | 50 | ||
82 | devShell = forAllSystems (system: | 51 | buildPhase = '' |
83 | let | 52 | runHook preBuild |
84 | pkgs = nixpkgsFor."${system}"; | 53 | |
85 | in | 54 | |
86 | pkgs.mkShell { | 55 | runHook postBuild |
87 | nativeBuildInputs = [ | 56 | ''; |
88 | pkgs.bun | 57 | |
89 | ]; | 58 | dontFixup = true; |
90 | RUST_BACKTRACE = 1; | 59 | |
91 | }); | 60 | installPhase = '' |
92 | 61 | runHook preInstall | |
93 | packages = forAllSystems(system: { | ||
94 | inherit (nixpkgsFor."${system}") readit node_modules; | ||
95 | }); | ||
96 | }; | ||
97 | } | ||
98 | 62 | ||
63 | mkdir -p $out/bin | ||
99 | 64 | ||
65 | ln -s ${node_modules}/node_modules $out | ||
66 | cp -R ./* $out | ||
67 | |||
68 | # bun is referenced naked in the package.json generated script | ||
69 | # makeBinaryWrapper ${bun}/bin/bun $out/bin/$pname \ | ||
70 | # --add-flags "run --prefer-offline --no-install $out/app.js" | ||
71 | |||
72 | makeBinaryWrapper ${bun}/bin/bun $out/bin/$pname \ | ||
73 | --prefix PATH : ${lib.makeBinPath [bun]} \ | ||
74 | --add-flags "run --prefer-offline --no-install $out/src/index.js" | ||
75 | |||
76 | ''; | ||
77 | }; | ||
78 | }; | ||
79 | |||
80 | devShell = forAllSystems (system: let | ||
81 | pkgs = nixpkgsFor."${system}"; | ||
82 | in | ||
83 | pkgs.mkShell { | ||
84 | nativeBuildInputs = [ | ||
85 | pkgs.bun | ||
86 | ]; | ||
87 | RUST_BACKTRACE = 1; | ||
88 | }); | ||
89 | |||
90 | packages = forAllSystems (system: { | ||
91 | inherit (nixpkgsFor."${system}") readit node_modules; | ||
92 | }); | ||
93 | |||
94 | defaultPackage = forAllSystems (system: nixpkgsFor."${system}".readit); | ||
95 | |||
96 | apps = forAllSystems (system: let | ||
97 | pkgs = nixpkgsFor.${system}; | ||
98 | in { | ||
99 | default = { | ||
100 | type = "app"; | ||
101 | program = "${pkgs.readit}/bin/readit"; | ||
102 | }; | ||
103 | }); | ||
104 | |||
105 | formatter = forAllSystems (system: nixpkgsFor."${system}".alejandra); | ||
106 | }; | ||
107 | } | ||