blob: f8d589626f66ba34628f2e8db53cef4ad45fb7fa [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 = ./.;
TheCodedProf4a7c25d2023-06-07 17:09:45 -040026 } [
TheCodedProf7a182d82023-06-07 17:23:55 -040027 (pnpm2nix.mkPnpmPackage.${system})
28 (pnpm2nix.mkPnpmEnv.${system})
TheCodedProf4a7c25d2023-06-07 17:09:45 -040029 ];
30
31 packages.default = let
32 packageJSON = (builtins.fromJSON (builtins.readFile ./package.json));
33 in pkgs.stdenv.mkDerivation {
34 pname = "nucleus";
35 version = packageJSON.version;
36
37 src = ./.;
38
39 buildInputs = [ packages.env nodejs nodePackages.pnpm ];
40 nativeBuildInputs = [ packages.env nodePackages.pnpm ];
41
42 buildPhase = ''
43 pnpm run build
44 '';
45
46 installPhase = ''
47 cp dist $out
48 mkdir -p $out/bin
49 echo "#!/usr/bin/env bash\ncd $out\n${packageJSON.scripts.start}" > $out/bin/nucleus
50 '';
51 };
52
53 dockerImage = let
54 nucleus = packages.default;
55 in pkgs.dockerTools.streamLayeredImage {
56 name = "nucleus";
57 tag = "latest";
58 contents = [ nucleus ];
59 config.Cmd = [ "${nucleus}/bin/nucleus" ];
60 };
Skyler Grey453b9992023-03-05 05:48:42 +000061 });
TheCodedProfa0e072a2023-04-22 19:57:56 -040062}