blob: fd6cfb6e54af0bef0a8922205fd4c059eac0cfd1 [file] [log] [blame]
Skyler Grey453b9992023-03-05 05:48:42 +00001{
2 description = "A basic flake with a shell";
TheCodedProf4a7c25d2023-06-07 17:09:45 -04003 inputs.nixpkgs.follows = "clicks-server/nixpkgs";
Skyler Grey453b9992023-03-05 05:48:42 +00004 inputs.flake-utils.url = "github:numtide/flake-utils";
TheCodedProf4a7c25d2023-06-07 17:09:45 -04005 inputs.clicks-server.url = "github:clicksminuteper/nixfiles";
6 inputs.pnpm2nix.url = "github:clicksminuteper/pnpm2nix";
Skyler Grey453b9992023-03-05 05:48:42 +00007
TheCodedProf4a7c25d2023-06-07 17:09:45 -04008 inputs.pnpm2nix.inputs.nixpkgs.follows = "nixpkgs";
9
10 outputs = { self, nixpkgs, flake-utils, clicks-server, pnpm2nix }:
Skyler Grey453b9992023-03-05 05:48:42 +000011 flake-utils.lib.eachDefaultSystem (system: let
12 pkgs = nixpkgs.legacyPackages.${system};
TheCodedProf4a7c25d2023-06-07 17:09:45 -040013 nodejs = pkgs.nodejs-19_x;
14 nodePackages = pkgs.nodePackages_latest;
15 lib = pkgs.lib;
16 in rec {
Skyler Grey453b9992023-03-05 05:48:42 +000017 devShells.default = pkgs.mkShell {
TheCodedProf4a7c25d2023-06-07 17:09:45 -040018 packages = [ nodejs nodePackages.pnpm ];
TheCodedProfa0e072a2023-04-22 19:57:56 -040019 shellHook = ''
20 unset name
21 '';
Skyler Grey453b9992023-03-05 05:48:42 +000022 };
TheCodedProf4a7c25d2023-06-07 17:09:45 -040023
24 packages.env = lib.pipe {
25 src = ./.;
26 packageJSON = ./package.json;
27 } [
28 pnpm2nix.mkPnpmPackage
29 pnpm2nix.mkPnpmEnv
30 ];
31
32 packages.default = let
33 packageJSON = (builtins.fromJSON (builtins.readFile ./package.json));
34 in pkgs.stdenv.mkDerivation {
35 pname = "nucleus";
36 version = packageJSON.version;
37
38 src = ./.;
39
40 buildInputs = [ packages.env nodejs nodePackages.pnpm ];
41 nativeBuildInputs = [ packages.env nodePackages.pnpm ];
42
43 buildPhase = ''
44 pnpm run build
45 '';
46
47 installPhase = ''
48 cp dist $out
49 mkdir -p $out/bin
50 echo "#!/usr/bin/env bash\ncd $out\n${packageJSON.scripts.start}" > $out/bin/nucleus
51 '';
52 };
53
54 dockerImage = let
55 nucleus = packages.default;
56 in pkgs.dockerTools.streamLayeredImage {
57 name = "nucleus";
58 tag = "latest";
59 contents = [ nucleus ];
60 config.Cmd = [ "${nucleus}/bin/nucleus" ];
61 };
Skyler Grey453b9992023-03-05 05:48:42 +000062 });
TheCodedProfa0e072a2023-04-22 19:57:56 -040063}