blob: 8a6f7d7771aa9c0d31561e876d75138357d0b72d [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};
TheCodedProf7b985d82023-06-08 16:40:41 -040013 nodejs = pkgs.nodejs_20;
TheCodedProf4a7c25d2023-06-07 17:09:45 -040014 nodePackages = pkgs.nodePackages_latest;
15 lib = pkgs.lib;
16 in rec {
Skyler Grey453b9992023-03-05 05:48:42 +000017 devShells.default = pkgs.mkShell {
TheCodedProf7b985d82023-06-08 16:40:41 -040018 packages = [ nodejs nodePackages.pnpm pkgs.pkg-config pkgs.fontconfig.dev ];
TheCodedProfa0e072a2023-04-22 19:57:56 -040019 shellHook = ''
20 unset name
TheCodedProf7b985d82023-06-08 16:40:41 -040021 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${lib.makeSearchPath "/lib/pkgconfig" [
22 pkgs.pixman
23 pkgs.cairo.dev
24 pkgs.libpng.dev
25 pkgs.gnome2.pango.dev
26 pkgs.glib.dev
27 pkgs.harfbuzz.dev
28 pkgs.freetype.dev
29 ]}
TheCodedProfa0e072a2023-04-22 19:57:56 -040030 '';
Skyler Grey453b9992023-03-05 05:48:42 +000031 };
TheCodedProf4a7c25d2023-06-07 17:09:45 -040032
33 packages.env = lib.pipe {
34 src = ./.;
TheCodedProf4a7c25d2023-06-07 17:09:45 -040035 } [
TheCodedProf7a182d82023-06-07 17:23:55 -040036 (pnpm2nix.mkPnpmPackage.${system})
37 (pnpm2nix.mkPnpmEnv.${system})
TheCodedProf4a7c25d2023-06-07 17:09:45 -040038 ];
39
40 packages.default = let
41 packageJSON = (builtins.fromJSON (builtins.readFile ./package.json));
42 in pkgs.stdenv.mkDerivation {
43 pname = "nucleus";
44 version = packageJSON.version;
45
46 src = ./.;
47
48 buildInputs = [ packages.env nodejs nodePackages.pnpm ];
49 nativeBuildInputs = [ packages.env nodePackages.pnpm ];
50
51 buildPhase = ''
52 pnpm run build
53 '';
54
55 installPhase = ''
56 cp dist $out
57 mkdir -p $out/bin
58 echo "#!/usr/bin/env bash\ncd $out\n${packageJSON.scripts.start}" > $out/bin/nucleus
59 '';
60 };
61
62 dockerImage = let
63 nucleus = packages.default;
64 in pkgs.dockerTools.streamLayeredImage {
65 name = "nucleus";
66 tag = "latest";
67 contents = [ nucleus ];
68 config.Cmd = [ "${nucleus}/bin/nucleus" ];
69 };
Skyler Grey453b9992023-03-05 05:48:42 +000070 });
TheCodedProfa0e072a2023-04-22 19:57:56 -040071}