Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 1 | { |
| 2 | description = "A basic flake with a shell"; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame] | 3 | inputs.nixpkgs.follows = "clicks-server/nixpkgs"; |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 4 | inputs.flake-utils.url = "github:numtide/flake-utils"; |
Skyler Grey | 9b6992a | 2023-06-09 12:46:05 +0200 | [diff] [blame^] | 5 | inputs.clicks-server.url = "git+ssh://git@github.com/clicksminuteper/nixfiles"; |
| 6 | inputs.pnpm2nix.url = "git+ssh://git@github.com/clicksminuteper/pnpm2nix"; |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 7 | |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame] | 8 | inputs.pnpm2nix.inputs.nixpkgs.follows = "nixpkgs"; |
| 9 | |
| 10 | outputs = { self, nixpkgs, flake-utils, clicks-server, pnpm2nix }: |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 11 | flake-utils.lib.eachDefaultSystem (system: let |
| 12 | pkgs = nixpkgs.legacyPackages.${system}; |
TheCodedProf | 7b985d8 | 2023-06-08 16:40:41 -0400 | [diff] [blame] | 13 | nodejs = pkgs.nodejs_20; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame] | 14 | nodePackages = pkgs.nodePackages_latest; |
| 15 | lib = pkgs.lib; |
| 16 | in rec { |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 17 | devShells.default = pkgs.mkShell { |
TheCodedProf | 7b985d8 | 2023-06-08 16:40:41 -0400 | [diff] [blame] | 18 | packages = [ nodejs nodePackages.pnpm pkgs.pkg-config pkgs.fontconfig.dev ]; |
TheCodedProf | a0e072a | 2023-04-22 19:57:56 -0400 | [diff] [blame] | 19 | shellHook = '' |
| 20 | unset name |
TheCodedProf | 7b985d8 | 2023-06-08 16:40:41 -0400 | [diff] [blame] | 21 | 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 | ]} |
TheCodedProf | a0e072a | 2023-04-22 19:57:56 -0400 | [diff] [blame] | 30 | ''; |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 31 | }; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame] | 32 | |
| 33 | packages.env = lib.pipe { |
| 34 | src = ./.; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame] | 35 | } [ |
TheCodedProf | 7a182d8 | 2023-06-07 17:23:55 -0400 | [diff] [blame] | 36 | (pnpm2nix.mkPnpmPackage.${system}) |
| 37 | (pnpm2nix.mkPnpmEnv.${system}) |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame] | 38 | ]; |
| 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 Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 70 | }); |
Skyler Grey | 9b6992a | 2023-06-09 12:46:05 +0200 | [diff] [blame^] | 71 | } |